diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 4cf97d48b..cf84b839f 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1186,15 +1186,8 @@ namespace MediaBrowser.Api.Playback if (bitrate.HasValue) { - var hasFixedResolution = state.VideoRequest.HasFixedResolution; - if (string.Equals(videoCodec, "libvpx", StringComparison.OrdinalIgnoreCase)) { - if (hasFixedResolution) - { - return string.Format(" -minrate:v ({0}*.90) -maxrate:v ({0}*1.10) -bufsize:v {0} -b:v {0}", bitrate.Value.ToString(UsCulture)); - } - // With vpx when crf is used, b:v becomes a max rate // https://trac.ffmpeg.org/wiki/vpxEncodingGuide. But higher bitrate source files -b:v causes judder so limite the bitrate but dont allow it to "saturate" the bitrate. So dont contrain it down just up. return string.Format(" -maxrate:v {0} -bufsize:v ({0}*2) -b:v {0}", bitrate.Value.ToString(UsCulture)); @@ -1205,36 +1198,15 @@ namespace MediaBrowser.Api.Playback return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); } - // h264_qsv - if (string.Equals(videoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "libnvenc", StringComparison.OrdinalIgnoreCase)) + // h264 + if (isHls) { - if (hasFixedResolution) - { - if (isHls) - { - return string.Format(" -b:v {0} -maxrate ({0}*.80) -bufsize {0}", bitrate.Value.ToString(UsCulture)); - } - - return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); - } - - return string.Format(" -b:v {0} -maxrate ({0}*1.2) -bufsize ({0}*2)", bitrate.Value.ToString(UsCulture)); + return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", + bitrate.Value.ToString(UsCulture), + (bitrate.Value * 2).ToString(UsCulture)); } - // H264 - if (hasFixedResolution) - { - if (isHls) - { - return string.Format(" -b:v {0} -maxrate ({0}*.80) -bufsize {0}", bitrate.Value.ToString(UsCulture)); - } - - return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); - } - - return string.Format(" -maxrate {0} -bufsize {1}", - bitrate.Value.ToString(UsCulture), - (bitrate.Value * 2).ToString(UsCulture)); + return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); } return string.Empty; diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 48d674432..86aae959d 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -818,7 +818,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager { if ((int) statusCode == 429) { - client.LastTimeout = DateTime.UtcNow; + throw new HttpException(response.StatusDescription) + { + IsTimedOut = true + }; } if (statusCode == HttpStatusCode.RequestEntityTooLarge) diff --git a/MediaBrowser.Controller/Providers/MetadataStatus.cs b/MediaBrowser.Controller/Providers/MetadataStatus.cs index f395dabf1..9b946aee2 100644 --- a/MediaBrowser.Controller/Providers/MetadataStatus.cs +++ b/MediaBrowser.Controller/Providers/MetadataStatus.cs @@ -40,12 +40,6 @@ namespace MediaBrowser.Controller.Providers /// The date last images refresh. public DateTime? DateLastImagesRefresh { get; set; } - /// - /// Gets or sets the last result. - /// - /// The last result. - public ProviderRefreshStatus LastStatus { get; set; } - /// /// Gets or sets the last result error message. /// @@ -54,26 +48,12 @@ namespace MediaBrowser.Controller.Providers public DateTime? ItemDateModified { get; set; } - public void AddStatus(ProviderRefreshStatus status, string errorMessage) + public void AddStatus(string errorMessage) { - if (LastStatus != status) - { - IsDirty = true; - } - if (string.IsNullOrEmpty(LastErrorMessage)) { LastErrorMessage = errorMessage; } - if (LastStatus == ProviderRefreshStatus.Success) - { - LastStatus = status; - } - } - - public MetadataStatus() - { - LastStatus = ProviderRefreshStatus.Success; } public bool IsDirty { get; private set; } diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index aa8efbde2..ba44ed7dd 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -50,7 +50,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { get { - return Path.Combine(_appPaths.CachePath, "subtitles"); + return Path.Combine(_appPaths.DataPath, "subtitles"); } } diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 0335c43f0..fb6864f15 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -286,7 +286,7 @@ namespace MediaBrowser.Model.Dlna } else { - _logger.Debug("Profile: {0}, No direct play profiles found for Path: {1}", + _logger.Info("Profile: {0}, No direct play profiles found for Path: {1}", options.Profile.Name ?? "Unknown Profile", item.Path ?? "Unknown path"); } @@ -365,7 +365,7 @@ namespace MediaBrowser.Model.Dlna bool isEligibleForDirectPlay = IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options), subtitleStream, options, PlayMethod.DirectPlay); bool isEligibleForDirectStream = IsEligibleForDirectPlay(item, options.GetMaxBitrate(), subtitleStream, options, PlayMethod.DirectStream); - _logger.Debug("Profile: {0}, Path: {1}, isEligibleForDirectPlay: {2}, isEligibleForDirectStream: {3}", + _logger.Info("Profile: {0}, Path: {1}, isEligibleForDirectPlay: {2}, isEligibleForDirectStream: {3}", options.Profile.Name ?? "Unknown Profile", item.Path ?? "Unknown path", isEligibleForDirectPlay, @@ -538,7 +538,7 @@ namespace MediaBrowser.Model.Dlna if (directPlay == null) { - _logger.Debug("Profile: {0}, No direct play profiles found for Path: {1}", + _logger.Info("Profile: {0}, No direct play profiles found for Path: {1}", profile.Name ?? "Unknown Profile", mediaSource.Path ?? "Unknown path"); @@ -598,7 +598,7 @@ namespace MediaBrowser.Model.Dlna if (string.IsNullOrEmpty(videoCodec)) { - _logger.Debug("Profile: {0}, DirectPlay=false. Reason=Unknown video codec. Path: {1}", + _logger.Info("Profile: {0}, DirectPlay=false. Reason=Unknown video codec. Path: {1}", profile.Name ?? "Unknown Profile", mediaSource.Path ?? "Unknown path"); @@ -633,7 +633,7 @@ namespace MediaBrowser.Model.Dlna if (string.IsNullOrEmpty(audioCodec)) { - _logger.Debug("Profile: {0}, DirectPlay=false. Reason=Unknown audio codec. Path: {1}", + _logger.Info("Profile: {0}, DirectPlay=false. Reason=Unknown audio codec. Path: {1}", profile.Name ?? "Unknown Profile", mediaSource.Path ?? "Unknown path"); @@ -693,7 +693,7 @@ namespace MediaBrowser.Model.Dlna private void LogConditionFailure(DeviceProfile profile, string type, ProfileCondition condition, MediaSourceInfo mediaSource) { - _logger.Debug("Profile: {0}, DirectPlay=false. Reason={1}.{2} Condition: {3}. ConditionValue: {4}. IsRequired: {5}. Path: {6}", + _logger.Info("Profile: {0}, DirectPlay=false. Reason={1}.{2} Condition: {3}. ConditionValue: {4}. IsRequired: {5}. Path: {6}", type, profile.Name ?? "Unknown Profile", condition.Property, @@ -715,7 +715,7 @@ namespace MediaBrowser.Model.Dlna if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed) { - _logger.Debug("Not eligible for {0} due to unsupported subtitles", playMethod); + _logger.Info("Not eligible for {0} due to unsupported subtitles", playMethod); return false; } } @@ -794,7 +794,7 @@ namespace MediaBrowser.Model.Dlna return true; } - _logger.Debug("Bitrate exceeds DirectPlay limit"); + _logger.Info("Bitrate exceeds DirectPlay limit"); return false; } diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs index 266d94f12..b39deba89 100644 --- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs +++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs @@ -164,7 +164,6 @@ namespace MediaBrowser.Providers.Manager catch (Exception ex) { result.ErrorMessage = ex.Message; - result.Status = ProviderRefreshStatus.CompletedWithErrors; _logger.ErrorException("Error in {0}", ex, provider.Name); } } @@ -303,7 +302,6 @@ namespace MediaBrowser.Providers.Manager catch (Exception ex) { result.ErrorMessage = ex.Message; - result.Status = ProviderRefreshStatus.CompletedWithErrors; _logger.ErrorException("Error in {0}", ex, provider.Name); } } diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index e07c7e3c7..f40f17588 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -98,7 +98,6 @@ namespace MediaBrowser.Providers.Manager var updateType = ItemUpdateType.None; var refreshResult = GetLastResult(item); refreshResult.LastErrorMessage = string.Empty; - refreshResult.LastStatus = ProviderRefreshStatus.Success; var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem); var localImagesFailed = false; @@ -118,7 +117,7 @@ namespace MediaBrowser.Providers.Manager { localImagesFailed = true; Logger.ErrorException("Error validating images for {0}", ex, item.Path ?? item.Name ?? "Unknown name"); - refreshResult.AddStatus(ProviderRefreshStatus.Failure, ex.Message); + refreshResult.AddStatus(ex.Message); } var metadataResult = new MetadataResult @@ -148,7 +147,7 @@ namespace MediaBrowser.Providers.Manager var result = await RefreshWithProviders(metadataResult, id, refreshOptions, providers, itemImageProvider, cancellationToken).ConfigureAwait(false); updateType = updateType | result.UpdateType; - refreshResult.AddStatus(result.Status, result.ErrorMessage); + refreshResult.AddStatus(result.ErrorMessage); if (result.Failures == 0) { refreshResult.SetDateLastMetadataRefresh(DateTime.UtcNow); @@ -170,7 +169,7 @@ namespace MediaBrowser.Providers.Manager var result = await itemImageProvider.RefreshImages(itemOfType, providers, refreshOptions, config, cancellationToken).ConfigureAwait(false); updateType = updateType | result.UpdateType; - refreshResult.AddStatus(result.Status, result.ErrorMessage); + refreshResult.AddStatus(result.ErrorMessage); if (result.Failures == 0) { refreshResult.SetDateLastImagesRefresh(DateTime.UtcNow); @@ -375,8 +374,6 @@ namespace MediaBrowser.Providers.Manager Item = CreateNew() }; temp.Item.Path = item.Path; - var successfulProviderCount = 0; - var failedProviderCount = 0; var userDataList = new List(); @@ -387,10 +384,8 @@ namespace MediaBrowser.Providers.Manager .ConfigureAwait(false); refreshResult.UpdateType = refreshResult.UpdateType | remoteResult.UpdateType; - refreshResult.Status = remoteResult.Status; refreshResult.ErrorMessage = remoteResult.ErrorMessage; - successfulProviderCount += remoteResult.Successes; - failedProviderCount += remoteResult.Failures; + refreshResult.Failures += remoteResult.Failures; } var hasLocalMetadata = false; @@ -426,7 +421,6 @@ namespace MediaBrowser.Providers.Manager { hasLocalMetadata = true; } - successfulProviderCount++; break; } @@ -438,12 +432,11 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - failedProviderCount++; + refreshResult.Failures++; Logger.ErrorException("Error in {0}", ex, provider.Name); // If a local provider fails, consider that a failure - refreshResult.Status = ProviderRefreshStatus.Failure; refreshResult.ErrorMessage = ex.Message; if (options.MetadataRefreshMode != MetadataRefreshMode.FullRefresh) @@ -461,12 +454,8 @@ namespace MediaBrowser.Providers.Manager .ConfigureAwait(false); refreshResult.UpdateType = refreshResult.UpdateType | remoteResult.UpdateType; - if (remoteResult.Status != ProviderRefreshStatus.Success) - { - refreshResult.Status = remoteResult.Status; - refreshResult.ErrorMessage = remoteResult.ErrorMessage; - } - successfulProviderCount += remoteResult.Successes; + refreshResult.ErrorMessage = remoteResult.ErrorMessage; + refreshResult.Failures += remoteResult.Failures; } if (providers.Any(i => !(i is ICustomMetadataProvider))) @@ -534,7 +523,6 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - refreshResult.Status = ProviderRefreshStatus.Failure; refreshResult.ErrorMessage = ex.Message; Logger.ErrorException("Error in {0}", ex, provider.Name); } @@ -570,8 +558,6 @@ namespace MediaBrowser.Providers.Manager MergeData(result, temp, new List(), false, false); refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataDownload; - - refreshResult.Successes++; } else { @@ -586,7 +572,6 @@ namespace MediaBrowser.Providers.Manager catch (Exception ex) { refreshResult.Failures++; - refreshResult.Status = ProviderRefreshStatus.CompletedWithErrors; refreshResult.ErrorMessage = ex.Message; Logger.ErrorException("Error in {0}", ex, provider.Name); } @@ -667,10 +652,8 @@ namespace MediaBrowser.Providers.Manager public class RefreshResult { public ItemUpdateType UpdateType { get; set; } - public ProviderRefreshStatus Status { get; set; } public string ErrorMessage { get; set; } public List Providers { get; set; } - public int Successes { get; set; } public int Failures { get; set; } } } diff --git a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs index f8763b847..30aa35924 100644 --- a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs @@ -110,7 +110,10 @@ namespace MediaBrowser.Providers.Omdb if (isSearch) { var searchResultList = _jsonSerializer.DeserializeFromStream(stream); - resultList.AddRange(searchResultList.Search); + if (searchResultList != null && searchResultList.Search != null) + { + resultList.AddRange(searchResultList.Search); + } } else { diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs index fb36b5947..26cde925e 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs @@ -124,15 +124,19 @@ namespace MediaBrowser.Server.Implementations.Library.Validators var item = _libraryManager.GetPerson(person.Key); validIds.Add(item.Id); - + var options = new MetadataRefreshOptions(_fileSystem) { - MetadataRefreshMode = person.Value ? MetadataRefreshMode.Default : MetadataRefreshMode.ValidationOnly, - ImageRefreshMode = person.Value ? ImageRefreshMode.Default : ImageRefreshMode.ValidationOnly + MetadataRefreshMode = person.Value ? MetadataRefreshMode.Default : MetadataRefreshMode.ValidationOnly, + ImageRefreshMode = person.Value ? ImageRefreshMode.Default : ImageRefreshMode.ValidationOnly }; await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false); } + catch (OperationCanceledException) + { + throw; + } catch (Exception ex) { _logger.ErrorException("Error validating IBN entry {0}", ex, person); diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index e8ba12635..67692a9ae 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -375,6 +375,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun protected override bool IsValidChannelId(string channelId) { + if (string.IsNullOrWhiteSpace(channelId)) + { + throw new ArgumentNullException("channelId"); + } + return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase); } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteProviderInfoRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteProviderInfoRepository.cs index bce33e834..e7853b458 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteProviderInfoRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteProviderInfoRepository.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.Persistence string[] queries = { - "create table if not exists MetadataStatus (ItemId GUID PRIMARY KEY, ItemName TEXT, ItemType TEXT, SeriesName TEXT, DateLastMetadataRefresh datetime, DateLastImagesRefresh datetime, LastStatus TEXT, LastErrorMessage TEXT, MetadataProvidersRefreshed TEXT, ImageProvidersRefreshed TEXT, ItemDateModified DateTimeNull)", + "create table if not exists MetadataStatus (ItemId GUID PRIMARY KEY, ItemName TEXT, ItemType TEXT, SeriesName TEXT, DateLastMetadataRefresh datetime, DateLastImagesRefresh datetime, LastErrorMessage TEXT, ItemDateModified DateTimeNull)", "create index if not exists idx_MetadataStatus on MetadataStatus(ItemId)", //pragmas @@ -71,10 +71,7 @@ namespace MediaBrowser.Server.Implementations.Persistence "SeriesName", "DateLastMetadataRefresh", "DateLastImagesRefresh", - "LastStatus", "LastErrorMessage", - "MetadataProvidersRefreshed", - "ImageProvidersRefreshed", "ItemDateModified" }; @@ -188,19 +185,12 @@ namespace MediaBrowser.Server.Implementations.Persistence if (!reader.IsDBNull(6)) { - result.LastStatus = (ProviderRefreshStatus)Enum.Parse(typeof(ProviderRefreshStatus), reader.GetString(6), true); + result.LastErrorMessage = reader.GetString(6); } if (!reader.IsDBNull(7)) { - result.LastErrorMessage = reader.GetString(7); - } - - // Skip metadata and image providers - - if (!reader.IsDBNull(10)) - { - result.ItemDateModified = reader.GetDateTime(10).ToUniversalTime(); + result.ItemDateModified = reader.GetDateTime(7).ToUniversalTime(); } return result; @@ -229,11 +219,8 @@ namespace MediaBrowser.Server.Implementations.Persistence _saveStatusCommand.GetParameter(3).Value = status.SeriesName; _saveStatusCommand.GetParameter(4).Value = status.DateLastMetadataRefresh; _saveStatusCommand.GetParameter(5).Value = status.DateLastImagesRefresh; - _saveStatusCommand.GetParameter(6).Value = status.LastStatus.ToString(); - _saveStatusCommand.GetParameter(7).Value = status.LastErrorMessage; - _saveStatusCommand.GetParameter(8).Value = string.Empty; - _saveStatusCommand.GetParameter(9).Value = string.Empty; - _saveStatusCommand.GetParameter(10).Value = status.ItemDateModified; + _saveStatusCommand.GetParameter(6).Value = status.LastErrorMessage; + _saveStatusCommand.GetParameter(7).Value = status.ItemDateModified; _saveStatusCommand.Transaction = transaction; diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index dbb60c3b6..f59788637 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -1975,9 +1975,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -2028,9 +2025,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest