Skip to content

Commit

Permalink
Fixed: Release Year in renaming format for certain OS language cultures
Browse files Browse the repository at this point in the history
Based-On: Radarr/Radarr@a0d2af5
(cherry picked from commit 87897d56ea62544a36986eb09d420649668d7400)
  • Loading branch information
Taloth authored and mynameisbogdan committed Feb 1, 2024
1 parent c3eda6f commit 24b8029
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
Expand Down Expand Up @@ -793,6 +795,30 @@ public void should_use_existing_casing_for_release_group(string releaseGroup)
.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);

_album.ReleaseDate = new DateTime(2021, 1, 15);

_namingConfig.StandardTrackFormat = "{Release Year}";

Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be("2021");
}
finally
{
Thread.CurrentThread.CurrentCulture = oldCulture;
}
}

[Test]
public void should_replace_artist_name_for_Various_Artists_album()
{
Expand Down
2 changes: 1 addition & 1 deletion src/NzbDrone.Core/Organizer/FileNameBuilder.cs
Expand Up @@ -35,7 +35,7 @@ public class FileNameBuilder : IBuildFileNames
private readonly Logger _logger;

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

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

0 comments on commit 24b8029

Please sign in to comment.