浏览代码

fixes #979 - Support personal fanart api key

Luke Pulverenti 10 年之前
父节点
当前提交
f552174069

+ 2 - 0
MediaBrowser.Model/Configuration/ServerConfiguration.cs

@@ -149,7 +149,9 @@ namespace MediaBrowser.Model.Configuration
         /// <value><c>true</c> if [enable tv db updates]; otherwise, <c>false</c>.</value>
         public bool EnableTvDbUpdates { get; set; }
         public bool EnableTmdbUpdates { get; set; }
+
         public bool EnableFanArtUpdates { get; set; }
+        public string FanartApiKey { get; set; }
 
         /// <summary>
         /// Gets or sets the image saving convention.

+ 8 - 1
MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs

@@ -98,10 +98,17 @@ namespace MediaBrowser.Providers.Movies
 
         private async Task<IEnumerable<string>> GetMovieIdsToUpdate(IEnumerable<string> 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

+ 5 - 0
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));

+ 5 - 0
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));

+ 8 - 1
MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs

@@ -104,10 +104,17 @@ namespace MediaBrowser.Providers.Music
         /// <returns>Task{IEnumerable{System.String}}.</returns>
         private async Task<IEnumerable<string>> GetArtistIdsToUpdate(IEnumerable<string> 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

+ 8 - 1
MediaBrowser.Providers/TV/FanArtTvUpdatesPostScanTask.cs

@@ -105,10 +105,17 @@ namespace MediaBrowser.Providers.TV
         /// <returns>Task{IEnumerable{System.String}}.</returns>
         private async Task<IEnumerable<string>> GetSeriesIdsToUpdate(IEnumerable<string> 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

+ 5 - 0
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));

+ 3 - 1
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",