From 87897d56ea62544a36986eb09d420649668d7400 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Fri, 7 May 2021 22:09:23 +0200 Subject: [PATCH] Fixed: MediaInfo tag in renaming format for certain OS language cultures Based-On: https://github.com/Radarr/Radarr/commit/a0d2af54e854a77e7e61d1c79a433c488cf9ac41 --- .../FileNameBuilderFixture.cs | 28 +++++++++++++++++++ .../Organizer/FileNameBuilder.cs | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs index b497a9b10..57ca4e1bc 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; +using System.Threading; using FizzWare.NBuilder; using FluentAssertions; using Moq; @@ -812,6 +814,32 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests .Should().Be(releaseGroup); } + [TestCase("en-US")] + [TestCase("fr-FR")] + [TestCase("az")] + [TestCase("tr-TR")] + public void should_replace_all_tokens_for_different_cultures(string culture) + { + var oldCulture = Thread.CurrentThread.CurrentCulture; + try + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); + + _episodeFile.ReleaseGroup = null; + + GivenMediaInfoModel(audioLanguages: "English/German"); + + _namingConfig.StandardEpisodeFormat = "{MediaInfo AudioLanguages}"; + + Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) + .Should().Be("[EN+DE]"); + } + finally + { + Thread.CurrentThread.CurrentCulture = oldCulture; + } + } + [TestCase("English", "")] [TestCase("English/German", "[EN+DE]")] public void should_format_audio_languages(string audioLanguages, string expected) diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 898462068..2ed329f71 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -45,7 +45,7 @@ namespace NzbDrone.Core.Organizer private readonly Logger _logger; private static readonly Regex TitleRegex = new Regex(@"(?\{\{|\}\})|\{(?[- ._\[(]*)(?(?:[a-z0-9]+)(?:(?[- ._]+)(?:[a-z0-9]+))?)(?::(?[a-z0-9+-]+(?[- ._)\]]*)\}", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); private static readonly Regex EpisodeRegex = new Regex(@"(?\{episode(?:\:0+)?})", RegexOptions.Compiled | RegexOptions.IgnoreCase);