Browse Source

Merge pull request #7544 from jaantaponen/long-filename-fix

Cody Robibero 3 years ago
parent
commit
8a1eca0913

+ 9 - 2
Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs

@@ -3,6 +3,7 @@
 using System;
 using System;
 using System.Globalization;
 using System.Globalization;
 using MediaBrowser.Controller.LiveTv;
 using MediaBrowser.Controller.LiveTv;
+using System.Text;
 
 
 namespace Emby.Server.Implementations.LiveTv.EmbyTV
 namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
@@ -48,12 +49,18 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
 
 
                 if (!string.IsNullOrWhiteSpace(info.EpisodeTitle))
                 if (!string.IsNullOrWhiteSpace(info.EpisodeTitle))
                 {
                 {
+                    var tmpName = name;
                     if (addHyphen)
                     if (addHyphen)
                     {
                     {
-                        name += " -";
+                        tmpName += " -";
                     }
                     }
 
 
-                    name += " " + info.EpisodeTitle;
+                    tmpName += " " + info.EpisodeTitle;
+                    //  Since the filename will be used with file ext. (.mp4, .ts, etc)
+                    if (Encoding.UTF8.GetByteCount(tmpName) < 250)
+                    {
+                        name = tmpName;
+                    }
                 }
                 }
             }
             }
             else if (info.IsMovie && info.ProductionYear != null)
             else if (info.IsMovie && info.ProductionYear != null)

+ 11 - 0
tests/Jellyfin.Server.Implementations.Tests/LiveTv/RecordingHelperTests.cs

@@ -85,6 +85,17 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
                     EpisodeTitle = "The VCR Illumination"
                     EpisodeTitle = "The VCR Illumination"
                 });
                 });
 
 
+            data.Add(
+               "Lorem ipsum dolor sit amet: consect 2018_12_06_21_06_00",
+               new TimerInfo
+               {
+                   Name = "Lorem ipsum dolor sit amet: consect",
+                   IsProgramSeries = true,
+                   StartDate = new DateTime(2018, 12, 6, 21, 6, 0, DateTimeKind.Local),
+                   OriginalAirDate = new DateTime(2018, 12, 6),
+                   EpisodeTitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor"
+               });
+
             return data;
             return data;
         }
         }