diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index d1c920f8a5..b6995d04bd 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -370,6 +370,7 @@ namespace MediaBrowser.Server.Startup.Common { var migrations = new List { + new OmdbEpisodeProviderMigration(ServerConfigurationManager), new DbMigration(ServerConfigurationManager, TaskManager) }; diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj index b58646a2e6..b3865eadf8 100644 --- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj +++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj @@ -73,6 +73,7 @@ + diff --git a/MediaBrowser.Server.Startup.Common/Migrations/OmdbEpisodeProviderMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/OmdbEpisodeProviderMigration.cs new file mode 100644 index 0000000000..00f6a692b7 --- /dev/null +++ b/MediaBrowser.Server.Startup.Common/Migrations/OmdbEpisodeProviderMigration.cs @@ -0,0 +1,47 @@ +using MediaBrowser.Controller.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MediaBrowser.Server.Startup.Common.Migrations +{ + class OmdbEpisodeProviderMigration : IVersionMigration + { + private readonly IServerConfigurationManager _config; + private const string _providerName = "The Open Movie Database"; + + public OmdbEpisodeProviderMigration(IServerConfigurationManager config) + { + _config = config; + } + + public void Run() + { + var migrationKey = this.GetType().FullName; + var migrationKeyList = _config.Configuration.Migrations.ToList(); + + if (!migrationKeyList.Contains(migrationKey)) + { + foreach (var metaDataOption in _config.Configuration.MetadataOptions) + { + if (metaDataOption.ItemType == "Episode") + { + var disabledFetchers = metaDataOption.DisabledMetadataFetchers.ToList(); + if (!disabledFetchers.Contains(_providerName)) + { + disabledFetchers.Add(_providerName); + metaDataOption.DisabledMetadataFetchers = disabledFetchers.ToArray(); + } + } + } + + migrationKeyList.Add(migrationKey); + _config.Configuration.Migrations = migrationKeyList.ToArray(); + _config.SaveConfiguration(); + } + + } + } +}