From a905044897f2357fc4a6019c07ad53acf44824e2 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 21 Feb 2021 21:36:15 -0500 Subject: [PATCH] Remove AHD --- .../Definitions/AwesomeHD/AwesomeHD.cs | 61 ------- .../AwesomeHD/AwesomeHDRequestGenerator.cs | 74 -------- .../AwesomeHD/AwesomeHDRssParser.cs | 170 ------------------ .../AwesomeHD/AwesomeHDSettings.cs | 32 ---- 4 files changed, 337 deletions(-) delete mode 100644 src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHD.cs delete mode 100644 src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDRequestGenerator.cs delete mode 100644 src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDRssParser.cs delete mode 100644 src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDSettings.cs diff --git a/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHD.cs b/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHD.cs deleted file mode 100644 index 4273c74d8..000000000 --- a/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHD.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Collections.Generic; -using NLog; -using NzbDrone.Common.Http; -using NzbDrone.Core.Configuration; - -namespace NzbDrone.Core.Indexers.AwesomeHD -{ - public class AwesomeHD : HttpIndexerBase - { - public override string Name => "AwesomeHD"; - public override string BaseUrl => "https://awesome-hd.club"; - public override DownloadProtocol Protocol => DownloadProtocol.Torrent; - public override IndexerPrivacy Privacy => IndexerPrivacy.Private; - public override bool SupportsRss => true; - public override bool SupportsSearch => true; - - public override IndexerCapabilities Capabilities => SetCapabilities(); - - public override int PageSize => 50; - - public AwesomeHD(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) - { - } - - public override IIndexerRequestGenerator GetRequestGenerator() - { - return new AwesomeHDRequestGenerator() { Settings = Settings, BaseUrl = BaseUrl }; - } - - public override IParseIndexerResponse GetParser() - { - return new AwesomeHDRssParser(Settings, BaseUrl); - } - - private IndexerCapabilities SetCapabilities() - { - var caps = new IndexerCapabilities - { - TvSearchParams = new List - { - TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId - }, - MovieSearchParams = new List - { - MovieSearchParam.Q, MovieSearchParam.ImdbId - }, - MusicSearchParams = new List - { - MusicSearchParam.Q - } - }; - - caps.Categories.AddCategoryMapping(1, NewznabStandardCategory.MoviesHD); - caps.Categories.AddCategoryMapping(2, NewznabStandardCategory.TVHD); - caps.Categories.AddCategoryMapping(3, NewznabStandardCategory.Audio); - - return caps; - } - } -} diff --git a/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDRequestGenerator.cs deleted file mode 100644 index f2202c57c..000000000 --- a/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDRequestGenerator.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Http; -using NzbDrone.Core.IndexerSearch.Definitions; - -namespace NzbDrone.Core.Indexers.AwesomeHD -{ - public class AwesomeHDRequestGenerator : IIndexerRequestGenerator - { - public string BaseUrl { get; set; } - public AwesomeHDSettings Settings { get; set; } - - public virtual IndexerPageableRequestChain GetRecentRequests() - { - var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetRequest(null)); - return pageableRequests; - } - - public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - var parameters = string.Empty; - - if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace()) - { - parameters = string.Format("&action=imdbsearch&imdb={0}", searchCriteria.ImdbId); - } - else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace()) - { - parameters = string.Format("&action=titlesearch&title={0}", searchCriteria.SearchTerm); - } - else - { - parameters = "&action=latestmovies"; - } - - pageableRequests.Add(GetRequest(parameters)); - return pageableRequests; - } - - public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } - - public Func> GetCookies { get; set; } - public Action, DateTime?> CookiesUpdater { get; set; } - - private IEnumerable GetRequest(string searchParameters) - { - if (searchParameters != null) - { - yield return new IndexerRequest($"{BaseUrl.Trim().TrimEnd('/')}/searchapi.php?passkey={Settings.Passkey.Trim()}{searchParameters}", HttpAccept.Rss); - } - } - } -} diff --git a/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDRssParser.cs b/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDRssParser.cs deleted file mode 100644 index 498cc5bd8..000000000 --- a/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDRssParser.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Xml; -using System.Xml.Linq; -using NzbDrone.Common.Http; -using NzbDrone.Core.Indexers.Exceptions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.Indexers.AwesomeHD -{ - public class AwesomeHDRssParser : IParseIndexerResponse - { - private readonly string _baseUrl; - private readonly AwesomeHDSettings _settings; - - public AwesomeHDRssParser(AwesomeHDSettings settings, string baseUrl) - { - _settings = settings; - _baseUrl = baseUrl; - } - - public IList ParseResponse(IndexerResponse indexerResponse) - { - var torrentInfos = new List(); - - if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) - { - throw new IndexerException(indexerResponse, - "Unexpected response status {0} code from API request", - indexerResponse.HttpResponse.StatusCode); - } - - try - { - var xdoc = XDocument.Parse(indexerResponse.Content); - var searchResults = xdoc.Descendants("searchresults").Select(x => new - { - AuthKey = x.Element("authkey").Value, - }).FirstOrDefault(); - - var torrents = xdoc.Descendants("torrent") - .Select(x => new - { - Id = x.Element("id").Value, - Name = x.Element("name").Value, - Year = x.Element("year").Value, - GroupId = x.Element("groupid").Value, - Time = DateTime.Parse(x.Element("time").Value), - UserId = x.Element("userid").Value, - Size = long.Parse(x.Element("size").Value), - Snatched = x.Element("snatched").Value, - Seeders = x.Element("seeders").Value, - Leechers = x.Element("leechers").Value, - ReleaseGroup = x.Element("releasegroup").Value, - Resolution = x.Element("resolution").Value, - Media = x.Element("media").Value, - Format = x.Element("format").Value, - Encoding = x.Element("encoding").Value, - AudioFormat = x.Element("audioformat").Value, - AudioBitrate = x.Element("audiobitrate").Value, - AudioChannels = x.Element("audiochannels").Value, - Subtitles = x.Element("subtitles").Value, - EncodeStatus = x.Element("encodestatus").Value, - Freeleech = x.Element("freeleech").Value, - Internal = x.Element("internal").Value == "1", - UserRelease = x.Element("userrelease").Value == "1", - ImdbId = x.Element("imdb").Value - }).ToList(); - - foreach (var torrent in torrents) - { - var id = torrent.Id; - - var title = $"{torrent.Name}.{torrent.Year}.{torrent.Resolution}.{torrent.Media}.{torrent.Encoding}.{torrent.AudioFormat}-{torrent.ReleaseGroup}"; - - if (torrent.Encoding.ToLower() == "x265") - { - //Per AHD staff they only allow HDR x265 encodes (https://github.com/Prowlarr/Prowlarr/issues/4386) - title = $"{torrent.Name}.{torrent.Year}.{torrent.Resolution}.{torrent.Media}.HDR.{torrent.Encoding}.{torrent.AudioFormat}-{torrent.ReleaseGroup}"; - } - - IndexerFlags flags = 0; - - if (torrent.Freeleech == "0.00") - { - flags |= IndexerFlags.G_Freeleech; - } - - if (torrent.Freeleech == "0.25") - { - flags |= IndexerFlags.G_Freeleech75; - } - - if (torrent.Freeleech == "0.75") - { - flags |= IndexerFlags.G_Freeleech25; - } - - if (torrent.Freeleech == "0.50") - { - flags |= IndexerFlags.G_Halfleech; - } - - if (torrent.Internal) - { - flags |= IndexerFlags.AHD_Internal; - } - - if (torrent.UserRelease) - { - flags |= IndexerFlags.AHD_UserRelease; - } - - var imdbId = 0; - if (torrent.ImdbId.Length > 2) - { - imdbId = int.Parse(torrent.ImdbId.Substring(2)); - } - - torrentInfos.Add(new TorrentInfo() - { - Guid = string.Format("AwesomeHD-{0}", id), - Title = title, - Size = torrent.Size, - DownloadUrl = GetDownloadUrl(id, searchResults.AuthKey, _settings.Passkey), - InfoUrl = GetInfoUrl(torrent.GroupId, id), - Seeders = int.Parse(torrent.Seeders), - Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), - PublishDate = torrent.Time.ToUniversalTime(), - ImdbId = imdbId, - IndexerFlags = flags, - }); - } - } - catch (XmlException) - { - throw new IndexerException(indexerResponse, - "An error occurred while processing feed, feed invalid"); - } - - return torrentInfos.OrderByDescending(o => ((dynamic)o).Seeders).ToArray(); - } - - public Action, DateTime?> CookiesUpdater { get; set; } - - private string GetDownloadUrl(string torrentId, string authKey, string passKey) - { - var url = new HttpUri(_baseUrl) - .CombinePath("/torrents.php") - .AddQueryParam("action", "download") - .AddQueryParam("id", torrentId) - .AddQueryParam("authkey", authKey) - .AddQueryParam("torrent_pass", passKey); - - return url.FullUri; - } - - private string GetInfoUrl(string groupId, string torrentId) - { - var url = new HttpUri(_baseUrl) - .CombinePath("/torrents.php") - .AddQueryParam("id", groupId) - .AddQueryParam("torrentid", torrentId); - - return url.FullUri; - } - } -} diff --git a/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDSettings.cs b/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDSettings.cs deleted file mode 100644 index ed78ee6b4..000000000 --- a/src/NzbDrone.Core/Indexers/Definitions/AwesomeHD/AwesomeHDSettings.cs +++ /dev/null @@ -1,32 +0,0 @@ -using FluentValidation; -using NzbDrone.Core.Annotations; -using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Validation; - -namespace NzbDrone.Core.Indexers.AwesomeHD -{ - public class AwesomeHDSettingsValidator : AbstractValidator - { - public AwesomeHDSettingsValidator() - { - RuleFor(c => c.Passkey).NotEmpty(); - } - } - - public class AwesomeHDSettings : IProviderConfig - { - private static readonly AwesomeHDSettingsValidator Validator = new AwesomeHDSettingsValidator(); - - public AwesomeHDSettings() - { - } - - [FieldDefinition(1, Label = "Passkey", Privacy = PrivacyLevel.ApiKey)] - public string Passkey { get; set; } - - public NzbDroneValidationResult Validate() - { - return new NzbDroneValidationResult(Validator.Validate(this)); - } - } -}