From 523e46af2a35b127d7253d44b7b613fcdebb3d1f Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 31 Dec 2024 01:55:55 +0200 Subject: [PATCH] Fixed: (AnimeBytes) Include year in release title for series with year in filenames --- .../AnimeBytesTests/AnimeBytesFixture.cs | 2 +- .../Indexers/Definitions/AnimeBytes.cs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/NzbDrone.Core.Test/IndexerTests/AnimeBytesTests/AnimeBytesFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/AnimeBytesTests/AnimeBytesFixture.cs index a2453592f..ae7eaa762 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/AnimeBytesTests/AnimeBytesFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/AnimeBytesTests/AnimeBytesFixture.cs @@ -122,7 +122,7 @@ namespace NzbDrone.Core.Test.IndexerTests.AnimeBytesTests var fifthTorrentInfo = releases.ElementAt(28) as TorrentInfo; - fifthTorrentInfo.Title.Should().Be("[-ZR-] Dr. STONE: STONE WARS S02 [Web][MKV][h264][1080p][AAC 2.0][Dual Audio][Softsubs (-ZR-)]"); + fifthTorrentInfo.Title.Should().Be("[-ZR-] Dr. STONE: STONE WARS 2021 S02 [Web][MKV][h264][1080p][AAC 2.0][Dual Audio][Softsubs (-ZR-)]"); fifthTorrentInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); fifthTorrentInfo.DownloadUrl.Should().Be("https://animebytes.tv/torrent/944509/download/somepass"); fifthTorrentInfo.InfoUrl.Should().Be("https://animebytes.tv/torrent/944509/group"); diff --git a/src/NzbDrone.Core/Indexers/Definitions/AnimeBytes.cs b/src/NzbDrone.Core/Indexers/Definitions/AnimeBytes.cs index 37729fd00..9d5870e4e 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/AnimeBytes.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/AnimeBytes.cs @@ -569,7 +569,7 @@ namespace NzbDrone.Core.Indexers.Definitions if (_settings.UseFilenameForSingleEpisodes) { - var files = torrent.Files; + var files = torrent.Files.ToList(); if (files.Count > 1) { @@ -607,11 +607,13 @@ namespace NzbDrone.Core.Indexers.Definitions } } + var useYearInTitle = year is > 0 && torrent.Files.Any(f => f.FileName.Contains(year.Value.ToString())); + foreach (var title in synonyms) { var releaseTitle = groupName is "Movie" or "Live Action Movie" ? $"{releaseGroup}{title} {year} {infoString}" : - $"{releaseGroup}{title} {releaseInfo} {infoString}"; + $"{releaseGroup}{title}{(useYearInTitle ? $" {year}" : string.Empty)} {releaseInfo} {infoString}"; var guid = new Uri(details + "?nh=" + HashUtil.CalculateMd5(title)); @@ -650,7 +652,7 @@ namespace NzbDrone.Core.Indexers.Definitions { var advancedSeasonRegex = new Regex(@"\b(?:(?\d+)(?:st|nd|rd|th) Season|Season (?\d+))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); var seasonCharactersRegex = new Regex(@"(I{2,})$", RegexOptions.Compiled); - var seasonNumberRegex = new Regex(@"\b(?[2-9])$", RegexOptions.Compiled); + var seasonNumberRegex = new Regex(@"(?[2-9])$", RegexOptions.Compiled); foreach (var title in titles) { @@ -755,7 +757,7 @@ namespace NzbDrone.Core.Indexers.Definitions public int Matches { get; set; } [JsonPropertyName("Groups")] - public AnimeBytesGroup[] Groups { get; set; } + public IReadOnlyCollection Groups { get; set; } } public class AnimeBytesGroup @@ -783,16 +785,16 @@ namespace NzbDrone.Core.Indexers.Definitions public string Image { get; set; } [JsonPropertyName("SynonymnsV2")] - public Dictionary Synonymns { get; set; } + public IReadOnlyDictionary Synonymns { get; set; } [JsonPropertyName("Description")] public string Description { get; set; } [JsonPropertyName("Tags")] - public List Tags { get; set; } + public IReadOnlyCollection Tags { get; set; } [JsonPropertyName("Torrents")] - public List Torrents { get; set; } + public IReadOnlyCollection Torrents { get; set; } } public class AnimeBytesTorrent @@ -831,7 +833,7 @@ namespace NzbDrone.Core.Indexers.Definitions public int FileCount { get; set; } [JsonPropertyName("FileList")] - public List Files { get; set; } + public IReadOnlyCollection Files { get; set; } [JsonPropertyName("UploadTime")] public string UploadTime { get; set; }