Browse Source

keep season/episode info up to date

Luke Pulverenti 8 years ago
parent
commit
2fed4c1ab8

+ 32 - 1
MediaBrowser.Providers/TV/EpisodeMetadataService.cs

@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Configuration;
+using System;
+using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Providers;
@@ -6,12 +7,42 @@ using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Providers.Manager;
 using System.Collections.Generic;
+using System.Threading.Tasks;
 using CommonIO;
 
 namespace MediaBrowser.Providers.TV
 {
     public class EpisodeMetadataService : MetadataService<Episode, EpisodeInfo>
     {
+        protected override async Task<ItemUpdateType> BeforeSave(Episode item, bool isFullRefresh, ItemUpdateType currentUpdateType)
+        {
+            var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false);
+
+            if (updateType <= ItemUpdateType.None)
+            {
+                if (!string.Equals(item.SeriesName, item.FindSeriesName(), StringComparison.Ordinal))
+                {
+                    updateType |= ItemUpdateType.MetadataImport;
+                }
+            }
+            if (updateType <= ItemUpdateType.None)
+            {
+                if (!string.Equals(item.SeriesSortName, item.FindSeriesSortName(), StringComparison.Ordinal))
+                {
+                    updateType |= ItemUpdateType.MetadataImport;
+                }
+            }
+            if (updateType <= ItemUpdateType.None)
+            {
+                if (!string.Equals(item.SeasonName, item.FindSeasonName(), StringComparison.Ordinal))
+                {
+                    updateType |= ItemUpdateType.MetadataImport;
+                }
+            }
+
+            return updateType;
+        }
+
         protected override void MergeData(MetadataResult<Episode> source, MetadataResult<Episode> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
         {
             ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);

+ 15 - 0
MediaBrowser.Providers/TV/SeasonMetadataService.cs

@@ -35,6 +35,21 @@ namespace MediaBrowser.Providers.TV
                 updateType |= SaveIsVirtualItem(item, episodes);
             }
 
+            if (updateType <= ItemUpdateType.None)
+            {
+                if (!string.Equals(item.SeriesName, item.FindSeriesName(), StringComparison.Ordinal))
+                {
+                    updateType |= ItemUpdateType.MetadataImport;
+                }
+            }
+            if (updateType <= ItemUpdateType.None)
+            {
+                if (!string.Equals(item.SeriesSortName, item.FindSeriesSortName(), StringComparison.Ordinal))
+                {
+                    updateType |= ItemUpdateType.MetadataImport;
+                }
+            }
+
             return updateType;
         }