Still a problem with the login & search doesn't work anymore with the
RequestStringWithCookiesAndRetry function.
This commit is contained in:
Thomas
2015-07-31 22:32:18 +02:00
parent ecacc0b129
commit 3b9d9ff0f8
2 changed files with 52 additions and 68 deletions

View File

@@ -23,8 +23,7 @@ namespace Jackett.Indexers
private string SearchUrl = "https://ncore.cc/torrents.php"; private string SearchUrl = "https://ncore.cc/torrents.php";
private static string LoginUrl = "https://ncore.cc/login.php"; private static string LoginUrl = "https://ncore.cc/login.php";
private readonly string LoggedInUrl = "https://ncore.cc/index.php"; private readonly string LoggedInUrl = "https://ncore.cc/index.php";
//private string cookieHeader = ""; //private JToken configData = null;
private JToken configData = null;
private readonly string enSearch = "torrents.php?oldal=1&tipus=kivalasztottak_kozott&kivalasztott_tipus=xvidser,dvdser,hdser&mire={0}&miben=name"; private readonly string enSearch = "torrents.php?oldal=1&tipus=kivalasztottak_kozott&kivalasztott_tipus=xvidser,dvdser,hdser&mire={0}&miben=name";
private readonly string hunSearch = "torrents.php?oldal=1&tipus=kivalasztottak_kozott&kivalasztott_tipus=xvidser_hun,dvdser_hun,hdser_hun,mire={0}&miben=name"; private readonly string hunSearch = "torrents.php?oldal=1&tipus=kivalasztottak_kozott&kivalasztott_tipus=xvidser_hun,dvdser_hun,hdser_hun,mire={0}&miben=name";
@@ -45,54 +44,46 @@ namespace Jackett.Indexers
logger: l) logger: l)
{ {
SearchUrl = SearchUrlEnHun; SearchUrl = SearchUrlEnHun;
//webclient = wc;
} }
public Task<ConfigurationData> GetConfigurationForSetup() public Task<ConfigurationData> GetConfigurationForSetup()
{ {
var config = configData == null ? new ConfigurationDatanCore() : new ConfigurationDatanCore(configData); //var config = configData == null ? new ConfigurationDatanCore() : new ConfigurationDatanCore(configData);
return Task.FromResult<ConfigurationData>(new ConfigurationDatanCore(configData)); //return Task.FromResult<ConfigurationData>(config);
return Task.FromResult<ConfigurationData>(new ConfigurationDatanCore());
} }
public async Task ApplyConfiguration(JToken configJson) public async Task ApplyConfiguration(JToken configJson)
{ {
var config = new ConfigurationDatanCore(); var incomingConfig = new ConfigurationDatanCore();
config.LoadValuesFromJson(configJson); incomingConfig.LoadValuesFromJson(configJson);
if (config.Hungarian.Value == false && config.English.Value == false) if (incomingConfig.Hungarian.Value == false && incomingConfig.English.Value == false)
throw new ExceptionWithConfigData("Please select atleast one language.", (ConfigurationData)config); throw new ExceptionWithConfigData("Please select atleast one language.", (ConfigurationData)incomingConfig);
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);
var pairs = new Dictionary<string, string> { var pairs = new Dictionary<string, string> {
{ "nev", config.Username.Value }, { "nev", incomingConfig.Username.Value },
{ "pass", config.Password.Value }, { "pass", incomingConfig.Password.Value },
{"ne_leptessen_ki", "on"} { "ne_leptessen_ki", "on"}
}; };
var response = await webclient.GetString(new Utils.Clients.WebRequest() var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, LoggedInUrl, LoggedInUrl);
ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("Felhasználó"), () =>
{ {
Url = LoginUrl, CQ dom = result.Content;
PostData = pairs, var messageEl = dom["#hibauzenet table tbody tr"];
Referer = SiteLink.ToString(), var msgContainer = messageEl.Get(0).ChildElements.ElementAt(1);
Type = RequestType.POST, var errorMessage = msgContainer != null ? msgContainer.InnerText : "Error while trying to login.";
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)incomingConfig);
}); });
if (!response.RedirectingTo.Equals("index.php")) //var configSaveData = new JObject();
{ //configSaveData["config"] = incomingConfig.ToJson();
var errorMessage = "Couldn't login"; //SaveConfig(configSaveData);
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
} }
else
{
var configSaveData = new JObject();
cookieHeader = response.Cookies;
cookieHeader = cookieHeader.Substring(0, cookieHeader.IndexOf(' ') - 1) + ";stilus=brutecore; nyelv=hu";
configSaveData["cookies"] = cookieHeader;
configSaveData["config"] = configData = config.ToJson();
SaveConfig(configSaveData);
IsConfigured = true;
}
}
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{ {
@@ -101,18 +92,10 @@ namespace Jackett.Indexers
var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString(); var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString();
var episodeSearchUrl = string.Format(SearchUrl, HttpUtility.UrlEncode(searchString)); var episodeSearchUrl = string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
//var response = await webclient.GetString(new Utils.Clients.WebRequest() var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl);
//{
// Url = episodeSearchUrl,
// Cookies = cookieHeader,
// Referer = SiteLink.ToString(),
//});
// var results = response.Content;
var results= "";
try try
{ {
CQ dom = results; CQ dom = response.Content;
ReleaseInfo release; ReleaseInfo release;
var rows = dom[".box_torrent_all"].Find(".box_torrent"); var rows = dom[".box_torrent_all"].Find(".box_torrent");
@@ -146,17 +129,18 @@ namespace Jackett.Indexers
} }
catch (Exception ex) catch (Exception ex)
{ {
//OnParseError(response.Content, ex); OnParseError(response.Content, ex);
} }
return releases.ToArray(); return releases.ToArray();
} }
//public void LoadFromSavedConfiguration(JToken jsonConfig) public override void LoadFromSavedConfiguration(JToken jsonConfig)
{
base.LoadFromSavedConfiguration(jsonConfig);
//if (jsonConfig["config"] != null)
//{ //{
// if (jsonConfig["config"] != null)
// {
// string hun, eng; // string hun, eng;
// Dictionary<string, string>[] configDictionary = JsonConvert.DeserializeObject<Dictionary<string, string>[]>(jsonConfig["config"].ToString()); // Dictionary<string, string>[] configDictionary = JsonConvert.DeserializeObject<Dictionary<string, string>[]>(jsonConfig["config"].ToString());
// configDictionary[2].TryGetValue("value", out hun); // configDictionary[2].TryGetValue("value", out hun);
@@ -173,10 +157,8 @@ namespace Jackett.Indexers
// SearchUrl = SearchUrlEn; // SearchUrl = SearchUrlEn;
// configData = jsonConfig["config"]; // configData = jsonConfig["config"];
// }
// cookieHeader = (string)jsonConfig["cookies"];
// IsConfigured = true;
//} //}
}
} }
} }

View File

@@ -186,6 +186,7 @@
<Compile Include="Indexers\HDTorrents.cs" /> <Compile Include="Indexers\HDTorrents.cs" />
<Compile Include="Indexers\IIndexer.cs" /> <Compile Include="Indexers\IIndexer.cs" />
<Compile Include="Indexers\ImmortalSeed.cs" /> <Compile Include="Indexers\ImmortalSeed.cs" />
<Compile Include="Indexers\nCore.cs" />
<Compile Include="Indexers\TorrentBytes.cs" /> <Compile Include="Indexers\TorrentBytes.cs" />
<Compile Include="Indexers\IPTorrents.cs" /> <Compile Include="Indexers\IPTorrents.cs" />
<Compile Include="Indexers\MoreThanTV.cs" /> <Compile Include="Indexers\MoreThanTV.cs" />
@@ -205,6 +206,7 @@
<Compile Include="Indexers\Torrentz.cs" /> <Compile Include="Indexers\Torrentz.cs" />
<Compile Include="Models\CachedResult.cs" /> <Compile Include="Models\CachedResult.cs" />
<Compile Include="Models\CategoryMapping.cs" /> <Compile Include="Models\CategoryMapping.cs" />
<Compile Include="Models\ConfigurationDatanCore.cs" />
<Compile Include="Models\IndexerConfig\BmtvConfig.cs" /> <Compile Include="Models\IndexerConfig\BmtvConfig.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginAnimeBytes.cs" /> <Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginAnimeBytes.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginFrenchTorrentDb.cs" /> <Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginFrenchTorrentDb.cs" />