From 5f76b59e67f64c1f24b5938808521f356a67039e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 18 Jan 2015 00:45:10 -0500 Subject: [PATCH] separate provider options --- .../MediaBrowser.Model.Portable.csproj | 9 ++ .../MediaBrowser.Model.net35.csproj | 9 ++ .../Configuration/FanartOptions.cs | 17 +++ .../Configuration/ServerConfiguration.cs | 22 ++-- .../Configuration/TheMovieDbOptions.cs | 12 +++ .../Configuration/TvdbOptions.cs | 12 +++ MediaBrowser.Model/Dlna/StreamBuilder.cs | 2 +- MediaBrowser.Model/MediaBrowser.Model.csproj | 3 + .../Movies/FanArtMovieUpdatesPostScanTask.cs | 15 ++- .../Movies/FanartMovieImageProvider.cs | 9 +- .../Movies/MovieDbProvider.cs | 23 +++- .../Movies/MovieUpdatesPrescanTask.cs | 2 +- .../Music/FanArtAlbumProvider.cs | 4 +- .../Music/FanArtArtistProvider.cs | 9 +- .../Music/FanArtUpdatesPostScanTask.cs | 14 ++- .../TV/FanArtSeasonProvider.cs | 3 +- .../TV/FanArtTvUpdatesPostScanTask.cs | 13 ++- .../TV/FanartSeriesProvider.cs | 39 +++++-- .../TV/MovieDbSeriesProvider.cs | 2 +- .../TV/TvdbEpisodeImageProvider.cs | 2 +- .../TV/TvdbSeasonImageProvider.cs | 2 +- .../TV/TvdbSeriesImageProvider.cs | 2 +- .../TV/TvdbSeriesProvider.cs | 23 +++- .../Localization/Server/server.json | 9 +- .../Sync/SyncJobProcessor.cs | 4 +- .../Api/DashboardService.cs | 8 +- .../Api/PackageCreator.cs | 102 ++++++++++++------ .../MediaBrowser.WebDashboard.csproj | 8 +- 28 files changed, 280 insertions(+), 99 deletions(-) create mode 100644 MediaBrowser.Model/Configuration/FanartOptions.cs create mode 100644 MediaBrowser.Model/Configuration/TheMovieDbOptions.cs create mode 100644 MediaBrowser.Model/Configuration/TvdbOptions.cs diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index de60a3e834..1effef4c64 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -194,6 +194,9 @@ Configuration\EncodingQuality.cs + + Configuration\FanartOptions.cs + Configuration\ImageOption.cs @@ -227,6 +230,12 @@ Configuration\SubtitlePlaybackMode.cs + + Configuration\TheMovieDbOptions.cs + + + Configuration\TvdbOptions.cs + Configuration\UnratedItem.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 1cc1aac094..a303a47184 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -159,6 +159,9 @@ Configuration\EncodingQuality.cs + + Configuration\FanartOptions.cs + Configuration\ImageOption.cs @@ -192,6 +195,12 @@ Configuration\SubtitlePlaybackMode.cs + + Configuration\TheMovieDbOptions.cs + + + Configuration\TvdbOptions.cs + Configuration\UnratedItem.cs diff --git a/MediaBrowser.Model/Configuration/FanartOptions.cs b/MediaBrowser.Model/Configuration/FanartOptions.cs new file mode 100644 index 0000000000..e992abe5de --- /dev/null +++ b/MediaBrowser.Model/Configuration/FanartOptions.cs @@ -0,0 +1,17 @@ + +namespace MediaBrowser.Model.Configuration +{ + public class FanartOptions + { + /// + /// Gets or sets a value indicating whether [enable automatic updates]. + /// + /// true if [enable automatic updates]; otherwise, false. + public bool EnableAutomaticUpdates { get; set; } + /// + /// Gets or sets the user API key. + /// + /// The user API key. + public string UserApiKey { get; set; } + } +} diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 755fe8aa83..e51cca7708 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -1,5 +1,4 @@ -using System.Xml.Schema; -using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; namespace MediaBrowser.Model.Configuration @@ -32,10 +31,11 @@ namespace MediaBrowser.Model.Configuration /// /// The HTTPS server port number. public int HttpsPortNumber { get; set; } - - /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. + + /// + /// Gets or sets a value indicating whether [use HTTPS]. /// - /// The value pointing to the file system where the ssl certiifcate is located. + /// true if [use HTTPS]; otherwise, false. public bool UseHttps { get; set; } /// @@ -154,6 +154,7 @@ namespace MediaBrowser.Model.Configuration /// /// true if [enable dashboard response caching]; otherwise, false. public bool EnableDashboardResponseCaching { get; set; } + public bool EnableDashboardResourceMinification { get; set; } /// /// Allows the dashboard to be served from a custom path. @@ -161,18 +162,8 @@ namespace MediaBrowser.Model.Configuration /// The dashboard source path. public string DashboardSourcePath { get; set; } - /// - /// Gets or sets a value indicating whether [enable tv db updates]. - /// - /// true if [enable tv db updates]; otherwise, false. - public bool EnableTvDbUpdates { get; set; } - public bool EnableTmdbUpdates { get; set; } - public bool StoreArtistsInMetadata { get; set; } - public bool EnableFanArtUpdates { get; set; } - public string FanartApiKey { get; set; } - /// /// Gets or sets the image saving convention. /// @@ -220,6 +211,7 @@ namespace MediaBrowser.Model.Configuration UseHttps = false; CertificatePath = null; EnableDashboardResponseCaching = true; + EnableDashboardResourceMinification = true; EnableAutomaticRestart = true; EnableWin8HttpListener = true; diff --git a/MediaBrowser.Model/Configuration/TheMovieDbOptions.cs b/MediaBrowser.Model/Configuration/TheMovieDbOptions.cs new file mode 100644 index 0000000000..9a73e34764 --- /dev/null +++ b/MediaBrowser.Model/Configuration/TheMovieDbOptions.cs @@ -0,0 +1,12 @@ + +namespace MediaBrowser.Model.Configuration +{ + public class TheMovieDbOptions + { + /// + /// Gets or sets a value indicating whether [enable automatic updates]. + /// + /// true if [enable automatic updates]; otherwise, false. + public bool EnableAutomaticUpdates { get; set; } + } +} diff --git a/MediaBrowser.Model/Configuration/TvdbOptions.cs b/MediaBrowser.Model/Configuration/TvdbOptions.cs new file mode 100644 index 0000000000..034af609c4 --- /dev/null +++ b/MediaBrowser.Model/Configuration/TvdbOptions.cs @@ -0,0 +1,12 @@ + +namespace MediaBrowser.Model.Configuration +{ + public class TvdbOptions + { + /// + /// Gets or sets a value indicating whether [enable automatic updates]. + /// + /// true if [enable automatic updates]; otherwise, false. + public bool EnableAutomaticUpdates { get; set; } + } +} diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index f1c6875379..721da54a80 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -548,7 +548,7 @@ namespace MediaBrowser.Model.Dlna { SubtitleProfile externalProfile = GetSubtitleProfile(options.Profile.SubtitleProfiles, SubtitleDeliveryMethod.External, _serverTextSubtitleOutputs); - if (options.Context == EncodingContext.Streaming && externalProfile != null) + if (externalProfile != null) { return externalProfile; } diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 599e4a9021..716f795625 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -97,8 +97,11 @@ + + + diff --git a/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs b/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs index 2f3d8ceeae..6e57ddb01c 100644 --- a/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs +++ b/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Providers.Music; @@ -13,6 +14,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Providers.TV; namespace MediaBrowser.Providers.Movies { @@ -54,7 +56,9 @@ namespace MediaBrowser.Providers.Movies /// Task. public async Task Run(IProgress progress, CancellationToken cancellationToken) { - if (!_config.Configuration.EnableFanArtUpdates) + var options = FanartSeriesProvider.Current.GetFanartOptions(); + + if (!options.EnableAutomaticUpdates) { progress.Report(100); return; @@ -82,7 +86,7 @@ namespace MediaBrowser.Providers.Movies // If this is our first time, don't do any updates and just record the timestamp if (!string.IsNullOrEmpty(lastUpdateTime)) { - var moviesToUpdate = await GetMovieIdsToUpdate(existingDirectories, lastUpdateTime, cancellationToken).ConfigureAwait(false); + var moviesToUpdate = await GetMovieIdsToUpdate(existingDirectories, lastUpdateTime, options, cancellationToken).ConfigureAwait(false); progress.Report(5); @@ -96,13 +100,14 @@ namespace MediaBrowser.Providers.Movies progress.Report(100); } - private async Task> GetMovieIdsToUpdate(IEnumerable existingIds, string lastUpdateTime, CancellationToken cancellationToken) + private async Task> GetMovieIdsToUpdate(IEnumerable existingIds, string lastUpdateTime, FanartOptions options, CancellationToken cancellationToken) { var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); - if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + var clientKey = options.UserApiKey; + if (!string.IsNullOrWhiteSpace(clientKey)) { - url += "&client_key=" + _config.Configuration.FanartApiKey; + url += "&client_key=" + clientKey; } // First get last time diff --git a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs index 91d8830e60..8d0c5cd54a 100644 --- a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs +++ b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs @@ -19,6 +19,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Providers.TV; namespace MediaBrowser.Providers.Movies { @@ -216,7 +217,8 @@ namespace MediaBrowser.Providers.Movies public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date) { - if (!_config.Configuration.EnableFanArtUpdates) + var options = FanartSeriesProvider.Current.GetFanartOptions(); + if (!options.EnableAutomaticUpdates) { return false; } @@ -283,9 +285,10 @@ namespace MediaBrowser.Providers.Movies var url = string.Format(FanArtBaseUrl, FanartArtistProvider.ApiKey, id); - if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + var clientKey = FanartSeriesProvider.Current.GetFanartOptions().UserApiKey; + if (!string.IsNullOrWhiteSpace(clientKey)) { - url += "&client_key=" + _config.Configuration.FanartApiKey; + url += "&client_key=" + clientKey; } var path = GetFanartJsonPath(id); diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index 05747e49f5..b4d7b14dcd 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -7,6 +7,7 @@ using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Providers; @@ -371,9 +372,14 @@ namespace MediaBrowser.Providers.Movies return _httpClient.Get(options); } + public TheMovieDbOptions GetTheMovieDbOptions() + { + return _configurationManager.GetConfiguration("themoviedb"); + } + public bool HasChanged(IHasMetadata item, DateTime date) { - if (!_configurationManager.Configuration.EnableTmdbUpdates) + if (!GetTheMovieDbOptions().EnableAutomaticUpdates) { return false; } @@ -605,4 +611,19 @@ namespace MediaBrowser.Providers.Movies }); } } + + public class TmdbConfigStore : IConfigurationFactory + { + public IEnumerable GetConfigurations() + { + return new List + { + new ConfigurationStore + { + Key = "themoviedb", + ConfigurationType = typeof(TheMovieDbOptions) + } + }; + } + } } diff --git a/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs b/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs index d03573a965..dd4b335425 100644 --- a/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs +++ b/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs @@ -68,7 +68,7 @@ namespace MediaBrowser.Providers.Movies /// Task. public async Task Run(IProgress progress, CancellationToken cancellationToken) { - if (!_config.Configuration.EnableTmdbUpdates) + if (!MovieDbProvider.Current.GetTheMovieDbOptions().EnableAutomaticUpdates) { progress.Report(100); return; diff --git a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs index 123ff9e290..734ee74b6e 100644 --- a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs @@ -16,6 +16,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Xml; +using MediaBrowser.Providers.TV; namespace MediaBrowser.Providers.Music { @@ -356,7 +357,8 @@ namespace MediaBrowser.Providers.Music public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date) { - if (!_config.Configuration.EnableFanArtUpdates) + var options = FanartSeriesProvider.Current.GetFanartOptions(); + if (!options.EnableAutomaticUpdates) { return false; } diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs index 6bb4b0aeff..0ed654962c 100644 --- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs @@ -17,6 +17,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Xml; +using MediaBrowser.Providers.TV; namespace MediaBrowser.Providers.Music { @@ -373,7 +374,8 @@ namespace MediaBrowser.Providers.Music public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date) { - if (!_config.Configuration.EnableFanArtUpdates) + var options = FanartSeriesProvider.Current.GetFanartOptions(); + if (!options.EnableAutomaticUpdates) { return false; } @@ -423,9 +425,10 @@ namespace MediaBrowser.Providers.Music var url = string.Format(FanArtBaseUrl, ApiKey, musicBrainzId); - if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + var clientKey = FanartSeriesProvider.Current.GetFanartOptions().UserApiKey; + if (!string.IsNullOrWhiteSpace(clientKey)) { - url += "&client_key=" + _config.Configuration.FanartApiKey; + url += "&client_key=" + clientKey; } var xmlPath = GetArtistXmlPath(_config.ApplicationPaths, musicBrainzId); diff --git a/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs b/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs index 703153e319..a9b05c99f6 100644 --- a/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs +++ b/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using System; @@ -12,6 +13,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Providers.TV; namespace MediaBrowser.Providers.Music { @@ -53,7 +55,9 @@ namespace MediaBrowser.Providers.Music /// Task. public async Task Run(IProgress progress, CancellationToken cancellationToken) { - if (!_config.Configuration.EnableFanArtUpdates) + var options = FanartSeriesProvider.Current.GetFanartOptions(); + + if (!options.EnableAutomaticUpdates) { progress.Report(100); return; @@ -81,7 +85,7 @@ namespace MediaBrowser.Providers.Music // If this is our first time, don't do any updates and just record the timestamp if (!string.IsNullOrEmpty(lastUpdateTime)) { - var artistsToUpdate = await GetArtistIdsToUpdate(existingDirectories, lastUpdateTime, cancellationToken).ConfigureAwait(false); + var artistsToUpdate = await GetArtistIdsToUpdate(existingDirectories, lastUpdateTime, options, cancellationToken).ConfigureAwait(false); progress.Report(5); @@ -102,13 +106,13 @@ namespace MediaBrowser.Providers.Music /// The last update time. /// The cancellation token. /// Task{IEnumerable{System.String}}. - private async Task> GetArtistIdsToUpdate(IEnumerable existingArtistIds, string lastUpdateTime, CancellationToken cancellationToken) + private async Task> GetArtistIdsToUpdate(IEnumerable existingArtistIds, string lastUpdateTime, FanartOptions options, CancellationToken cancellationToken) { var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); - if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + if (!string.IsNullOrWhiteSpace(options.UserApiKey)) { - url += "&client_key=" + _config.Configuration.FanartApiKey; + url += "&client_key=" + options.UserApiKey; } // First get last time diff --git a/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs b/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs index 9f0cd4ff12..bbffd91b7c 100644 --- a/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs @@ -223,7 +223,8 @@ namespace MediaBrowser.Providers.TV public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date) { - if (!_config.Configuration.EnableFanArtUpdates) + var options = FanartSeriesProvider.Current.GetFanartOptions(); + if (!options.EnableAutomaticUpdates) { return false; } diff --git a/MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs b/MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs index 567f3b5daa..115b80434c 100644 --- a/MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs +++ b/MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Providers.Music; @@ -54,7 +55,9 @@ namespace MediaBrowser.Providers.TV /// Task. public async Task Run(IProgress progress, CancellationToken cancellationToken) { - if (!_config.Configuration.EnableFanArtUpdates) + var options = FanartSeriesProvider.Current.GetFanartOptions(); + + if (!options.EnableAutomaticUpdates) { progress.Report(100); return; @@ -82,7 +85,7 @@ namespace MediaBrowser.Providers.TV // If this is our first time, don't do any updates and just record the timestamp if (!string.IsNullOrEmpty(lastUpdateTime)) { - var seriesToUpdate = await GetSeriesIdsToUpdate(existingDirectories, lastUpdateTime, cancellationToken).ConfigureAwait(false); + var seriesToUpdate = await GetSeriesIdsToUpdate(existingDirectories, lastUpdateTime, options, cancellationToken).ConfigureAwait(false); progress.Report(5); @@ -103,13 +106,13 @@ namespace MediaBrowser.Providers.TV /// The last update time. /// The cancellation token. /// Task{IEnumerable{System.String}}. - private async Task> GetSeriesIdsToUpdate(IEnumerable existingSeriesIds, string lastUpdateTime, CancellationToken cancellationToken) + private async Task> GetSeriesIdsToUpdate(IEnumerable existingSeriesIds, string lastUpdateTime, FanartOptions options, CancellationToken cancellationToken) { var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); - if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + if (!string.IsNullOrWhiteSpace(options.UserApiKey)) { - url += "&client_key=" + _config.Configuration.FanartApiKey; + url += "&client_key=" + options.UserApiKey; } // First get last time diff --git a/MediaBrowser.Providers/TV/FanartSeriesProvider.cs b/MediaBrowser.Providers/TV/FanartSeriesProvider.cs index f95b6b2c68..e512e6af81 100644 --- a/MediaBrowser.Providers/TV/FanartSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/FanartSeriesProvider.cs @@ -6,6 +6,7 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Net; @@ -161,10 +162,10 @@ namespace MediaBrowser.Providers.TV PopulateImages(list, obj.tvposter, ImageType.Primary, 1000, 1426); } - private void PopulateImages(List list, - List images, - ImageType type, - int width, + private void PopulateImages(List list, + List images, + ImageType type, + int width, int height, bool allowSeasonAll = false) { @@ -283,6 +284,11 @@ namespace MediaBrowser.Providers.TV } } + public FanartOptions GetFanartOptions() + { + return _config.GetConfiguration("fanart"); + } + /// /// Downloads the series json. /// @@ -295,11 +301,12 @@ namespace MediaBrowser.Providers.TV var url = string.Format(FanArtBaseUrl, FanartArtistProvider.ApiKey, tvdbId); - if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + var clientKey = GetFanartOptions().UserApiKey; + if (!string.IsNullOrWhiteSpace(clientKey)) { - url += "&client_key=" + _config.Configuration.FanartApiKey; + url += "&client_key=" + clientKey; } - + var path = GetFanartJsonPath(tvdbId); Directory.CreateDirectory(Path.GetDirectoryName(path)); @@ -336,7 +343,8 @@ namespace MediaBrowser.Providers.TV public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date) { - if (!_config.Configuration.EnableFanArtUpdates) + var options = GetFanartOptions(); + if (!options.EnableAutomaticUpdates) { return false; } @@ -383,4 +391,19 @@ namespace MediaBrowser.Providers.TV public List seasonbanner { get; set; } } } + + public class FanartConfigStore : IConfigurationFactory + { + public IEnumerable GetConfigurations() + { + return new List + { + new ConfigurationStore + { + Key = "fanart", + ConfigurationType = typeof(FanartOptions) + } + }; + } + } } diff --git a/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs index b4588741e2..0fcbab1691 100644 --- a/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs @@ -369,7 +369,7 @@ namespace MediaBrowser.Providers.TV public bool HasChanged(IHasMetadata item, DateTime date) { - if (!_configurationManager.Configuration.EnableTmdbUpdates) + if (!MovieDbProvider.Current.GetTheMovieDbOptions().EnableAutomaticUpdates) { return false; } diff --git a/MediaBrowser.Providers/TV/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/TV/TvdbEpisodeImageProvider.cs index d105174706..969a76e38c 100644 --- a/MediaBrowser.Providers/TV/TvdbEpisodeImageProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbEpisodeImageProvider.cs @@ -193,7 +193,7 @@ namespace MediaBrowser.Providers.TV if (!episode.IsVirtualUnaired) { // For non-unaired items, only enable if configured - if (!_config.Configuration.EnableTvDbUpdates) + if (!TvdbSeriesProvider.Current.GetTvDbOptions().EnableAutomaticUpdates) { return false; } diff --git a/MediaBrowser.Providers/TV/TvdbSeasonImageProvider.cs b/MediaBrowser.Providers/TV/TvdbSeasonImageProvider.cs index 1ebd7bed55..4dbf05d539 100644 --- a/MediaBrowser.Providers/TV/TvdbSeasonImageProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeasonImageProvider.cs @@ -362,7 +362,7 @@ namespace MediaBrowser.Providers.TV if (item.LocationType != LocationType.Virtual) { // For non-virtual items, only enable if configured - if (!_config.Configuration.EnableTvDbUpdates) + if (!TvdbSeriesProvider.Current.GetTvDbOptions().EnableAutomaticUpdates) { return false; } diff --git a/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs index 08913d3b49..6c8a06e386 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs @@ -340,7 +340,7 @@ namespace MediaBrowser.Providers.TV public bool HasChanged(IHasMetadata item, MetadataStatus status, IDirectoryService directoryService) { - if (!_config.Configuration.EnableTvDbUpdates) + if (!TvdbSeriesProvider.Current.GetTvDbOptions().EnableAutomaticUpdates) { return false; } diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs index fa49afbe97..2be3192335 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs @@ -6,6 +6,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; @@ -224,6 +225,11 @@ namespace MediaBrowser.Providers.TV await ExtractEpisodes(seriesDataPath, Path.Combine(seriesDataPath, preferredMetadataLanguage + ".xml"), lastTvDbUpdateTime).ConfigureAwait(false); } + public TvdbOptions GetTvDbOptions() + { + return _config.GetConfiguration("tvdb"); + } + private readonly Task _cachedTask = Task.FromResult(true); internal Task EnsureSeriesInfo(string seriesId, string preferredMetadataLanguage, CancellationToken cancellationToken) { @@ -237,7 +243,7 @@ namespace MediaBrowser.Providers.TV var seriesXmlFilename = preferredMetadataLanguage + ".xml"; var download = false; - var automaticUpdatesEnabled = _config.Configuration.EnableTvDbUpdates; + var automaticUpdatesEnabled = GetTvDbOptions().EnableAutomaticUpdates; const int cacheDays = 2; @@ -1219,4 +1225,19 @@ namespace MediaBrowser.Providers.TV }); } } + + public class TvdbConfigStore : IConfigurationFactory + { + public IEnumerable GetConfigurations() + { + return new List + { + new ConfigurationStore + { + Key = "tvdb", + ConfigurationType = typeof(TvdbOptions) + } + }; + } + } } diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 1ed5ddb4fd..37948cb3f4 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -40,6 +40,12 @@ "OptionIAcceptTermsOfService": "I accept the terms of service", "ButtonPrivacyPolicy": "Privacy policy", "ButtonTermsOfService": "Terms of Service", + "HeaderDeveloperOptions": "Developer Options", + "OptionEnableWebClientResponseCache": "Enable web client response caching", + "OptionDisableForDevelopmentHelp": "Disable these for web client development purposes", + "OptionEnableWebClientResourceMinification": "Enable web client resource minification", + "LabelDashboardSourcePath": "Web client source path:", + "LabelDashboardSourcePathHelp": "If running the server from source, specify the path to the dashboard-ui folder. All web client files will be served from this location.", "ButtonOk": "Ok", "ButtonCancel": "Cancel", "ButtonNew": "New", @@ -47,6 +53,7 @@ "HeaderAudio": "Audio", "HeaderVideo": "Video", "HeaderPaths": "Paths", + "ButtonDonateWithPayPal": "Donate with PayPal", "OptionDetectArchiveFilesAsMedia": "Detect archive files as media", "OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.", "LabelEnterConnectUserName": "User name or email:", @@ -1308,7 +1315,7 @@ "MessageNoTrailersFound": "No trailers found. Install the Trailer channel to enhance your movie experience by adding a library of internet trailers.", "HeaderNewUsers": "New Users", "ButtonSignUp": "Sign up", - "ButtonForgotPassword": "Forgot password?", + "ButtonForgotPassword": "Forgot password", "OptionDisableUserPreferences": "Disable access to user preferences", "OptionDisableUserPreferencesHelp": "If enabled, only administrators will be able to configure user profile images, passwords, and language preferences.", "HeaderSelectServer": "Select Server", diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 02c5aedd57..a233fe9121 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -702,8 +702,8 @@ namespace MediaBrowser.Server.Implementations.Sync var mediaSources = hasMediaSources.GetMediaSources(false).ToList(); var preferredAudio = string.IsNullOrEmpty(user.Configuration.AudioLanguagePreference) - ? new string[] { } - : new[] { user.Configuration.AudioLanguagePreference }; + ? new string[] { } + : new[] { user.Configuration.AudioLanguagePreference }; var preferredSubs = string.IsNullOrEmpty(user.Configuration.SubtitleLanguagePreference) ? new List { } diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index b1d6a3cf85..dcafa94171 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -134,7 +134,7 @@ namespace MediaBrowser.WebDashboard.Api { var page = ServerEntryPoint.Instance.PluginConfigurationPages.First(p => p.Name.Equals(request.Name, StringComparison.OrdinalIgnoreCase)); - return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml(page.GetHtmlStream(), null)); + return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml(page.GetHtmlStream(), null, false)); } /// @@ -249,8 +249,10 @@ namespace MediaBrowser.WebDashboard.Api /// Task{Stream}. private Task GetResourceStream(string path, string localizationCulture) { + var minify = _serverConfigurationManager.Configuration.EnableDashboardResourceMinification; + return GetPackageCreator() - .GetResource(path, localizationCulture, _appHost.ApplicationVersion.ToString()); + .GetResource(path, localizationCulture, _appHost.ApplicationVersion.ToString(), minify); } private PackageCreator GetPackageCreator() @@ -321,7 +323,7 @@ namespace MediaBrowser.WebDashboard.Api private async Task DumpFile(string resourceVirtualPath, string destinationFilePath, string culture, string appVersion) { - using (var stream = await GetPackageCreator().GetResource(resourceVirtualPath, culture, appVersion).ConfigureAwait(false)) + using (var stream = await GetPackageCreator().GetResource(resourceVirtualPath, culture, appVersion, true).ConfigureAwait(false)) { using (var fs = _fileSystem.GetFileStream(destinationFilePath, FileMode.Create, FileAccess.Write, FileShare.Read)) { diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 8802a16222..46616043b2 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using WebMarkupMin.Core.Minifiers; +using WebMarkupMin.Core.Settings; namespace MediaBrowser.WebDashboard.Api { @@ -30,9 +31,9 @@ namespace MediaBrowser.WebDashboard.Api _jsonSerializer = jsonSerializer; } - public async Task GetResource(string path, + public async Task GetResource(string path, string localizationCulture, - string appVersion) + string appVersion, bool enableMinification) { var isHtml = IsHtml(path); @@ -40,11 +41,11 @@ namespace MediaBrowser.WebDashboard.Api if (path.Equals("scripts/all.js", StringComparison.OrdinalIgnoreCase)) { - resourceStream = await GetAllJavascript(localizationCulture, appVersion).ConfigureAwait(false); + resourceStream = await GetAllJavascript(localizationCulture, appVersion, enableMinification).ConfigureAwait(false); } else if (path.Equals("css/all.css", StringComparison.OrdinalIgnoreCase)) { - resourceStream = await GetAllCss().ConfigureAwait(false); + resourceStream = await GetAllCss(enableMinification).ConfigureAwait(false); } else { @@ -57,7 +58,7 @@ namespace MediaBrowser.WebDashboard.Api // jQuery ajax doesn't seem to handle if-modified-since correctly if (isHtml) { - resourceStream = await ModifyHtml(resourceStream, localizationCulture).ConfigureAwait(false); + resourceStream = await ModifyHtml(resourceStream, localizationCulture, enableMinification).ConfigureAwait(false); } } @@ -106,8 +107,9 @@ namespace MediaBrowser.WebDashboard.Api /// /// The source stream. /// The localization culture. + /// if set to true [enable minification]. /// Task{Stream}. - public async Task ModifyHtml(Stream sourceStream, string localizationCulture) + public async Task ModifyHtml(Stream sourceStream, string localizationCulture, bool enableMinification) { using (sourceStream) { @@ -128,16 +130,27 @@ namespace MediaBrowser.WebDashboard.Api html = html.Replace("", ""); } - //try - //{ - // var minifier = new HtmlMinifier(new HtmlMinificationSettings(true)); + if (enableMinification) + { + try + { + var minifier = new HtmlMinifier(new HtmlMinificationSettings()); + var result = minifier.Minify(html, false); - // html = minifier.Minify(html).MinifiedContent; - //} - //catch (Exception ex) - //{ - // Logger.ErrorException("Error minifying html", ex); - //} + if (result.Errors.Count > 0) + { + _logger.Error("Error minifying html: " + result.Errors[0].Message); + } + else + { + html = result.MinifiedContent; + } + } + catch (Exception ex) + { + _logger.ErrorException("Error minifying html", ex); + } + } } var version = GetType().Assembly.GetName().Version; @@ -221,7 +234,6 @@ namespace MediaBrowser.WebDashboard.Api var files = new[] { "scripts/all.js" + versionString, - "thirdparty/jstree3.0.8/jstree.min.js", "thirdparty/swipebox-master/js/jquery.swipebox.min.js" + versionString }; @@ -236,7 +248,7 @@ namespace MediaBrowser.WebDashboard.Api /// Gets a stream containing all concatenated javascript /// /// Task{Stream}. - private async Task GetAllJavascript(string culture, string version) + private async Task GetAllJavascript(string culture, string version, bool enableMinification) { var memoryStream = new MemoryStream(); var newLineBytes = Encoding.UTF8.GetBytes(Environment.NewLine); @@ -250,6 +262,8 @@ namespace MediaBrowser.WebDashboard.Api await AppendResource(memoryStream, "thirdparty/cast_sender.js", newLineBytes).ConfigureAwait(false); await AppendResource(memoryStream, "thirdparty/browser.js", newLineBytes).ConfigureAwait(false); + await AppendResource(memoryStream, "thirdparty/jstree3.0.8/jstree.js", newLineBytes).ConfigureAwait(false); + await AppendLocalization(memoryStream, culture).ConfigureAwait(false); await memoryStream.WriteAsync(newLineBytes, 0, newLineBytes.Length).ConfigureAwait(false); @@ -304,15 +318,25 @@ namespace MediaBrowser.WebDashboard.Api var js = builder.ToString(); - try + if (enableMinification) { - var result = new CrockfordJsMinifier().Minify(js, false, Encoding.UTF8); + try + { + var result = new CrockfordJsMinifier().Minify(js, false, Encoding.UTF8); - js = result.MinifiedContent; - } - catch (Exception ex) - { - _logger.ErrorException("Error minifying javascript", ex); + if (result.Errors.Count > 0) + { + _logger.Error("Error minifying javascript: " + result.Errors[0].Message); + } + else + { + js = result.MinifiedContent; + } + } + catch (Exception ex) + { + _logger.ErrorException("Error minifying javascript", ex); + } } var bytes = Encoding.UTF8.GetBytes(js); @@ -518,7 +542,7 @@ namespace MediaBrowser.WebDashboard.Api /// Gets all CSS. /// /// Task{Stream}. - private async Task GetAllCss() + private async Task GetAllCss(bool enableMinification) { var files = new[] { @@ -561,16 +585,26 @@ namespace MediaBrowser.WebDashboard.Api var css = builder.ToString(); - //try - //{ - // var result = new KristensenCssMinifier().Minify(builder.ToString(), false, Encoding.UTF8); + if (enableMinification) + { + try + { + var result = new KristensenCssMinifier().Minify(builder.ToString(), false, Encoding.UTF8); - // css = result.MinifiedContent; - //} - //catch (Exception ex) - //{ - // Logger.ErrorException("Error minifying css", ex); - //} + if (result.Errors.Count > 0) + { + _logger.Error("Error minifying css: " + result.Errors[0].Message); + } + else + { + css = result.MinifiedContent; + } + } + catch (Exception ex) + { + _logger.ErrorException("Error minifying css", ex); + } + } var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(css)); diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 1399c9f8af..dbc701b6db 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -90,6 +90,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -2152,11 +2155,6 @@ PreserveNewest - - - PreserveNewest - - PreserveNewest