diff --git a/src/NzbDrone.Core.Test/IndexerTests/OrpheusTests/OrpheusFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/OrpheusTests/OrpheusFixture.cs index 03f012795..980f93c22 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/OrpheusTests/OrpheusFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/OrpheusTests/OrpheusFixture.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Test.IndexerTests.OrpheusTests Subject.Definition = new IndexerDefinition() { Name = "Orpheus", - Settings = new OrpheusSettings() { Apikey = "somekey" } + Settings = new OrpheusSettings { Apikey = "somekey" } }; } @@ -37,14 +37,14 @@ namespace NzbDrone.Core.Test.IndexerTests.OrpheusTests .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader { { "Content-Type", "application/json" } }, new CookieCollection(), recentFeed))); - var releases = (await Subject.Fetch(new BasicSearchCriteria { Categories = new int[] { 2000 } })).Releases; + var releases = (await Subject.Fetch(new BasicSearchCriteria { Categories = new[] { 2000 } })).Releases; releases.Should().HaveCount(65); releases.First().Should().BeOfType(); var torrentInfo = releases.First() as GazelleInfo; - torrentInfo.Title.Should().Be("The Beatles - Abbey Road (1969) [MP3 V2 (VBR)] [BD]"); + torrentInfo.Title.Should().Be("The Beatles - Abbey Road (1969) [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 ec001c5eb..5f107c310 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Net; -using System.Text; using System.Threading.Tasks; using FluentValidation; using NLog; @@ -25,7 +24,7 @@ namespace NzbDrone.Core.Indexers.Definitions public class Orpheus : TorrentIndexerBase { public override string Name => "Orpheus"; - public override string[] IndexerUrls => new string[] { "https://orpheus.network/" }; + public override string[] IndexerUrls => new[] { "https://orpheus.network/" }; public override string Description => "Orpheus (APOLLO) is a Private Torrent Tracker for MUSIC"; public override DownloadProtocol Protocol => DownloadProtocol.Torrent; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; @@ -39,7 +38,7 @@ namespace NzbDrone.Core.Indexers.Definitions public override IIndexerRequestGenerator GetRequestGenerator() { - return new OrpheusRequestGenerator() { Settings = Settings, Capabilities = Capabilities, HttpClient = _httpClient }; + return new OrpheusRequestGenerator { Settings = Settings, Capabilities = Capabilities, HttpClient = _httpClient }; } public override IParseIndexerResponse GetParser() @@ -52,13 +51,13 @@ namespace NzbDrone.Core.Indexers.Definitions var caps = new IndexerCapabilities { MusicSearchParams = new List - { - MusicSearchParam.Q, MusicSearchParam.Album, MusicSearchParam.Artist, MusicSearchParam.Label, MusicSearchParam.Year - }, + { + MusicSearchParam.Q, MusicSearchParam.Album, MusicSearchParam.Artist, MusicSearchParam.Label, MusicSearchParam.Year + }, BookSearchParams = new List - { - BookSearchParam.Q - } + { + BookSearchParam.Q + } }; caps.Categories.AddCategoryMapping(1, NewznabStandardCategory.Audio, "Music"); @@ -121,10 +120,6 @@ namespace NzbDrone.Core.Indexers.Definitions public Action, DateTime?> CookiesUpdater { get; set; } public IIndexerHttpClient HttpClient { get; set; } - public OrpheusRequestGenerator() - { - } - public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); @@ -260,24 +255,14 @@ namespace NzbDrone.Core.Indexers.Definitions foreach (var torrent in result.Torrents) { var id = torrent.TorrentId; - var artist = WebUtility.HtmlDecode(result.Artist); - var album = WebUtility.HtmlDecode(result.GroupName); - - var title = $"{result.Artist} - {result.GroupName} ({result.GroupYear}) [{torrent.Format} {torrent.Encoding}] [{torrent.Media}]"; - if (torrent.HasCue) - { - title += " [Cue]"; - } + var title = GetTitle(result, torrent); var infoUrl = GetInfoUrl(result.GroupId, id); - GazelleInfo release = new GazelleInfo() + var release = new GazelleInfo { Guid = infoUrl, - - // Splice Title from info to avoid calling API again for every torrent. Title = WebUtility.HtmlDecode(title), - Container = torrent.Encoding, Codec = torrent.Format, Size = long.Parse(torrent.Size), @@ -314,7 +299,7 @@ namespace NzbDrone.Core.Indexers.Definitions var id = result.TorrentId; var infoUrl = GetInfoUrl(result.GroupId, id); - GazelleInfo release = new GazelleInfo() + var release = new GazelleInfo { Guid = infoUrl, Title = WebUtility.HtmlDecode(result.GroupName), @@ -352,6 +337,25 @@ namespace NzbDrone.Core.Indexers.Definitions .ToArray(); } + private string GetTitle(GazelleRelease result, GazelleTorrent torrent) + { + var title = $"{result.Artist} - {result.GroupName} ({result.GroupYear})"; + + if (torrent.RemasterTitle.IsNotNullOrWhiteSpace()) + { + title += $" [{string.Format("{0} {1}", torrent.RemasterTitle, torrent.RemasterYear).Trim()}]"; + } + + title += $" [{torrent.Format} {torrent.Encoding}] [{torrent.Media}]"; + + if (torrent.HasCue) + { + title += " [Cue]"; + } + + return title; + } + private string GetDownloadUrl(int torrentId, bool canUseToken) { // AuthKey is required but not checked, just pass in a dummy variable @@ -391,7 +395,7 @@ namespace NzbDrone.Core.Indexers.Definitions public class OrpheusSettings : NoAuthTorrentBaseSettings { - private static readonly OrpheusSettingsValidator Validator = new OrpheusSettingsValidator(); + private static readonly OrpheusSettingsValidator Validator = new (); public OrpheusSettings() {