mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-10-26 16:45:09 +00:00
Merge pull request #18061 from panko/pr-naming
Skip optimistic expressions when parsing series names
This commit is contained in:
3 files changed
+31
-1
No files matched your search
@@ -20,6 +20,14 @@ namespace Emby.Naming.TV
|
||||
|
||||
foreach (var expression in options.EpisodeExpressions)
|
||||
{
|
||||
// Optimistic expressions (bare numbers, "01.blah", etc.) are only meant for
|
||||
// episode parsing and produce false series names on release folder names like
|
||||
// "Silo.S03.1080p.WEB-DL..." (e.g. reading "264" as S02E64). Skip them here.
|
||||
if (expression.IsOptimistic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var currentResult = Parse(path, expression);
|
||||
if (currentResult.Success)
|
||||
{
|
||||
@@ -49,8 +57,18 @@ namespace Emby.Naming.TV
|
||||
{
|
||||
if (expression.IsNamed)
|
||||
{
|
||||
// Reject implausible season numbers (e.g. resolutions like 1280x720
|
||||
// read as S1280E720), mirroring EpisodePathParser.
|
||||
var seasonNumberGroup = match.Groups["seasonnumber"];
|
||||
if (seasonNumberGroup.Success
|
||||
&& int.TryParse(seasonNumberGroup.ValueSpan, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out var seasonNumber)
|
||||
&& ((seasonNumber >= 200 && seasonNumber < 1928) || seasonNumber > 2500))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result.SeriesName = match.Groups["seriesname"].Value;
|
||||
result.Success = !string.IsNullOrEmpty(result.SeriesName) && !match.Groups["seasonnumber"].ValueSpan.IsEmpty;
|
||||
result.Success = !string.IsNullOrEmpty(result.SeriesName) && !seasonNumberGroup.ValueSpan.IsEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,5 +25,15 @@ namespace Jellyfin.Naming.Tests.TV
|
||||
Assert.Equal(name, res.SeriesName);
|
||||
Assert.True(res.Success);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/media/Jujutsu Kaisen (BD_1280x720)")]
|
||||
[InlineData("/media/Show.1920x1080.BluRay")]
|
||||
public void SeriesPathParser_ResolutionPatternIsNotASeries(string path)
|
||||
{
|
||||
var res = SeriesPathParser.Parse(_namingOptions, path);
|
||||
|
||||
Assert.False(res.Success);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ namespace Jellyfin.Naming.Tests.TV
|
||||
[InlineData("Marvel's.Agents.of.S.H.I.E.L.D.", "Marvel's Agents of S.H.I.E.L.D.")]
|
||||
[InlineData("The.Show.S.H.O.W", "The Show S.H.O.W")]
|
||||
[InlineData("/some/path/Dawson's Creek", "Dawson's Creek")]
|
||||
[InlineData("/media/Bunker.S03.1080p.PULSAR.WEB-DL.DDP5.1.Atmos.H.264-showWEB", "Bunker")]
|
||||
[InlineData("/media/Outer.Colony.S01.1080p.NOVA.WEB-DL.DDP5.1.H.264.HUN.ENG-QUASAR", "Outer Colony")]
|
||||
public void SeriesResolverResolveTest(string path, string name)
|
||||
{
|
||||
var res = SeriesResolver.Resolve(_namingOptions, path);
|
||||
|
||||
Reference in new issue
Block a user