diff --git a/src/Jackett.Common/Indexers/MyAnonamouse.cs b/src/Jackett.Common/Indexers/MyAnonamouse.cs index e48116442..abb46e751 100644 --- a/src/Jackett.Common/Indexers/MyAnonamouse.cs +++ b/src/Jackett.Common/Indexers/MyAnonamouse.cs @@ -8,7 +8,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Jackett.Common.Models; -using Jackett.Common.Models.IndexerConfig; +using Jackett.Common.Models.IndexerConfig.Bespoke; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; using Jackett.Common.Utils.Clients; @@ -20,14 +20,9 @@ namespace Jackett.Common.Indexers [ExcludeFromCodeCoverage] public class MyAnonamouse : BaseWebIndexer { - private string LoginUrl => SiteLink + "takelogin.php"; private string SearchUrl => SiteLink + "tor/js/loadSearchJSONbasic.php"; - private new ConfigurationDataMyAnonamouse configData - { - get => (ConfigurationDataMyAnonamouse)base.configData; - set => base.configData = value; - } + private new ConfigurationDataMyAnonamouse configData => (ConfigurationDataMyAnonamouse)base.configData; public MyAnonamouse(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps) : base(id: "myanonamouse", @@ -146,15 +141,12 @@ namespace Jackett.Common.Indexers { LoadValuesFromJson(configJson); - // TODO: implement captcha CookieHeader = "mam_id=" + configData.MamId.Value; try { var results = await PerformQuery(new TorznabQuery()); - if (results.Count() == 0) - { + if (!results.Any()) throw new Exception("Your man_id did not work"); - } IsConfigured = true; SaveConfig(); @@ -176,7 +168,7 @@ namespace Jackett.Common.Indexers {"tor[text]", query.GetQueryString()}, {"tor[srchIn][title]", "true"}, {"tor[srchIn][author]", "true"}, - {"tor[searchType]", "all"}, + {"tor[searchType]", configData.ExcludeVip?.Value == true ? "nVIP" : "all"}, // exclude VIP torrents {"tor[searchIn]", "torrents"}, {"tor[hash]", ""}, {"tor[sortType]", "default"}, @@ -184,10 +176,12 @@ namespace Jackett.Common.Indexers {"thumbnails", "1"}, // gives links for thumbnail sized versions of their posters //{ "posterLink", "1"}, // gives links for a full sized poster //{ "dlLink", "1"}, // include the url to download the torrent - {"description", "1"}, // include the description + {"description", "1"} // include the description //{"bookmarks", "0"} // include if the item is bookmarked or not }; + // Exclude VIP torrents + var catList = MapTorznabCapsToTrackers(query); if (catList.Any()) { @@ -199,21 +193,15 @@ namespace Jackett.Common.Indexers } } else - { qParams.Add("tor[cat][]", "0"); - } var urlSearch = SearchUrl; if (qParams.Count > 0) - { urlSearch += $"?{qParams.GetQueryString()}"; - } var response = await RequestStringWithCookiesAndRetry(urlSearch); if (response.Content.StartsWith("Error")) - { throw new Exception(response.Content); - } try { @@ -221,11 +209,8 @@ namespace Jackett.Common.Indexers var sitelink = new Uri(SiteLink); var error = jsonContent.Value("error"); - if (error != null) - { - if (error == "Nothing returned, out of 0") - return releases; - } + if (error != null && error == "Nothing returned, out of 0") + return releases; foreach (var item in jsonContent.Value("data")) { @@ -237,22 +222,22 @@ namespace Jackett.Common.Indexers release.Description = item.Value("description"); - var author_info = item.Value("author_info"); + var authorInfo = item.Value("author_info"); string author = null; - if (!string.IsNullOrWhiteSpace(author_info)) + if (!string.IsNullOrWhiteSpace(authorInfo)) { - author_info = Regex.Unescape(author_info); - var author_info_json = JObject.Parse(author_info); - author = author_info_json.First.Last.Value(); + authorInfo = Regex.Unescape(authorInfo); + var authorInfoJson = JObject.Parse(authorInfo); + author = authorInfoJson.First.Last.Value(); } if (author != null) release.Title += " by " + author; var flags = new List(); - var lang_code = item.Value("lang_code"); - if (!string.IsNullOrEmpty(lang_code)) - flags.Add(lang_code); + var langCode = item.Value("lang_code"); + if (!string.IsNullOrEmpty(langCode)) + flags.Add(langCode); var filetype = item.Value("filetype"); if (!string.IsNullOrEmpty(filetype)) @@ -261,6 +246,9 @@ namespace Jackett.Common.Indexers if (flags.Count > 0) release.Title += " [" + string.Join(" / ", flags) + "]"; + if (item.Value("vip") == 1) + release.Title += " [VIP]"; + var category = item.Value("category"); release.Category = MapTrackerCatToNewznab(category); @@ -278,12 +266,8 @@ namespace Jackett.Common.Indexers release.Peers = item.Value("leechers") + release.Seeders; var size = item.Value("size"); release.Size = ReleaseInfo.GetBytes(size); - var free = item.Value("free"); - if (free == 1) - release.DownloadVolumeFactor = 0; - else - release.DownloadVolumeFactor = 1; + release.DownloadVolumeFactor = item.Value("free") == 1 ? 0 : 1; release.UploadVolumeFactor = 1; releases.Add(release); diff --git a/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataMyAnonamouse.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataMyAnonamouse.cs index 81a6d4a79..bade96feb 100644 --- a/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataMyAnonamouse.cs +++ b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataMyAnonamouse.cs @@ -1,10 +1,12 @@ -namespace Jackett.Common.Models.IndexerConfig +namespace Jackett.Common.Models.IndexerConfig.Bespoke { public class ConfigurationDataMyAnonamouse : ConfigurationData { public StringItem MamId { get; private set; } public DisplayItem MamIdHint { get; private set; } + public BoolItem ExcludeVip { get; private set; } + public DisplayItem Instructions { get; private set; } public ConfigurationDataMyAnonamouse() { @@ -14,6 +16,8 @@ namespace Jackett.Common.Models.IndexerConfig { Name = "mam_id instructions" }; + ExcludeVip = new BoolItem { Name = "Exclude VIP torrents" }; + Instructions = new DisplayItem("For best results, change the 'Torrents per page' setting to 100 in your Profile => Torrent tab.") { Name = "" }; } }