From a311d138057ff99ae2f401d6975d60e402688c39 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 25 Jun 2022 18:06:40 -0500 Subject: [PATCH] Remove ShowRSS C# Implementation --- .../Migration/018_minimum_seeders.cs | 2 +- .../Datastore/Migration/019_remove_showrss.cs | 15 ++ .../Indexers/Definitions/ShowRSS.cs | 183 ------------------ 3 files changed, 16 insertions(+), 184 deletions(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/019_remove_showrss.cs delete mode 100644 src/NzbDrone.Core/Indexers/Definitions/ShowRSS.cs diff --git a/src/NzbDrone.Core/Datastore/Migration/018_minimum_seeders.cs b/src/NzbDrone.Core/Datastore/Migration/018_minimum_seeders.cs index 9569db660..9fda4423d 100644 --- a/src/NzbDrone.Core/Datastore/Migration/018_minimum_seeders.cs +++ b/src/NzbDrone.Core/Datastore/Migration/018_minimum_seeders.cs @@ -3,7 +3,7 @@ using NzbDrone.Core.Datastore.Migration.Framework; namespace NzbDrone.Core.Datastore.Migration { - [Migration(18)] + [Migration(018)] public class minimum_seeders : NzbDroneMigrationBase { protected override void MainDbUpgrade() diff --git a/src/NzbDrone.Core/Datastore/Migration/019_remove_showrss.cs b/src/NzbDrone.Core/Datastore/Migration/019_remove_showrss.cs new file mode 100644 index 000000000..f58eb6ccc --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/019_remove_showrss.cs @@ -0,0 +1,15 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(019)] + public class remove_showrss : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + // Remove, YML version exists + Delete.FromTable("Indexers").Row(new { Implementation = "ShowRSS" }); + } + } +} diff --git a/src/NzbDrone.Core/Indexers/Definitions/ShowRSS.cs b/src/NzbDrone.Core/Indexers/Definitions/ShowRSS.cs deleted file mode 100644 index 5c4508665..000000000 --- a/src/NzbDrone.Core/Indexers/Definitions/ShowRSS.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using FluentValidation; -using NLog; -using NzbDrone.Common.Http; -using NzbDrone.Core.Annotations; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.Indexers.Settings; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Validation; - -namespace NzbDrone.Core.Indexers.Definitions -{ - public class ShowRSS : TorrentIndexerBase - { - public override string Name => "ShowRSS"; - public override string[] IndexerUrls => new string[] { "https://showrss.info/" }; - public override string Language => "en-US"; - public override string Description => "showRSS is a service that allows you to keep track of your favorite TV shows"; - public override Encoding Encoding => Encoding.UTF8; - public override DownloadProtocol Protocol => DownloadProtocol.Torrent; - public override IndexerPrivacy Privacy => IndexerPrivacy.Public; - public override IndexerCapabilities Capabilities => SetCapabilities(); - - public ShowRSS(IIndexerHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, eventAggregator, indexerStatusService, configService, logger) - { - } - - public override IIndexerRequestGenerator GetRequestGenerator() - { - return new ShowRSSRequestGenerator() { Settings = Settings, Capabilities = Capabilities }; - } - - public override IParseIndexerResponse GetParser() - { - return new ShowRSSParser(Settings); - } - - private IndexerCapabilities SetCapabilities() - { - var caps = new IndexerCapabilities - { - TvSearchParams = new List - { - TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep - } - }; - - caps.Categories.AddCategoryMapping(1, NewznabStandardCategory.TV); - caps.Categories.AddCategoryMapping(2, NewznabStandardCategory.TVSD); - caps.Categories.AddCategoryMapping(3, NewznabStandardCategory.TVHD); - - return caps; - } - } - - public class ShowRSSRequestGenerator : IIndexerRequestGenerator - { - public NoAuthTorrentBaseSettings Settings { get; set; } - public IndexerCapabilities Capabilities { get; set; } - - public ShowRSSRequestGenerator() - { - } - - private IEnumerable GetPagedRequests(string term, int[] categories) - { - var searchUrl = string.Format("{0}/other/all.rss", Settings.BaseUrl.TrimEnd('/')); - - var request = new IndexerRequest(searchUrl, HttpAccept.Html); - - yield return request; - } - - public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - return pageableRequests; - } - - public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - return pageableRequests; - } - - public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedTvSearchString), searchCriteria.Categories)); - - return pageableRequests; - } - - public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - return pageableRequests; - } - - public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria) - { - var pageableRequests = new IndexerPageableRequestChain(); - - pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedSearchTerm), searchCriteria.Categories)); - - return pageableRequests; - } - - public Func> GetCookies { get; set; } - public Action, DateTime?> CookiesUpdater { get; set; } - } - - public class ShowRSSParser : IParseIndexerResponse - { - private readonly NoAuthTorrentBaseSettings _settings; - private string BrowseUrl => _settings.BaseUrl + "browse/"; - - public ShowRSSParser(NoAuthTorrentBaseSettings settings) - { - _settings = settings; - } - - public IList ParseResponse(IndexerResponse indexerResponse) - { - var torrentInfos = new List(); - - var xmlDoc = new XmlDocument(); - xmlDoc.LoadXml(indexerResponse.Content); - foreach (XmlNode node in xmlDoc.GetElementsByTagName("item")) - { - var title = node.SelectSingleNode(".//*[local-name()='raw_title']").InnerText; - - // TODO: Make sure we don't return all sorts of trash - //if (!query.MatchQueryStringAND(title)) - //{ - // continue; - //} - var category = title.Contains("720p") || title.Contains("1080p") ? - NewznabStandardCategory.TVHD : - NewznabStandardCategory.TVSD; - - var magnetUri = node.SelectSingleNode("link")?.InnerText; - var publishDate = DateTime.Parse(node.SelectSingleNode("pubDate").InnerText, CultureInfo.InvariantCulture); - var infoHash = node.SelectSingleNode(".//*[local-name()='info_hash']").InnerText; - var details = BrowseUrl + node.SelectSingleNode(".//*[local-name()='show_id']").InnerText; - - var release = new TorrentInfo - { - Title = title, - InfoUrl = details, - Categories = new List { category }, - Guid = magnetUri, - PublishDate = publishDate, - InfoHash = infoHash, - MagnetUrl = magnetUri, - Size = 512, - Seeders = 1, - Peers = 2, - DownloadVolumeFactor = 0, - UploadVolumeFactor = 1 - }; - - torrentInfos.Add(release); - } - - return torrentInfos.ToArray(); - } - - public Action, DateTime?> CookiesUpdater { get; set; } - } -}