diff --git a/src/NzbDrone.Core.Test/IndexerTests/OrpheusTests/OrpheusFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/OrpheusTests/OrpheusFixture.cs index 980f93c22..a8380abea 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/OrpheusTests/OrpheusFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/OrpheusTests/OrpheusFixture.cs @@ -44,7 +44,7 @@ public async Task should_parse_recent_feed_from_Orpheus() var torrentInfo = releases.First() as GazelleInfo; - torrentInfo.Title.Should().Be("The Beatles - Abbey Road (1969) [2.0 Mix 2019] [MP3 V2 (VBR)] [BD]"); + torrentInfo.Title.Should().Be("The Beatles - Abbey Road [1969] [Album] [2.0 Mix 2019] [MP3 V2 (VBR)] [BD]"); torrentInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); torrentInfo.DownloadUrl.Should().Be("https://orpheus.network/ajax.php?action=download&id=1902448"); torrentInfo.InfoUrl.Should().Be("https://orpheus.network/torrents.php?id=466&torrentid=1902448"); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs index dfc53a4d5..69ee5a646 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs @@ -31,14 +31,18 @@ public class Orpheus : TorrentIndexerBase public override IndexerCapabilities Capabilities => SetCapabilities(); public override bool SupportsRedirect => true; - public Orpheus(IIndexerHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, eventAggregator, indexerStatusService, configService, logger) + public Orpheus(IIndexerHttpClient httpClient, + IEventAggregator eventAggregator, + IIndexerStatusService indexerStatusService, + IConfigService configService, + Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } public override IIndexerRequestGenerator GetRequestGenerator() { - return new OrpheusRequestGenerator { Settings = Settings, Capabilities = Capabilities, HttpClient = _httpClient }; + return new OrpheusRequestGenerator(Settings, Capabilities); } public override IParseIndexerResponse GetParser() @@ -52,7 +56,7 @@ private IndexerCapabilities SetCapabilities() { MusicSearchParams = new List { - MusicSearchParam.Q, MusicSearchParam.Album, MusicSearchParam.Artist, MusicSearchParam.Label, MusicSearchParam.Year + MusicSearchParam.Q, MusicSearchParam.Artist, MusicSearchParam.Album, MusicSearchParam.Year }, BookSearchParams = new List { @@ -62,11 +66,11 @@ private IndexerCapabilities SetCapabilities() caps.Categories.AddCategoryMapping(1, NewznabStandardCategory.Audio, "Music"); caps.Categories.AddCategoryMapping(2, NewznabStandardCategory.PC, "Applications"); - caps.Categories.AddCategoryMapping(3, NewznabStandardCategory.Books, "E-Books"); + caps.Categories.AddCategoryMapping(3, NewznabStandardCategory.BooksEBook, "E-Books"); caps.Categories.AddCategoryMapping(4, NewznabStandardCategory.AudioAudiobook, "Audiobooks"); caps.Categories.AddCategoryMapping(5, NewznabStandardCategory.Other, "E-Learning Videos"); caps.Categories.AddCategoryMapping(6, NewznabStandardCategory.Other, "Comedy"); - caps.Categories.AddCategoryMapping(7, NewznabStandardCategory.Books, "Comics"); + caps.Categories.AddCategoryMapping(7, NewznabStandardCategory.BooksComics, "Comics"); return caps; } @@ -114,11 +118,17 @@ public override async Task Download(Uri link) public class OrpheusRequestGenerator : IIndexerRequestGenerator { - public OrpheusSettings Settings { get; set; } - public IndexerCapabilities Capabilities { get; set; } + private readonly OrpheusSettings _settings; + private readonly IndexerCapabilities _capabilities; + public Func> GetCookies { get; set; } public Action, DateTime?> CookiesUpdater { get; set; } - public IIndexerHttpClient HttpClient { get; set; } + + public OrpheusRequestGenerator(OrpheusSettings settings, IndexerCapabilities capabilities) + { + _settings = settings; + _capabilities = capabilities; + } public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria) { @@ -135,11 +145,6 @@ public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchC parameters.Add("groupname", searchCriteria.Album); } - if (searchCriteria.Label.IsNotNullOrWhiteSpace()) - { - parameters.Add("recordlabel", searchCriteria.Label); - } - if (searchCriteria.Year.HasValue) { parameters.Add("year", searchCriteria.Year.ToString()); @@ -189,7 +194,7 @@ private IEnumerable GetRequest(SearchCriteriaBase searchCriteria parameters.Add("order_way", "desc"); parameters.Add("searchstr", term); - var queryCats = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories); + var queryCats = _capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories); if (queryCats.Count > 0) { @@ -199,18 +204,18 @@ private IEnumerable GetRequest(SearchCriteriaBase searchCriteria } } - var req = RequestBuilder() - .Resource($"ajax.php?{parameters.GetQueryString()}") + var request = RequestBuilder() + .Resource($"/ajax.php?{parameters.GetQueryString()}") .Build(); - yield return new IndexerRequest(req); + yield return new IndexerRequest(request); } private HttpRequestBuilder RequestBuilder() { - return new HttpRequestBuilder($"{Settings.BaseUrl.Trim().TrimEnd('/')}") + return new HttpRequestBuilder($"{_settings.BaseUrl.TrimEnd('/')}") .Accept(HttpAccept.Json) - .SetHeader("Authorization", $"token {Settings.Apikey}"); + .SetHeader("Authorization", $"token {_settings.Apikey}"); } } @@ -339,11 +344,16 @@ public IList ParseResponse(IndexerResponse indexerResponse) private string GetTitle(GazelleRelease result, GazelleTorrent torrent) { - var title = $"{result.Artist} - {result.GroupName} ({result.GroupYear})"; + var title = $"{result.Artist} - {result.GroupName} [{result.GroupYear}]"; + + if (result.ReleaseType.IsNotNullOrWhiteSpace() && result.ReleaseType != "Unknown") + { + title += " [" + result.ReleaseType + "]"; + } if (torrent.RemasterTitle.IsNotNullOrWhiteSpace()) { - title += $" [{string.Format("{0} {1}", torrent.RemasterTitle, torrent.RemasterYear).Trim()}]"; + title += $" [{$"{torrent.RemasterTitle} {torrent.RemasterYear}".Trim()}]"; } title += $" [{torrent.Format} {torrent.Encoding}] [{torrent.Media}]";