Skip to content

Commit 24b8029

Browse files
Talothmynameisbogdan
authored andcommittedFeb 1, 2024
Fixed: Release Year in renaming format for certain OS language cultures
Based-On: Radarr/Radarr@a0d2af5 (cherry picked from commit 87897d56ea62544a36986eb09d420649668d7400)
1 parent c3eda6f commit 24b8029

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
 

‎src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs

+26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.IO;
45
using System.Linq;
6+
using System.Threading;
57
using FizzWare.NBuilder;
68
using FluentAssertions;
79
using NUnit.Framework;
@@ -793,6 +795,30 @@ public void should_use_existing_casing_for_release_group(string releaseGroup)
793795
.Should().Be(releaseGroup);
794796
}
795797

798+
[TestCase("en-US")]
799+
[TestCase("fr-FR")]
800+
[TestCase("az")]
801+
[TestCase("tr-TR")]
802+
public void should_replace_all_tokens_for_different_cultures(string culture)
803+
{
804+
var oldCulture = Thread.CurrentThread.CurrentCulture;
805+
try
806+
{
807+
Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
808+
809+
_album.ReleaseDate = new DateTime(2021, 1, 15);
810+
811+
_namingConfig.StandardTrackFormat = "{Release Year}";
812+
813+
Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
814+
.Should().Be("2021");
815+
}
816+
finally
817+
{
818+
Thread.CurrentThread.CurrentCulture = oldCulture;
819+
}
820+
}
821+
796822
[Test]
797823
public void should_replace_artist_name_for_Various_Artists_album()
798824
{

‎src/NzbDrone.Core/Organizer/FileNameBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class FileNameBuilder : IBuildFileNames
3535
private readonly Logger _logger;
3636

3737
private static readonly Regex TitleRegex = new Regex(@"(?<escaped>\{\{|\}\})|\{(?<prefix>[- ._\[(]*)(?<token>(?:[a-z0-9]+)(?:(?<separator>[- ._]+)(?:[a-z0-9]+))?)(?::(?<customFormat>[a-z0-9]+))?(?<suffix>[- ._)\]]*)\}",
38-
RegexOptions.Compiled | RegexOptions.IgnoreCase);
38+
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
3939

4040
public static readonly Regex TrackRegex = new Regex(@"(?<track>\{track(?:\:0+)?})",
4141
RegexOptions.Compiled | RegexOptions.IgnoreCase);

0 commit comments

Comments
 (0)
Please sign in to comment.