mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	Merge pull request #1260 from MediaBrowser/master
update movie db provider
This commit is contained in:
		
						commit
						e6329c46d1
					
				@ -160,9 +160,7 @@ namespace MediaBrowser.Providers.Movies
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                Url = string.Format(TmdbConfigUrl, ApiKey),
 | 
					                Url = string.Format(TmdbConfigUrl, ApiKey),
 | 
				
			||||||
                CancellationToken = cancellationToken,
 | 
					                CancellationToken = cancellationToken,
 | 
				
			||||||
                AcceptHeader = AcceptHeader,
 | 
					                AcceptHeader = AcceptHeader
 | 
				
			||||||
                CacheMode = CacheMode.Unconditional,
 | 
					 | 
				
			||||||
                CacheLength = TimeSpan.FromDays(1)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }).ConfigureAwait(false))
 | 
					            }).ConfigureAwait(false))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -368,27 +366,14 @@ namespace MediaBrowser.Providers.Movies
 | 
				
			|||||||
            return mainResult;
 | 
					            return mainResult;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static long _lastRequestTicks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Gets the movie db response.
 | 
					        /// Gets the movie db response.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        internal async Task<Stream> GetMovieDbResponse(HttpRequestOptions options)
 | 
					        internal Task<Stream> GetMovieDbResponse(HttpRequestOptions options)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var requestIntervalMs = 250;
 | 
					 | 
				
			||||||
            var delayTicks = (requestIntervalMs * 10000) - (DateTime.UtcNow.Ticks - _lastRequestTicks);
 | 
					 | 
				
			||||||
            var delayMs = Math.Min(delayTicks / 10000, requestIntervalMs);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (delayMs > 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                _logger.Debug("Throttling Tmdb by {0} ms", delayMs);
 | 
					 | 
				
			||||||
                await Task.Delay(Convert.ToInt32(delayMs)).ConfigureAwait(false);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            options.ResourcePool = MovieDbResourcePool;
 | 
					            options.ResourcePool = MovieDbResourcePool;
 | 
				
			||||||
            _lastRequestTicks = DateTime.UtcNow.Ticks;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return await _httpClient.Get(options).ConfigureAwait(false);
 | 
					            return _httpClient.Get(options);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public TheMovieDbOptions GetTheMovieDbOptions()
 | 
					        public TheMovieDbOptions GetTheMovieDbOptions()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user