From 0452f5ad06fa27e3c861ecfeb8b24d2e838ba452 Mon Sep 17 00:00:00 2001 From: coolius Date: Mon, 18 Apr 2016 14:42:53 +0100 Subject: [PATCH] Added AlternateLink to IPTorrents --- src/Jackett/Indexers/BitSoup.cs | 47 ++++++------------- src/Jackett/Indexers/IPTorrents.cs | 22 +++++---- src/Jackett/Jackett.csproj | 1 + ...gurationDataBasicLoginWithAlternateLink.cs | 27 +++++++++++ 4 files changed, 57 insertions(+), 40 deletions(-) create mode 100644 src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithAlternateLink.cs diff --git a/src/Jackett/Indexers/BitSoup.cs b/src/Jackett/Indexers/BitSoup.cs index 3946f5863..08d9e02bf 100644 --- a/src/Jackett/Indexers/BitSoup.cs +++ b/src/Jackett/Indexers/BitSoup.cs @@ -25,12 +25,12 @@ namespace Jackett.Indexers private string UseLink { get { return (this.configData.AlternateLink.Value != null && this.configData.AlternateLink.Value != "" ? this.configData.AlternateLink.Value : SiteLink); } } private string BrowseUrl { get { return UseLink + "browse.php"; } } private string LoginUrl { get { return UseLink + "takelogin.php"; } } - private string LoginReferer { get { return UseLink + "login.php"; } } - private List KnownURLs = new List{ "https://www.bitsoup.me/","https://www.bitsoup.org/"}; + private string LoginReferer { get { return UseLink + "login.php"; } } + private List KnownURLs = new List { "https://www.bitsoup.me/", "https://www.bitsoup.org/" }; - new NxtGnConfigurationData configData + new ConfigurationDataBasicLoginWithAlternateLink configData { - get { return (NxtGnConfigurationData)base.configData; } + get { return (ConfigurationDataBasicLoginWithAlternateLink)base.configData; } set { base.configData = value; } } @@ -43,11 +43,11 @@ namespace Jackett.Indexers client: wc, logger: l, p: ps, - configData: new NxtGnConfigurationData()) + configData: new ConfigurationDataBasicLoginWithAlternateLink()) { - this.configData.DisplayText.Value = this.DisplayName + " has multiple URLs. The default (" + this.SiteLink + ") can be changed by entering a new value in the box below."; - this.configData.DisplayText.Value += "The following are some known URLs for " + this.DisplayName; - this.configData.DisplayText.Value += "
  • " + String.Join("
  • ", this.KnownURLs.ToArray()) + "
"; + this.configData.Instructions.Value = this.DisplayName + " has multiple URLs. The default (" + this.SiteLink + ") can be changed by entering a new value in the box below."; + this.configData.Instructions.Value += "The following are some known URLs for " + this.DisplayName; + this.configData.Instructions.Value += "
  • " + String.Join("
  • ", this.KnownURLs.ToArray()) + "
"; //AddCategoryMapping("624", TorznabCatType.Console); //AddCategoryMapping("307", TorznabCatType.ConsoleNDS); @@ -158,12 +158,12 @@ namespace Jackett.Indexers { configData.AlternateLink.Value = null; throw new Exception("AlternateLink must be a valid url."); - } + } } var pairs = new Dictionary { { "username", configData.Username.Value }, { "password", configData.Password.Value }, - + }; var loginPage = await RequestStringWithCookies(UseLink, string.Empty); @@ -188,11 +188,12 @@ namespace Jackett.Indexers var queryCollection = new NameValueCollection(); - queryCollection.Add("search", string.IsNullOrWhiteSpace(searchString)? "" : searchString); + queryCollection.Add("search", string.IsNullOrWhiteSpace(searchString) ? "" : searchString); if (trackerCats.Count > 1) { - for (var ct = 0; ct < trackerCats.Count; ct++) queryCollection.Add("cat" + (ct+1), trackerCats.ElementAt(ct)); - } else + for (var ct = 0; ct < trackerCats.Count; ct++) queryCollection.Add("cat" + (ct + 1), trackerCats.ElementAt(ct)); + } + else { queryCollection.Add("cat", (trackerCats.Count == 1 ? trackerCats.ElementAt(0) : "0")); } @@ -242,23 +243,5 @@ namespace Jackett.Indexers OnParseError(results, ex); } } - - public class NxtGnConfigurationData : ConfigurationData - { - public StringItem Username { get; private set; } - public StringItem Password { get; private set; } - public DisplayItem DisplayText { get; private set; } - public StringItem AlternateLink { get; set; } - - - public NxtGnConfigurationData() - { - Username = new StringItem { Name = "Username" }; - Password = new StringItem { Name = "Password" }; - DisplayText = new DisplayItem("") { Name = "" }; - AlternateLink = new StringItem { Name = "AlternateLinks" }; - } - - } } -} +} \ No newline at end of file diff --git a/src/Jackett/Indexers/IPTorrents.cs b/src/Jackett/Indexers/IPTorrents.cs index ec1dc2ffd..d76e68186 100644 --- a/src/Jackett/Indexers/IPTorrents.cs +++ b/src/Jackett/Indexers/IPTorrents.cs @@ -21,11 +21,13 @@ namespace Jackett.Indexers { public class IPTorrents : BaseIndexer, IIndexer { - private string BrowseUrl { get { return SiteLink + "t"; } } + private string UseLink { get { return (!String.IsNullOrEmpty(this.configData.AlternateLink.Value) ? this.configData.AlternateLink.Value : SiteLink); } } + private string BrowseUrl { get { return UseLink + "t"; } } + private List KnownURLs = new List { "https://nemo.iptorrents.com/", "https://ipt.rocks/" }; - new ConfigurationDataBasicLogin configData + new ConfigurationDataBasicLoginWithAlternateLink configData { - get { return (ConfigurationDataBasicLogin)base.configData; } + get { return (ConfigurationDataBasicLoginWithAlternateLink)base.configData; } set { base.configData = value; } } @@ -38,8 +40,12 @@ namespace Jackett.Indexers client: wc, logger: l, p: ps, - configData: new ConfigurationDataBasicLogin()) + configData: new ConfigurationDataBasicLoginWithAlternateLink()) { + this.configData.Instructions.Value = this.DisplayName + " has multiple URLs. The default (" + this.SiteLink + ") can be changed by entering a new value in the box below."; + this.configData.Instructions.Value += "The following are some known URLs for " + this.DisplayName; + this.configData.Instructions.Value += "
  • " + String.Join("
  • ", this.KnownURLs.ToArray()) + "
"; + AddCategoryMapping(72, TorznabCatType.Movies); AddCategoryMapping(77, TorznabCatType.MoviesSD); AddCategoryMapping(89, TorznabCatType.MoviesSD); @@ -92,9 +98,9 @@ namespace Jackett.Indexers }; var request = new Utils.Clients.WebRequest() { - Url = SiteLink, + Url = UseLink, Type = RequestType.POST, - Referer = SiteLink, + Referer = UseLink, PostData = pairs }; var response = await webclient.GetString(request); @@ -156,7 +162,7 @@ namespace Jackett.Indexers } release.Description = release.Title; - release.Guid = new Uri(SiteLink + qTitleLink.Attr("href").Substring(1)); + release.Guid = new Uri(UseLink + qTitleLink.Attr("href").Substring(1)); release.Comments = release.Guid; var descString = qRow.Find(".t_ctime").Text(); @@ -165,7 +171,7 @@ namespace Jackett.Indexers release.PublishDate = DateTimeUtil.FromTimeAgo(dateString); var qLink = row.ChildElements.ElementAt(3).Cq().Children("a"); - release.Link = new Uri(SiteLink + HttpUtility.UrlEncode(qLink.Attr("href").TrimStart('/'))); + release.Link = new Uri(UseLink + HttpUtility.UrlEncode(qLink.Attr("href").TrimStart('/'))); var sizeStr = row.ChildElements.ElementAt(5).Cq().Text(); release.Size = ReleaseInfo.GetBytes(sizeStr); diff --git a/src/Jackett/Jackett.csproj b/src/Jackett/Jackett.csproj index c0f290a08..c9de86017 100644 --- a/src/Jackett/Jackett.csproj +++ b/src/Jackett/Jackett.csproj @@ -231,6 +231,7 @@ + diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithAlternateLink.cs b/src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithAlternateLink.cs new file mode 100644 index 000000000..9cc9a8b64 --- /dev/null +++ b/src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithAlternateLink.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Jackett.Models.IndexerConfig +{ + public class ConfigurationDataBasicLoginWithAlternateLink : ConfigurationData + { + public StringItem Username { get; private set; } + public StringItem Password { get; private set; } + public DisplayItem Instructions { get; private set; } + public StringItem AlternateLink { get; set; } + + public ConfigurationDataBasicLoginWithAlternateLink(string instructionMessageOptional = null) + { + Username = new StringItem { Name = "Username" }; + Password = new StringItem { Name = "Password" }; + Instructions = new DisplayItem(instructionMessageOptional) { Name = "" }; + AlternateLink = new StringItem { Name = "Alternate Link" }; + } + + + } +} \ No newline at end of file