move more metadata settings to per library

This commit is contained in:
Luke Pulverenti 2016-10-02 00:31:47 -04:00
parent 1454e07c54
commit 911d9f4598
11 changed files with 42 additions and 61 deletions

View File

@ -88,8 +88,6 @@ namespace MediaBrowser.Api
var result = new StartupConfiguration
{
UICulture = _config.Configuration.UICulture,
EnableInternetProviders = _config.Configuration.EnableInternetProviders,
SaveLocalMeta = _config.Configuration.SaveLocalMeta,
MetadataCountryCode = _config.Configuration.MetadataCountryCode,
PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage
};
@ -123,8 +121,6 @@ namespace MediaBrowser.Api
public void Post(UpdateStartupConfiguration request)
{
_config.Configuration.UICulture = request.UICulture;
_config.Configuration.EnableInternetProviders = request.EnableInternetProviders;
_config.Configuration.SaveLocalMeta = request.SaveLocalMeta;
_config.Configuration.MetadataCountryCode = request.MetadataCountryCode;
_config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage;
_config.SaveConfiguration();
@ -215,8 +211,6 @@ namespace MediaBrowser.Api
public class StartupConfiguration
{
public string UICulture { get; set; }
public bool EnableInternetProviders { get; set; }
public bool SaveLocalMeta { get; set; }
public string MetadataCountryCode { get; set; }
public string PreferredMetadataLanguage { get; set; }
public string LiveTvTunerType { get; set; }

View File

@ -422,7 +422,7 @@ namespace MediaBrowser.Controller.Entities
public virtual bool IsInternetMetadataEnabled()
{
return ConfigurationManager.Configuration.EnableInternetProviders;
return LibraryManager.GetLibraryOptions(this).EnableInternetProviders;
}
public virtual bool CanDelete()
@ -1341,7 +1341,9 @@ namespace MediaBrowser.Controller.Entities
return false;
}
return ConfigurationManager.Configuration.SaveLocalMeta;
var libraryOptions = LibraryManager.GetLibraryOptions(this);
return libraryOptions.SaveLocalMetadata;
}
/// <summary>

View File

@ -111,7 +111,7 @@ namespace MediaBrowser.Controller.Entities
{
LibraryOptions[path] = options;
options.SchemaVersion = 2;
options.SchemaVersion = 3;
XmlSerializer.SerializeToFile(options, GetLibraryOptionsPath(path));
}
}

View File

@ -2,17 +2,11 @@
{
public class ChapterOptions
{
public bool EnableMovieChapterImageExtraction { get; set; }
public bool EnableEpisodeChapterImageExtraction { get; set; }
public bool EnableOtherVideoChapterImageExtraction { get; set; }
public bool DownloadMovieChapters { get; set; }
public bool DownloadEpisodeChapters { get; set; }
public string[] FetcherOrder { get; set; }
public string[] DisabledFetchers { get; set; }
public bool ExtractDuringLibraryScan { get; set; }
public ChapterOptions()
{

View File

@ -11,11 +11,15 @@
public bool DownloadImagesInAdvance { get; set; }
public MediaPathInfo[] PathInfos { get; set; }
public bool SaveLocalMetadata { get; set; }
public bool EnableInternetProviders { get; set; }
public LibraryOptions()
{
EnablePhotos = true;
EnableRealtimeMonitor = true;
PathInfos = new MediaPathInfo[] { };
EnableInternetProviders = true;
}
}

View File

@ -262,8 +262,8 @@ namespace MediaBrowser.Providers.MediaInfo
NormalizeChapterNames(chapters);
var libraryOptions = _libraryManager.GetLibraryOptions(video);
var extractDuringScan = chapterOptions.ExtractDuringLibraryScan;
if (libraryOptions != null && libraryOptions.SchemaVersion >= 2)
var extractDuringScan = false;
if (libraryOptions != null)
{
extractDuringScan = libraryOptions.ExtractChapterImagesDuringLibraryScan;
}

View File

@ -118,7 +118,7 @@ namespace MediaBrowser.Providers.TV
var hasNewEpisodes = false;
if (_config.Configuration.EnableInternetProviders && addNewItems)
if (addNewItems && !group.Any(i => !i.IsInternetMetadataEnabled()))
{
var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase));

View File

@ -74,12 +74,6 @@ namespace MediaBrowser.Providers.TV
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
if (!_config.Configuration.EnableInternetProviders)
{
progress.Report(100);
return;
}
var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase));
if (seriesConfig != null && seriesConfig.DisabledMetadataFetchers.Contains(TvdbSeriesProvider.Current.Name, StringComparer.OrdinalIgnoreCase))
@ -116,7 +110,9 @@ namespace MediaBrowser.Providers.TV
IncludeItemTypes = new[] { typeof(Series).Name },
Recursive = true,
GroupByPresentationUniqueKey = false
}).Cast<Series>();
}).Cast<Series>()
.ToList();
var seriesIdsInLibrary = seriesList
.Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb)))
@ -126,6 +122,13 @@ namespace MediaBrowser.Providers.TV
var missingSeries = seriesIdsInLibrary.Except(existingDirectories, StringComparer.OrdinalIgnoreCase)
.ToList();
var enableInternetProviders = seriesList.Count == 0 ? false : seriesList[0].IsInternetMetadataEnabled();
if (!enableInternetProviders)
{
progress.Report(100);
return;
}
// If this is our first time, update all series
if (string.IsNullOrEmpty(lastUpdateTime))
{

View File

@ -1216,12 +1216,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (libraryFolder != null)
{
info.ItemId = libraryFolder.Id.ToString("N");
}
var collectionFolder = libraryFolder as CollectionFolder;
if (collectionFolder != null)
{
info.LibraryOptions = collectionFolder.GetLibraryOptions();
info.LibraryOptions = GetLibraryOptions(libraryFolder);
}
return info;
@ -1889,11 +1884,23 @@ namespace MediaBrowser.Server.Implementations.Library
public LibraryOptions GetLibraryOptions(BaseItem item)
{
var collectionFolder = GetCollectionFolders(item)
.OfType<CollectionFolder>()
.FirstOrDefault();
var collectionFolder = item as CollectionFolder;
if (collectionFolder == null)
{
collectionFolder = GetCollectionFolders(item)
.OfType<CollectionFolder>()
.FirstOrDefault();
}
return collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
var options = collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
if (options.SchemaVersion < 3)
{
options.SaveLocalMetadata = ConfigurationManager.Configuration.SaveLocalMeta;
options.EnableInternetProviders = ConfigurationManager.Configuration.EnableInternetProviders;
}
return options;
}
public string GetContentType(BaseItem item)

View File

@ -61,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
}
var libraryOptions = _libraryManager.GetLibraryOptions(video);
if (libraryOptions != null && libraryOptions.SchemaVersion >= 2)
if (libraryOptions != null)
{
if (!libraryOptions.EnableChapterImageExtraction)
{
@ -70,29 +70,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
}
else
{
var options = _chapterManager.GetConfiguration();
if (video is Movie)
{
if (!options.EnableMovieChapterImageExtraction)
{
return false;
}
}
else if (video is Episode)
{
if (!options.EnableEpisodeChapterImageExtraction)
{
return false;
}
}
else
{
if (!options.EnableOtherVideoChapterImageExtraction)
{
return false;
}
}
return false;
}
// Can't extract images if there are no video streams

View File

@ -242,8 +242,7 @@ namespace MediaBrowser.Server.Implementations.Session
var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue;
user.LastActivityDate = activityDate;
// Don't log in the db anymore frequently than 10 seconds
if ((activityDate - userLastActivityDate).TotalSeconds > 10)
if ((activityDate - userLastActivityDate).TotalSeconds > 60)
{
try
{