mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-06 17:35:32 +01:00
Merge pull request #14824 from CodyEngel/fix-numeric-titles
Fix TV Series parsing containing only numbers.
This commit is contained in:
commit
8c02c3be93
2 changed files with 22 additions and 0 deletions
|
|
@ -17,6 +17,13 @@ namespace Emby.Naming.TV
|
||||||
[GeneratedRegex(@"((?<a>[^\._]{2,})[\._]*)|([\._](?<b>[^\._]{2,}))")]
|
[GeneratedRegex(@"((?<a>[^\._]{2,})[\._]*)|([\._](?<b>[^\._]{2,}))")]
|
||||||
private static partial Regex SeriesNameRegex();
|
private static partial Regex SeriesNameRegex();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Regex that matches titles with year in parentheses. Captures the title (which may be
|
||||||
|
/// numeric) before the year, i.e. turns "1923 (2022)" into "1923".
|
||||||
|
/// </summary>
|
||||||
|
[GeneratedRegex(@"(?<title>.+?)\s*\(\d{4}\)")]
|
||||||
|
private static partial Regex TitleWithYearRegex();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolve information about series from path.
|
/// Resolve information about series from path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -27,6 +34,20 @@ namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
string seriesName = Path.GetFileName(path);
|
string seriesName = Path.GetFileName(path);
|
||||||
|
|
||||||
|
// First check if the filename matches a title with year pattern (handles numeric titles)
|
||||||
|
if (!string.IsNullOrEmpty(seriesName))
|
||||||
|
{
|
||||||
|
var titleWithYearMatch = TitleWithYearRegex().Match(seriesName);
|
||||||
|
if (titleWithYearMatch.Success)
|
||||||
|
{
|
||||||
|
seriesName = titleWithYearMatch.Groups["title"].Value.Trim();
|
||||||
|
return new SeriesInfo(path)
|
||||||
|
{
|
||||||
|
Name = seriesName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SeriesPathParserResult result = SeriesPathParser.Parse(options, path);
|
SeriesPathParserResult result = SeriesPathParser.Parse(options, path);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ namespace Jellyfin.Naming.Tests.TV
|
||||||
[InlineData("/some/path/The Show", "The Show")]
|
[InlineData("/some/path/The Show", "The Show")]
|
||||||
[InlineData("/some/path/The Show s02e10 720p hdtv", "The Show")]
|
[InlineData("/some/path/The Show s02e10 720p hdtv", "The Show")]
|
||||||
[InlineData("/some/path/The Show s02e10 the episode 720p hdtv", "The Show")]
|
[InlineData("/some/path/The Show s02e10 the episode 720p hdtv", "The Show")]
|
||||||
|
[InlineData("/some/path/1923 (2022)", "1923")]
|
||||||
public void SeriesResolverResolveTest(string path, string name)
|
public void SeriesResolverResolveTest(string path, string name)
|
||||||
{
|
{
|
||||||
var res = SeriesResolver.Resolve(_namingOptions, path);
|
var res = SeriesResolver.Resolve(_namingOptions, path);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue