From f55217406985ad21da44aa523353f33e3f720ccd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 12 Jan 2015 02:01:19 -0500 Subject: [PATCH] fixes #979 - Support personal fanart api key --- MediaBrowser.Model/Configuration/ServerConfiguration.cs | 2 ++ .../Movies/FanArtMovieUpdatesPostScanTask.cs | 9 ++++++++- .../Movies/FanartMovieImageProvider.cs | 5 +++++ MediaBrowser.Providers/Music/FanArtArtistProvider.cs | 5 +++++ .../Music/FanArtUpdatesPostScanTask.cs | 9 ++++++++- MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs | 9 ++++++++- MediaBrowser.Providers/TV/FanartSeriesProvider.cs | 5 +++++ .../Localization/Server/server.json | 4 +++- 8 files changed, 44 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index f9c5c65674..e30cf1789d 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -149,7 +149,9 @@ namespace MediaBrowser.Model.Configuration /// true if [enable tv db updates]; otherwise, false. public bool EnableTvDbUpdates { get; set; } public bool EnableTmdbUpdates { get; set; } + public bool EnableFanArtUpdates { get; set; } + public string FanartApiKey { get; set; } /// /// Gets or sets the image saving convention. diff --git a/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs b/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs index 2936fec0ec..2f3d8ceeae 100644 --- a/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs +++ b/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs @@ -98,10 +98,17 @@ namespace MediaBrowser.Providers.Movies private async Task> GetMovieIdsToUpdate(IEnumerable existingIds, string lastUpdateTime, CancellationToken cancellationToken) { + var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); + + if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + { + url += "&client_key=" + _config.Configuration.FanartApiKey; + } + // First get last time using (var stream = await _httpClient.Get(new HttpRequestOptions { - Url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime), + Url = url, CancellationToken = cancellationToken, EnableHttpCompression = true, ResourcePool = FanartArtistProvider.Current.FanArtResourcePool diff --git a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs index 6813f2ff5e..91d8830e60 100644 --- a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs +++ b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs @@ -283,6 +283,11 @@ namespace MediaBrowser.Providers.Movies var url = string.Format(FanArtBaseUrl, FanartArtistProvider.ApiKey, id); + if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + { + url += "&client_key=" + _config.Configuration.FanartApiKey; + } + var path = GetFanartJsonPath(id); Directory.CreateDirectory(Path.GetDirectoryName(path)); diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs index 6f633cfc87..6bb4b0aeff 100644 --- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs @@ -423,6 +423,11 @@ namespace MediaBrowser.Providers.Music var url = string.Format(FanArtBaseUrl, ApiKey, musicBrainzId); + if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + { + url += "&client_key=" + _config.Configuration.FanartApiKey; + } + var xmlPath = GetArtistXmlPath(_config.ApplicationPaths, musicBrainzId); Directory.CreateDirectory(Path.GetDirectoryName(xmlPath)); diff --git a/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs b/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs index 4c6706287c..703153e319 100644 --- a/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs +++ b/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs @@ -104,10 +104,17 @@ namespace MediaBrowser.Providers.Music /// Task{IEnumerable{System.String}}. private async Task> GetArtistIdsToUpdate(IEnumerable existingArtistIds, string lastUpdateTime, CancellationToken cancellationToken) { + var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); + + if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + { + url += "&client_key=" + _config.Configuration.FanartApiKey; + } + // First get last time using (var stream = await _httpClient.Get(new HttpRequestOptions { - Url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime), + Url = url, CancellationToken = cancellationToken, EnableHttpCompression = true, ResourcePool = FanartArtistProvider.Current.FanArtResourcePool diff --git a/MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs b/MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs index 13920d942d..567f3b5daa 100644 --- a/MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs +++ b/MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs @@ -105,10 +105,17 @@ namespace MediaBrowser.Providers.TV /// Task{IEnumerable{System.String}}. private async Task> GetSeriesIdsToUpdate(IEnumerable existingSeriesIds, string lastUpdateTime, CancellationToken cancellationToken) { + var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); + + if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + { + url += "&client_key=" + _config.Configuration.FanartApiKey; + } + // First get last time using (var stream = await _httpClient.Get(new HttpRequestOptions { - Url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime), + Url = url, CancellationToken = cancellationToken, EnableHttpCompression = true, ResourcePool = FanartArtistProvider.Current.FanArtResourcePool diff --git a/MediaBrowser.Providers/TV/FanartSeriesProvider.cs b/MediaBrowser.Providers/TV/FanartSeriesProvider.cs index 8ba25e9f1f..f95b6b2c68 100644 --- a/MediaBrowser.Providers/TV/FanartSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/FanartSeriesProvider.cs @@ -295,6 +295,11 @@ namespace MediaBrowser.Providers.TV var url = string.Format(FanArtBaseUrl, FanartArtistProvider.ApiKey, tvdbId); + if (!string.IsNullOrWhiteSpace(_config.Configuration.FanartApiKey)) + { + url += "&client_key=" + _config.Configuration.FanartApiKey; + } + var path = GetFanartJsonPath(tvdbId); Directory.CreateDirectory(Path.GetDirectoryName(path)); diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 1935fba93d..e3add2f19b 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -314,12 +314,14 @@ "OptionEpisodes": "Episodes", "OptionOtherVideos": "Other Videos", "TitleMetadata": "Metadata", - "LabelAutomaticUpdatesFanart": "Enable automatic updates from FanArt.tv", + "LabelAutomaticUpdates": "Enable automatic updates", "LabelAutomaticUpdatesTmdb": "Enable automatic updates from TheMovieDB.org", "LabelAutomaticUpdatesTvdb": "Enable automatic updates from TheTVDB.com", "LabelAutomaticUpdatesFanartHelp": "If enabled, new images will be downloaded automatically as they're added to fanart.tv. Existing images will not be replaced.", "LabelAutomaticUpdatesTmdbHelp": "If enabled, new images will be downloaded automatically as they're added to TheMovieDB.org. Existing images will not be replaced.", "LabelAutomaticUpdatesTvdbHelp": "If enabled, new images will be downloaded automatically as they're added to TheTVDB.com. Existing images will not be replaced.", + "LabelFanartApiKey": "Personal api key:", + "LabelFanartApiKeyHelp": "Requests to fanart without a personal API key return results that were approved over 7 days ago. With a personal API key that drops to 48 hours and if you are also a fanart VIP member that will further drop to around 10 minutes.", "ExtractChapterImagesHelp": "Extracting chapter images will allow clients to display graphical scene selection menus. The process can be slow, cpu-intensive and may require several gigabytes of space. It runs when videos are discovered, and also as a nightly scheduled task at 4am. The schedule is configurable in the scheduled tasks area. It is not recommended to run this task during peak usage hours.", "LabelMetadataDownloadLanguage": "Preferred download language:", "ButtonAutoScroll": "Auto-scroll",