Added migration task for new MovieDbEpisodeProvider

Ensures that the new provider is disabled by default
This commit is contained in:
softworkz 2016-03-03 05:10:15 +01:00
parent 6c50734131
commit 86de8e27b9
3 changed files with 49 additions and 0 deletions

View File

@ -374,6 +374,7 @@ namespace MediaBrowser.Server.Startup.Common
var migrations = new List<IVersionMigration>
{
new OmdbEpisodeProviderMigration(ServerConfigurationManager),
new MovieDbEpisodeProviderMigration(ServerConfigurationManager),
new DbMigration(ServerConfigurationManager, TaskManager)
};

View File

@ -73,6 +73,7 @@
<Compile Include="MbLinkShortcutHandler.cs" />
<Compile Include="Migrations\IVersionMigration.cs" />
<Compile Include="Migrations\DbMigration.cs" />
<Compile Include="Migrations\MovieDbEpisodeProviderMigration.cs" />
<Compile Include="Migrations\OmdbEpisodeProviderMigration.cs" />
<Compile Include="Migrations\RenameXmlOptions.cs" />
<Compile Include="NativeEnvironment.cs" />

View File

@ -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 MovieDbEpisodeProviderMigration : IVersionMigration
{
private readonly IServerConfigurationManager _config;
private const string _providerName = "TheMovieDb";
public MovieDbEpisodeProviderMigration(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();
}
}
}
}