aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/Trailer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/Entities/Trailer.cs')
-rw-r--r--MediaBrowser.Controller/Entities/Trailer.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs
index 3bff5bc64f..cefc1dabe9 100644
--- a/MediaBrowser.Controller/Entities/Trailer.cs
+++ b/MediaBrowser.Controller/Entities/Trailer.cs
@@ -106,8 +106,49 @@ namespace MediaBrowser.Controller.Entities
var info = GetItemLookupInfo<TrailerInfo>();
info.IsLocalTrailer = IsLocalTrailer;
+
+ if (!IsInMixedFolder)
+ {
+ info.Name = System.IO.Path.GetFileName(ContainingFolderPath);
+ }
return info;
}
+
+ public override bool BeforeMetadataRefresh()
+ {
+ var hasChanges = base.BeforeMetadataRefresh();
+
+ if (!ProductionYear.HasValue)
+ {
+ var info = LibraryManager.ParseName(Name);
+
+ var yearInName = info.Year;
+
+ if (yearInName.HasValue)
+ {
+ ProductionYear = yearInName;
+ hasChanges = true;
+ }
+ else
+ {
+ // Try to get the year from the folder name
+ if (!IsInMixedFolder)
+ {
+ info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
+
+ yearInName = info.Year;
+
+ if (yearInName.HasValue)
+ {
+ ProductionYear = yearInName;
+ hasChanges = true;
+ }
+ }
+ }
+ }
+
+ return hasChanges;
+ }
}
}