Procházet zdrojové kódy

add another parser case and allow parsing of seasonless

Add another parser case and we now allow parsing of seasonless series which hopefully should cover more cases of directory structure
Narfinger před 5 roky
rodič
revize
4a20260a27

+ 7 - 3
Emby.Naming/Common/NamingOptions.cs

@@ -328,6 +328,10 @@ namespace Emby.Naming.Common
 
 
                 // *** End Kodi Standard Naming
                 // *** End Kodi Standard Naming
 
 
+                // [bar] Foo - 1 [baz]
+                new EpisodeExpression(@".*?(\[.*?\])+.*?(?<seriesname>(\w+\s)+?)[-\s_]+(?<epnumber>\d{1,3}).*$"){
+                    IsNamed=false,
+                },
                 new EpisodeExpression(@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})[^\\\/]*$")
                 new EpisodeExpression(@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})[^\\\/]*$")
                 {
                 {
                     IsNamed = true
                     IsNamed = true
@@ -654,9 +658,9 @@ namespace Emby.Naming.Common
                 @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
                 @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
                 @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$"
                 @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$"
             }.Select(i => new EpisodeExpression(i)
             }.Select(i => new EpisodeExpression(i)
-                {
-                    IsNamed = true
-                }).ToArray();
+            {
+                IsNamed = true
+            }).ToArray();
 
 
             VideoFileExtensions = extensions
             VideoFileExtensions = extensions
                 .Distinct(StringComparer.OrdinalIgnoreCase)
                 .Distinct(StringComparer.OrdinalIgnoreCase)

+ 5 - 1
Emby.Server.Implementations/Library/LibraryManager.cs

@@ -1899,7 +1899,7 @@ namespace Emby.Server.Implementations.Library
         /// <param name="cancellationToken">The cancellation token.</param>
         /// <param name="cancellationToken">The cancellation token.</param>
         public void UpdateItem(BaseItem item, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
         public void UpdateItem(BaseItem item, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
         {
         {
-            UpdateItems(new [] { item }, parent, updateReason, cancellationToken);
+            UpdateItems(new[] { item }, parent, updateReason, cancellationToken);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -2487,6 +2487,10 @@ namespace Emby.Server.Implementations.Library
                 {
                 {
                     episode.ParentIndexNumber = season.IndexNumber;
                     episode.ParentIndexNumber = season.IndexNumber;
                 }
                 }
+                else
+                {
+                    episode.ParentIndexNumber = 1;
+                }
 
 
                 if (episode.ParentIndexNumber.HasValue)
                 if (episode.ParentIndexNumber.HasValue)
                 {
                 {

+ 3 - 2
tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs

@@ -30,12 +30,13 @@ namespace Emby.Naming.TV
         }
         }
 
 
         [Theory]
         [Theory]
-        [InlineData("/media/Foo/Foo 889.avi", "Foo", 889)]
+        [InlineData("/media/Foo/Foo 889", "Foo", 889)]
+        [InlineData("/media/Foo/[Bar] Foo Baz - 11 [1080p]", "Foo Baz", 11)]
         public void ParseEpisodeWithoutSeason(string path, string name, int episode)
         public void ParseEpisodeWithoutSeason(string path, string name, int episode)
         {
         {
             NamingOptions o = new NamingOptions();
             NamingOptions o = new NamingOptions();
             EpisodePathParser p = new EpisodePathParser(o);
             EpisodePathParser p = new EpisodePathParser(o);
-            var res = p.Parse(path, false, null, null, true);
+            var res = p.Parse(path, true, null, null, true);
 
 
             Assert.True(res.Success);
             Assert.True(res.Success);
             Assert.Equal(name, res.SeriesName);
             Assert.Equal(name, res.SeriesName);