From e56faea17a9c300299a6b088ca399abe4351b472 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 9 Apr 2017 17:38:59 -0400 Subject: update vsync --- MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs index 98adb6e20..f74dbce98 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs @@ -57,7 +57,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private readonly IMediaSourceManager _mediaSourceManager; public EncodingJob(ILogger logger, IMediaSourceManager mediaSourceManager) : - base(logger) + base(logger, TranscodingJobType.Progressive) { _logger = logger; _mediaSourceManager = mediaSourceManager; -- cgit v1.2.3 From 4154fdf9c6ad6256467790032771c2475432217c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 12 Apr 2017 13:09:12 -0400 Subject: update omdb info parsing --- Emby.Drawing/ImageProcessor.cs | 33 ++------- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 47 ++++--------- MediaBrowser.Providers/Omdb/OmdbProvider.cs | 78 ++++++++++------------ .../Providers/BaseNfoProvider.cs | 5 -- 4 files changed, 50 insertions(+), 113 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 5b04ceea2..f19e3e037 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -57,7 +57,6 @@ namespace Emby.Drawing private readonly IJsonSerializer _jsonSerializer; private readonly IServerApplicationPaths _appPaths; private readonly IImageEncoder _imageEncoder; - private readonly SemaphoreSlim _imageProcessingSemaphore; private readonly Func _libraryManager; public ImageProcessor(ILogger logger, @@ -102,8 +101,6 @@ namespace Emby.Drawing } _cachedImagedSizes = new ConcurrentDictionary(sizeDictionary); - _logger.Info("ImageProcessor started with {0} max concurrent image processes", maxConcurrentImageProcesses); - _imageProcessingSemaphore = new SemaphoreSlim(maxConcurrentImageProcesses, maxConcurrentImageProcesses); } public string[] SupportedInputFormats @@ -238,8 +235,6 @@ namespace Emby.Drawing var outputFormat = GetOutputFormat(options.SupportedOutputFormats[0]); var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, outputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.UnplayedCount, options.Blur, options.BackgroundColor, options.ForegroundLayer); - //var imageProcessingLockTaken = false; - try { CheckDisposed(); @@ -253,10 +248,6 @@ namespace Emby.Drawing var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath)); _fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath)); - //await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); - - //imageProcessingLockTaken = true; - _imageEncoder.EncodeImage(originalImagePath, tmpPath, AutoOrient(options.Item), newWidth, newHeight, quality, options, outputFormat); CopyFile(tmpPath, cacheFilePath); @@ -273,13 +264,6 @@ namespace Emby.Drawing // Just spit out the original file if all the options are default return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); } - //finally - //{ - // if (imageProcessingLockTaken) - // { - // _imageProcessingSemaphore.Release(); - // } - //} } private void CopyFile(string src, string destination) @@ -786,24 +770,15 @@ namespace Emby.Drawing var tmpPath = Path.Combine(_appPaths.TempDirectory, Path.ChangeExtension(Guid.NewGuid().ToString(), Path.GetExtension(enhancedImagePath))); _fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath)); - await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); + await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, tmpPath, item, imageType, imageIndex).ConfigureAwait(false); try { - await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, tmpPath, item, imageType, imageIndex).ConfigureAwait(false); - - try - { - _fileSystem.CopyFile(tmpPath, enhancedImagePath, true); - } - catch - { - - } + _fileSystem.CopyFile(tmpPath, enhancedImagePath, true); } - finally + catch { - _imageProcessingSemaphore.Release(); + } return tmpPath; diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 97f2c57eb..af826f231 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -49,16 +49,6 @@ namespace MediaBrowser.MediaEncoding.Encoder /// private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim(1, 1); - /// - /// The video image resource pool - /// - private readonly SemaphoreSlim _videoImageResourcePool = new SemaphoreSlim(1, 1); - - /// - /// The audio image resource pool - /// - private readonly SemaphoreSlim _audioImageResourcePool = new SemaphoreSlim(2, 2); - /// /// The FF probe resource pool /// @@ -724,8 +714,6 @@ namespace MediaBrowser.MediaEncoding.Encoder private async Task ExtractImage(string[] inputFiles, string container, int? imageStreamIndex, MediaProtocol protocol, bool isAudio, Video3DFormat? threedFormat, TimeSpan? offset, CancellationToken cancellationToken) { - var resourcePool = isAudio ? _audioImageResourcePool : _videoImageResourcePool; - var inputArgument = GetInputArgument(inputFiles, protocol); if (isAudio) @@ -740,7 +728,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { try { - return await ExtractImageInternal(inputArgument, container, imageStreamIndex, protocol, threedFormat, offset, true, resourcePool, cancellationToken).ConfigureAwait(false); + return await ExtractImageInternal(inputArgument, container, imageStreamIndex, protocol, threedFormat, offset, true, cancellationToken).ConfigureAwait(false); } catch (ArgumentException) { @@ -752,10 +740,10 @@ namespace MediaBrowser.MediaEncoding.Encoder } } - return await ExtractImageInternal(inputArgument, container, imageStreamIndex, protocol, threedFormat, offset, false, resourcePool, cancellationToken).ConfigureAwait(false); + return await ExtractImageInternal(inputArgument, container, imageStreamIndex, protocol, threedFormat, offset, false, cancellationToken).ConfigureAwait(false); } - private async Task ExtractImageInternal(string inputPath, string container, int? imageStreamIndex, MediaProtocol protocol, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, SemaphoreSlim resourcePool, CancellationToken cancellationToken) + private async Task ExtractImageInternal(string inputPath, string container, int? imageStreamIndex, MediaProtocol protocol, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(inputPath)) { @@ -835,31 +823,21 @@ namespace MediaBrowser.MediaEncoding.Encoder using (var processWrapper = new ProcessWrapper(process, this, _logger)) { - await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); - bool ranToCompletion; - try - { - StartProcess(processWrapper); + StartProcess(processWrapper); - var timeoutMs = ConfigurationManager.Configuration.ImageExtractionTimeoutMs; - if (timeoutMs <= 0) - { - timeoutMs = DefaultImageExtractionTimeoutMs; - } + var timeoutMs = ConfigurationManager.Configuration.ImageExtractionTimeoutMs; + if (timeoutMs <= 0) + { + timeoutMs = DefaultImageExtractionTimeoutMs; + } - ranToCompletion = process.WaitForExit(timeoutMs); + ranToCompletion = process.WaitForExit(timeoutMs); - if (!ranToCompletion) - { - StopProcess(processWrapper, 1000); - } - - } - finally + if (!ranToCompletion) { - resourcePool.Release(); + StopProcess(processWrapper, 1000); } var exitCode = ranToCompletion ? processWrapper.ExitCode ?? 0 : -1; @@ -1118,7 +1096,6 @@ namespace MediaBrowser.MediaEncoding.Encoder { if (dispose) { - _videoImageResourcePool.Dispose(); StopProcesses(); } } diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index 148bfc8a8..2c368c97b 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -14,8 +14,6 @@ using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.IO; namespace MediaBrowser.Providers.Omdb { @@ -68,21 +66,11 @@ namespace MediaBrowser.Providers.Omdb item.ProductionYear = year; } - // Seeing some bogus RT data on omdb for series, so filter it out here - // RT doesn't even have tv series - int tomatoMeter; + var tomatoScore = result.GetRottenTomatoScore(); - if (!string.IsNullOrEmpty(result.tomatoMeter) - && int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter) - && tomatoMeter >= 0) + if (tomatoScore.HasValue) { - item.CriticRating = tomatoMeter; - } - - if (!string.IsNullOrEmpty(result.tomatoConsensus) - && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase)) - { - item.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus); + item.CriticRating = tomatoScore; } int voteCount; @@ -169,21 +157,11 @@ namespace MediaBrowser.Providers.Omdb item.ProductionYear = year; } - // Seeing some bogus RT data on omdb for series, so filter it out here - // RT doesn't even have tv series - int tomatoMeter; - - if (!string.IsNullOrEmpty(result.tomatoMeter) - && int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter) - && tomatoMeter >= 0) - { - item.CriticRating = tomatoMeter; - } + var tomatoScore = result.GetRottenTomatoScore(); - if (!string.IsNullOrEmpty(result.tomatoConsensus) - && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase)) + if (tomatoScore.HasValue) { - item.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus); + item.CriticRating = tomatoScore; } int voteCount; @@ -486,39 +464,51 @@ namespace MediaBrowser.Providers.Omdb public string Year { get; set; } public string Rated { get; set; } public string Released { get; set; } - public int Episode { get; set; } public string Runtime { get; set; } public string Genre { get; set; } public string Director { get; set; } public string Writer { get; set; } public string Actors { get; set; } public string Plot { get; set; } + public string Language { get; set; } + public string Country { get; set; } + public string Awards { get; set; } public string Poster { get; set; } + public List Ratings { get; set; } + public string Metascore { get; set; } public string imdbRating { get; set; } public string imdbVotes { get; set; } public string imdbID { get; set; } public string Type { get; set; } - public string tomatoMeter { get; set; } - public string tomatoImage { get; set; } - public string tomatoRating { get; set; } - public string tomatoReviews { get; set; } - public string tomatoFresh { get; set; } - public string tomatoRotten { get; set; } - public string tomatoConsensus { get; set; } - public string tomatoUserMeter { get; set; } - public string tomatoUserRating { get; set; } - public string tomatoUserReviews { get; set; } public string DVD { get; set; } public string BoxOffice { get; set; } public string Production { get; set; } public string Website { get; set; } public string Response { get; set; } + public int Episode { get; set; } - public string Language { get; set; } - public string Country { get; set; } - public string Awards { get; set; } - public string Metascore { get; set; } + public float? GetRottenTomatoScore() + { + if (Ratings != null) + { + var rating = Ratings.FirstOrDefault(i => string.Equals(i.Source, "Rotten Tomatoes", StringComparison.OrdinalIgnoreCase)); + if (rating != null && rating.Value != null) + { + var value = rating.Value.TrimEnd('%'); + float score; + if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out score)) + { + return score; + } + } + } + return null; + } + } + public class OmdbRating + { + public string Source { get; set; } + public string Value { get; set; } } - } } diff --git a/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs b/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs index 7e37d61df..e5931cf25 100644 --- a/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs +++ b/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs @@ -78,9 +78,4 @@ namespace MediaBrowser.XbmcMetadata.Providers } } } - - static class XmlProviderUtils - { - internal static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(4, 4); - } } -- cgit v1.2.3 From 8eb4c034b44f9c414ec19e7f0ab40c2070a8cf64 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 15 Apr 2017 15:45:33 -0400 Subject: update audio sync params --- MediaBrowser.Api/MediaBrowser.Api.csproj | 1 + MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 5 + MediaBrowser.Api/Playback/Hls/VideoHlsService.cs | 8 +- MediaBrowser.Api/SuggestionsService.cs | 104 +++++++++++++++++++++ MediaBrowser.Api/TvShowsService.cs | 36 +++++-- .../Entities/Audio/MusicAlbum.cs | 33 +++++++ .../MediaEncoding/EncodingHelper.cs | 48 +++++----- .../MediaEncoding/EncodingJobInfo.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 26 ++---- 9 files changed, 207 insertions(+), 56 deletions(-) create mode 100644 MediaBrowser.Api/SuggestionsService.cs (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index c2c8d1102..0785b904a 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -134,6 +134,7 @@ + diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 43f25145e..038d76245 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -826,6 +826,11 @@ namespace MediaBrowser.Api.Playback.Hls args += " -ab " + bitrate.Value.ToString(UsCulture); } + if (state.OutputAudioSampleRate.HasValue) + { + args += " -ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture); + } + args += " " + EncodingHelper.GetAudioFilterParam(state, ApiEntryPoint.Instance.GetEncodingOptions(), true); return args; diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index 71b1dc1b1..a813d7a87 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -6,10 +6,7 @@ using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using System; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Net; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Services; @@ -60,6 +57,11 @@ namespace MediaBrowser.Api.Playback.Hls args += " -ab " + bitrate.Value.ToString(UsCulture); } + if (state.OutputAudioSampleRate.HasValue) + { + args += " -ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture); + } + args += " " + EncodingHelper.GetAudioFilterParam(state, ApiEntryPoint.Instance.GetEncodingOptions(), true); return args; diff --git a/MediaBrowser.Api/SuggestionsService.cs b/MediaBrowser.Api/SuggestionsService.cs new file mode 100644 index 000000000..7196c0f39 --- /dev/null +++ b/MediaBrowser.Api/SuggestionsService.cs @@ -0,0 +1,104 @@ +using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Net; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Querying; +using MediaBrowser.Model.Services; +using System; +using System.Linq; +using System.Threading.Tasks; +using MediaBrowser.Controller.Library; + +namespace MediaBrowser.Api +{ + [Route("/Users/{UserId}/Suggestions", "GET", Summary = "Gets items based on a query.")] + public class GetSuggestedItems : IReturn> + { + public string MediaType { get; set; } + public string Type { get; set; } + public string UserId { get; set; } + public bool EnableTotalRecordCount { get; set; } + public int? StartIndex { get; set; } + public int? Limit { get; set; } + + public string[] GetMediaTypes() + { + return (MediaType ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + } + + public string[] GetIncludeItemTypes() + { + return (Type ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + } + } + + public class SuggestionsService : BaseApiService + { + private readonly IDtoService _dtoService; + private readonly IAuthorizationContext _authContext; + private readonly IUserManager _userManager; + private readonly ILibraryManager _libraryManager; + + public SuggestionsService(IDtoService dtoService, IAuthorizationContext authContext, IUserManager userManager, ILibraryManager libraryManager) + { + _dtoService = dtoService; + _authContext = authContext; + _userManager = userManager; + _libraryManager = libraryManager; + } + + public async Task Get(GetSuggestedItems request) + { + var result = await GetResultItems(request).ConfigureAwait(false); + + return ToOptimizedResult(result); + } + + private async Task> GetResultItems(GetSuggestedItems request) + { + var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; + + var dtoOptions = GetDtoOptions(_authContext, request); + var result = GetItems(request, user, dtoOptions); + + var dtoList = await _dtoService.GetBaseItemDtos(result.Items, dtoOptions, user).ConfigureAwait(false); + + if (dtoList == null) + { + throw new InvalidOperationException("GetBaseItemDtos returned null"); + } + + return new QueryResult + { + TotalRecordCount = result.TotalRecordCount, + Items = dtoList.ToArray() + }; + } + + private QueryResult GetItems(GetSuggestedItems request, User user, DtoOptions dtoOptions) + { + var query = new InternalItemsQuery(user) + { + SortBy = new string[] { ItemSortBy.Random }, + MediaTypes = request.GetMediaTypes(), + IncludeItemTypes = request.GetIncludeItemTypes(), + IsVirtualItem = false, + StartIndex = request.StartIndex, + Limit = request.Limit, + DtoOptions = dtoOptions + }; + + if (request.EnableTotalRecordCount) + { + return _libraryManager.GetItemsResult(query); + } + + var items = _libraryManager.GetItemList(query).ToArray(); + + return new QueryResult + { + Items = items + }; + } + } +} diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 43fe74d5f..d7f017e1d 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -137,6 +137,7 @@ namespace MediaBrowser.Api } [Route("/Shows/{Id}/Episodes", "GET", Summary = "Gets episodes for a tv season")] + [Route("/Shows/Episodes", "GET", Summary = "Gets episodes for a tv season")] public class GetEpisodes : IReturn, IHasItemFields, IHasDtoOptions { /// @@ -200,9 +201,11 @@ namespace MediaBrowser.Api [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? EnableUserData { get; set; } + public string SeriesName { get; set; } } [Route("/Shows/{Id}/Seasons", "GET", Summary = "Gets seasons for a tv series")] + [Route("/Shows/Seasons", "GET", Summary = "Gets seasons for a tv series")] public class GetSeasons : IReturn, IHasItemFields, IHasDtoOptions { /// @@ -246,6 +249,7 @@ namespace MediaBrowser.Api [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? EnableUserData { get; set; } + public string SeriesName { get; set; } } /// @@ -427,11 +431,11 @@ namespace MediaBrowser.Api { var user = _userManager.GetUserById(request.UserId); - var series = _libraryManager.GetItemById(request.Id) as Series; + var series = GetSeries(request.Id, request.SeriesName, user); if (series == null) { - throw new ResourceNotFoundException("No series exists with Id " + request.Id); + throw new ResourceNotFoundException("Series not found"); } var seasons = (await series.GetItems(new InternalItemsQuery(user) @@ -455,6 +459,26 @@ namespace MediaBrowser.Api }; } + private Series GetSeries(string seriesId, string seriesName, User user) + { + if (!string.IsNullOrWhiteSpace(seriesId)) + { + return _libraryManager.GetItemById(seriesId) as Series; + } + + if (!string.IsNullOrWhiteSpace(seriesName)) + { + return _libraryManager.GetItemList(new InternalItemsQuery(user) + { + Name = seriesName, + IncludeItemTypes = new string[] { typeof(Series).Name } + + }).OfType().FirstOrDefault(); + } + + return null; + } + public async Task Get(GetEpisodes request) { var user = _userManager.GetUserById(request.UserId); @@ -474,11 +498,11 @@ namespace MediaBrowser.Api } else if (request.Season.HasValue) { - var series = _libraryManager.GetItemById(request.Id) as Series; + var series = GetSeries(request.Id, request.SeriesName, user); if (series == null) { - throw new ResourceNotFoundException("No series exists with Id " + request.Id); + throw new ResourceNotFoundException("Series not found"); } var season = series.GetSeasons(user).FirstOrDefault(i => i.IndexNumber == request.Season.Value); @@ -494,11 +518,11 @@ namespace MediaBrowser.Api } else { - var series = _libraryManager.GetItemById(request.Id) as Series; + var series = GetSeries(request.Id, request.SeriesName, user); if (series == null) { - throw new ResourceNotFoundException("No series exists with Id " + request.Id); + throw new ResourceNotFoundException("Series not found"); } episodes = series.GetEpisodes(user); diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 6ad38033a..f40ab3cde 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -9,6 +9,7 @@ using MediaBrowser.Model.Serialization; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Dto; namespace MediaBrowser.Controller.Entities.Audio { @@ -227,7 +228,39 @@ namespace MediaBrowser.Controller.Entities.Audio // Refresh current item await RefreshMetadata(parentRefreshOptions, cancellationToken).ConfigureAwait(false); + if (!refreshOptions.IsAutomated) + { + await RefreshArtists(refreshOptions, cancellationToken).ConfigureAwait(false); + } + progress.Report(100); } + + private async Task RefreshArtists(MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken) + { + var artists = AllArtists.Select(i => + { + // This should not be necessary but we're seeing some cases of it + if (string.IsNullOrWhiteSpace(i)) + { + return null; + } + + var artist = LibraryManager.GetArtist(i); + + if (!artist.IsAccessedByName) + { + return null; + } + + return artist; + + }).Where(i => i != null).ToList(); + + foreach (var artist in artists) + { + await artist.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); + } + } } } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 8412985bf..dd1397a0d 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -719,14 +719,15 @@ namespace MediaBrowser.Controller.MediaEncoding } } // nvenc doesn't decode with param -level set ?! - else if (string.Equals(videoEncoder, "h264_nvenc", StringComparison.OrdinalIgnoreCase)){ + else if (string.Equals(videoEncoder, "h264_nvenc", StringComparison.OrdinalIgnoreCase)) + { //param += ""; } else if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase)) { param += " -level " + level; } - + } if (string.Equals(videoEncoder, "libx264", StringComparison.OrdinalIgnoreCase)) @@ -1014,43 +1015,32 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetAudioFilterParam(EncodingJobInfo state, EncodingOptions encodingOptions, bool isHls) { - var volParam = string.Empty; - var audioSampleRate = string.Empty; - var channels = state.OutputAudioChannels; + var filters = new List(); + // Boost volume to 200% when downsampling from 6ch to 2ch if (channels.HasValue && channels.Value <= 2) { if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5 && !encodingOptions.DownMixAudioBoost.Equals(1)) { - volParam = ",volume=" + encodingOptions.DownMixAudioBoost.ToString(_usCulture); + filters.Add("volume=" + encodingOptions.DownMixAudioBoost.ToString(_usCulture)); } } - if (state.OutputAudioSampleRate.HasValue) - { - audioSampleRate = state.OutputAudioSampleRate.Value + ":"; - } - - var adelay = isHls ? "adelay=1," : string.Empty; - - var pts = string.Empty; - if (state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode && !state.CopyTimestamps) { var seconds = TimeSpan.FromTicks(state.StartTimeTicks ?? 0).TotalSeconds; - pts = string.Format(",asetpts=PTS-{0}/TB", Math.Round(seconds).ToString(_usCulture)); + filters.Add(string.Format("asetpts=PTS-{0}/TB", Math.Round(seconds).ToString(_usCulture))); } - return string.Format("-af \"{0}aresample={1}async={4}{2}{3}\"", + if (filters.Count > 0) + { + return "-af \"" + string.Join(",", filters.ToArray()) + "\""; + } - adelay, - audioSampleRate, - volParam, - pts, - state.OutputAudioSync); + return string.Empty; } /// @@ -1282,7 +1272,7 @@ namespace MediaBrowser.Controller.MediaEncoding } var videoSizeParam = string.Empty; - + if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue) { videoSizeParam = string.Format("scale={0}:{1}", state.VideoStream.Width.Value.ToString(_usCulture), state.VideoStream.Height.Value.ToString(_usCulture)); @@ -1569,7 +1559,7 @@ namespace MediaBrowser.Controller.MediaEncoding var outputVideoCodec = GetVideoEncoder(state, encodingOptions); // Important: If this is ever re-enabled, make sure not to use it with wtv because it breaks seeking - if (!string.Equals(state.InputContainer, "wtv", StringComparison.OrdinalIgnoreCase) && + if (!string.Equals(state.InputContainer, "wtv", StringComparison.OrdinalIgnoreCase) && state.TranscodingType != TranscodingJobType.Progressive && state.EnableBreakOnNonKeyFrames(outputVideoCodec)) { @@ -1657,7 +1647,6 @@ namespace MediaBrowser.Controller.MediaEncoding if (state.ReadInputAtNativeFramerate || mediaSource.Protocol == MediaProtocol.File && string.Equals(mediaSource.Container, "wtv", StringComparison.OrdinalIgnoreCase)) { - state.OutputAudioSync = "1000"; state.InputVideoSync = "-1"; state.InputAudioSync = "1"; } @@ -1715,7 +1704,7 @@ namespace MediaBrowser.Controller.MediaEncoding { if (state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) { - return ; + return; } // This is tricky to remux in, after converting to dvdsub it's not positioned correctly @@ -1985,7 +1974,12 @@ namespace MediaBrowser.Controller.MediaEncoding { args += " -ab " + bitrate.Value.ToString(_usCulture); } - + + if (state.OutputAudioSampleRate.HasValue) + { + args += " -ar " + state.OutputAudioSampleRate.Value.ToString(_usCulture); + } + args += " " + GetAudioFilterParam(state, encodingOptions, false); return args; diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index 4e0f223b7..f3e6280aa 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Controller.MediaEncoding return "-1"; } } - public string OutputAudioSync = "1"; + public string InputAudioSync { get; set; } public string InputVideoSync { get; set; } public TransportStreamTimestamp InputTimestamp { get; set; } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index af826f231..816f14f82 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -664,28 +664,16 @@ namespace MediaBrowser.MediaEncoding.Encoder private bool DetectInterlaced(MediaSourceInfo video, MediaStream videoStream) { - var formats = (video.Container ?? string.Empty).Split(',').ToList(); - var enableInterlacedDection = formats.Contains("vob", StringComparer.OrdinalIgnoreCase) || - formats.Contains("m2ts", StringComparer.OrdinalIgnoreCase) || - formats.Contains("ts", StringComparer.OrdinalIgnoreCase) || - formats.Contains("mpegts", StringComparer.OrdinalIgnoreCase) || - formats.Contains("wtv", StringComparer.OrdinalIgnoreCase); - // If it's mpeg based, assume true if ((videoStream.Codec ?? string.Empty).IndexOf("mpeg", StringComparison.OrdinalIgnoreCase) != -1) { - if (enableInterlacedDection) - { - return true; - } - } - else - { - // If the video codec is not some form of mpeg, then take a shortcut and limit this to containers that are likely to have interlaced content - if (!enableInterlacedDection) - { - return false; - } + var formats = (video.Container ?? string.Empty).Split(',').ToList(); + return formats.Contains("vob", StringComparer.OrdinalIgnoreCase) || + formats.Contains("m2ts", StringComparer.OrdinalIgnoreCase) || + formats.Contains("ts", StringComparer.OrdinalIgnoreCase) || + formats.Contains("mpegts", StringComparer.OrdinalIgnoreCase) || + formats.Contains("wtv", StringComparer.OrdinalIgnoreCase); + } return false; -- cgit v1.2.3 From 561028c90734b911ebb5eec26aa071fb6851a2a6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 17 Apr 2017 15:01:16 -0400 Subject: update automated checkins --- .../Library/MediaSourceManager.cs | 98 +--------------------- .../LiveTv/LiveTvMediaSourceProvider.cs | 2 +- .../Session/SessionManager.cs | 38 ++++----- MediaBrowser.Api/ApiEntryPoint.cs | 12 --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/Playback/MediaInfoService.cs | 2 +- MediaBrowser.Api/SuggestionsService.cs | 35 +------- MediaBrowser.Api/TvShowsService.cs | 34 +------- .../Library/IMediaSourceManager.cs | 11 +-- MediaBrowser.Controller/Session/ISessionManager.cs | 2 + MediaBrowser.Controller/Session/SessionInfo.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 2 +- 12 files changed, 28 insertions(+), 212 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index ccd4c3631..4857008f3 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -9,13 +9,10 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Threading; @@ -365,12 +362,10 @@ namespace Emby.Server.Implementations.Library private readonly Dictionary _openStreams = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly SemaphoreSlim _liveStreamSemaphore = new SemaphoreSlim(1, 1); - public async Task OpenLiveStream(LiveStreamRequest request, bool enableAutoClose, CancellationToken cancellationToken) + public async Task OpenLiveStream(LiveStreamRequest request, CancellationToken cancellationToken) { await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); - enableAutoClose = false; - try { var tuple = GetProvider(request.OpenToken); @@ -389,8 +384,6 @@ namespace Emby.Server.Implementations.Library var info = new LiveStreamInfo { - Date = DateTime.UtcNow, - EnableCloseTimer = enableAutoClose, Id = mediaSource.LiveStreamId, MediaSource = mediaSource, DirectStreamProvider = mediaSourceTuple.Item2 @@ -398,11 +391,6 @@ namespace Emby.Server.Implementations.Library _openStreams[mediaSource.LiveStreamId] = info; - if (enableAutoClose) - { - StartCloseTimer(); - } - var json = _jsonSerializer.SerializeToString(mediaSource); _logger.Debug("Live stream opened: " + json); var clone = _jsonSerializer.DeserializeFromString(json); @@ -462,28 +450,6 @@ namespace Emby.Server.Implementations.Library return result.Item1; } - public async Task PingLiveStream(string id, CancellationToken cancellationToken) - { - await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); - - try - { - LiveStreamInfo info; - if (_openStreams.TryGetValue(id, out info)) - { - info.Date = DateTime.UtcNow; - } - else - { - _logger.Error("Failed to ping live stream {0}", id); - } - } - finally - { - _liveStreamSemaphore.Release(); - } - } - private async Task CloseLiveStreamWithProvider(IMediaSourceProvider provider, string streamId) { _logger.Info("Closing live stream {0} with provider {1}", streamId, provider.GetType().Name); @@ -525,11 +491,6 @@ namespace Emby.Server.Implementations.Library await CloseLiveStreamWithProvider(tuple.Item1, tuple.Item2).ConfigureAwait(false); } - - if (_openStreams.Count == 0) - { - StopCloseTimer(); - } } } finally @@ -558,66 +519,11 @@ namespace Emby.Server.Implementations.Library return new Tuple(provider, keyId); } - private ITimer _closeTimer; - private readonly TimeSpan _openStreamMaxAge = TimeSpan.FromSeconds(180); - - private void StartCloseTimer() - { - StopCloseTimer(); - - _closeTimer = _timerFactory.Create(CloseTimerCallback, null, _openStreamMaxAge, _openStreamMaxAge); - } - - private void StopCloseTimer() - { - var timer = _closeTimer; - - if (timer != null) - { - _closeTimer = null; - timer.Dispose(); - } - } - - private async void CloseTimerCallback(object state) - { - List infos; - await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false); - - try - { - infos = _openStreams - .Values - .Where(i => i.EnableCloseTimer && DateTime.UtcNow - i.Date > _openStreamMaxAge) - .ToList(); - } - finally - { - _liveStreamSemaphore.Release(); - } - - foreach (var info in infos) - { - if (!info.Closed) - { - try - { - await CloseLiveStream(info.Id).ConfigureAwait(false); - } - catch (Exception ex) - { - _logger.ErrorException("Error closing media source", ex); - } - } - } - } - /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public void Dispose() { - StopCloseTimer(); Dispose(true); } @@ -644,8 +550,6 @@ namespace Emby.Server.Implementations.Library private class LiveStreamInfo { - public DateTime Date; - public bool EnableCloseTimer; public string Id; public bool Closed; public MediaSourceInfo MediaSource; diff --git a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index 93996f5da..329f5b8a4 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -190,7 +190,7 @@ namespace Emby.Server.Implementations.LiveTv else if (width >= 1260) { - videoStream.BitRate = 3000000; + videoStream.BitRate = 4000000; } else if (width >= 700) diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index ed0a47121..63556c1ce 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -310,10 +310,7 @@ namespace Emby.Server.Implementations.Session /// /// Updates the now playing item id. /// - /// The session. - /// The information. - /// The library item. - private async Task UpdateNowPlayingItem(SessionInfo session, PlaybackProgressInfo info, BaseItem libraryItem) + private async Task UpdateNowPlayingItem(SessionInfo session, PlaybackProgressInfo info, BaseItem libraryItem, bool updateLastCheckInTime) { if (string.IsNullOrWhiteSpace(info.MediaSourceId)) { @@ -352,7 +349,11 @@ namespace Emby.Server.Implementations.Session session.NowPlayingItem = info.Item; session.LastActivityDate = DateTime.UtcNow; - session.LastPlaybackCheckIn = DateTime.UtcNow; + + if (updateLastCheckInTime) + { + session.LastPlaybackCheckIn = DateTime.UtcNow; + } session.PlayState.IsPaused = info.IsPaused; session.PlayState.PositionTicks = info.PositionTicks; @@ -604,7 +605,7 @@ namespace Emby.Server.Implementations.Session ? null : GetNowPlayingItem(session, info.ItemId); - await UpdateNowPlayingItem(session, info, libraryItem).ConfigureAwait(false); + await UpdateNowPlayingItem(session, info, libraryItem, true).ConfigureAwait(false); if (!string.IsNullOrEmpty(session.DeviceId) && info.PlayMethod != PlayMethod.Transcode) { @@ -671,14 +672,15 @@ namespace Emby.Server.Implementations.Session await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false); } + public Task OnPlaybackProgress(PlaybackProgressInfo info) + { + return OnPlaybackProgress(info, false); + } + /// /// Used to report playback progress for an item /// - /// The info. - /// Task. - /// - /// positionTicks - public async Task OnPlaybackProgress(PlaybackProgressInfo info) + public async Task OnPlaybackProgress(PlaybackProgressInfo info, bool isAutomated) { if (info == null) { @@ -691,7 +693,7 @@ namespace Emby.Server.Implementations.Session ? null : GetNowPlayingItem(session, info.ItemId); - await UpdateNowPlayingItem(session, info, libraryItem).ConfigureAwait(false); + await UpdateNowPlayingItem(session, info, libraryItem, !isAutomated).ConfigureAwait(false); var users = GetUsers(session); @@ -703,18 +705,6 @@ namespace Emby.Server.Implementations.Session } } - if (!string.IsNullOrWhiteSpace(info.LiveStreamId)) - { - try - { - await _mediaSourceManager.PingLiveStream(info.LiveStreamId, CancellationToken.None).ConfigureAwait(false); - } - catch (Exception ex) - { - _logger.ErrorException("Error closing live stream", ex); - } - } - EventHelper.FireEventIfNotNull(PlaybackProgress, this, new PlaybackProgressEventArgs { Item = libraryItem, diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index b62af554e..a59ab33a9 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -426,18 +426,6 @@ namespace MediaBrowser.Api { job.ChangeKillTimerIfStarted(); } - - if (!string.IsNullOrWhiteSpace(job.LiveStreamId)) - { - try - { - await _mediaSourceManager.PingLiveStream(job.LiveStreamId, CancellationToken.None).ConfigureAwait(false); - } - catch (Exception ex) - { - Logger.ErrorException("Error closing live stream", ex); - } - } } /// diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 480508e6f..699c4bbb2 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -169,7 +169,7 @@ namespace MediaBrowser.Api.Playback { OpenToken = state.MediaSource.OpenToken - }, false, cancellationTokenSource.Token).ConfigureAwait(false); + }, cancellationTokenSource.Token).ConfigureAwait(false); EncodingHelper.AttachMediaSourceInfo(state, liveStreamResponse.MediaSource, state.RequestedUrl); diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 0ee0dab30..fcd18bfe4 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -109,7 +109,7 @@ namespace MediaBrowser.Api.Playback { var authInfo = _authContext.GetAuthorizationInfo(Request); - var result = await _mediaSourceManager.OpenLiveStream(request, true, CancellationToken.None).ConfigureAwait(false); + var result = await _mediaSourceManager.OpenLiveStream(request, CancellationToken.None).ConfigureAwait(false); var profile = request.DeviceProfile; if (profile == null) diff --git a/MediaBrowser.Api/SuggestionsService.cs b/MediaBrowser.Api/SuggestionsService.cs index 3e901e303..99411ffdc 100644 --- a/MediaBrowser.Api/SuggestionsService.cs +++ b/MediaBrowser.Api/SuggestionsService.cs @@ -12,7 +12,6 @@ using MediaBrowser.Controller.Library; namespace MediaBrowser.Api { [Route("/Users/{UserId}/Suggestions", "GET", Summary = "Gets items based on a query.")] - [Route("/Users/{UserId}/Suggestions", "POST", Summary = "Gets items based on a query.")] public class GetSuggestedItems : IReturn> { public string MediaType { get; set; } @@ -21,7 +20,6 @@ namespace MediaBrowser.Api public bool EnableTotalRecordCount { get; set; } public int? StartIndex { get; set; } public int? Limit { get; set; } - public string Name { get; set; } public string[] GetMediaTypes() { @@ -56,13 +54,6 @@ namespace MediaBrowser.Api return ToOptimizedResult(result); } - public async Task Post(GetSuggestedItems request) - { - var result = await GetResultItems(request).ConfigureAwait(false); - - return ToOptimizedResult(result); - } - private async Task> GetResultItems(GetSuggestedItems request) { var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; @@ -86,29 +77,6 @@ namespace MediaBrowser.Api private QueryResult GetItems(GetSuggestedItems request, User user, DtoOptions dtoOptions) { - BaseItem similarToItem = null; - - if (!string.IsNullOrWhiteSpace(request.Name)) - { - // get item by name, then get similar items from that - similarToItem = _libraryManager.GetItemList(new InternalItemsQuery(user) - { - SortBy = new string[] {ItemSortBy.Random}, - MediaTypes = request.GetMediaTypes(), - IncludeItemTypes = request.GetIncludeItemTypes(), - IsVirtualItem = false, - Name = request.Name, - Recursive = true, - Limit = 1 - - }).FirstOrDefault(); - - if (similarToItem == null) - { - return new QueryResult(); - } - } - return _libraryManager.GetItemsResult(new InternalItemsQuery(user) { SortBy = new string[] { ItemSortBy.Random }, @@ -119,8 +87,7 @@ namespace MediaBrowser.Api Limit = request.Limit, DtoOptions = dtoOptions, EnableTotalRecordCount = request.EnableTotalRecordCount, - Recursive = true, - SimilarTo = similarToItem + Recursive = true }); } } diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 13adceed5..126f1c753 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -137,7 +137,6 @@ namespace MediaBrowser.Api } [Route("/Shows/{Id}/Episodes", "GET", Summary = "Gets episodes for a tv season")] - [Route("/Shows/Episodes", "POST", Summary = "Gets episodes for a tv season")] public class GetEpisodes : IReturn, IHasItemFields, IHasDtoOptions { /// @@ -200,12 +199,9 @@ namespace MediaBrowser.Api [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? EnableUserData { get; set; } - - public string SeriesName { get; set; } } [Route("/Shows/{Id}/Seasons", "GET", Summary = "Gets seasons for a tv series")] - [Route("/Shows/Seasons", "POST", Summary = "Gets seasons for a tv series")] public class GetSeasons : IReturn, IHasItemFields, IHasDtoOptions { /// @@ -248,8 +244,6 @@ namespace MediaBrowser.Api [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? EnableUserData { get; set; } - - public string SeriesName { get; set; } } /// @@ -431,7 +425,7 @@ namespace MediaBrowser.Api { var user = _userManager.GetUserById(request.UserId); - var series = GetSeries(request.Id, request.SeriesName, user); + var series = GetSeries(request.Id, user); if (series == null) { @@ -459,33 +453,13 @@ namespace MediaBrowser.Api }; } - public Task Post(GetSeasons request) - { - return Get(request); - } - - public Task Post(GetEpisodes request) - { - return Get(request); - } - - private Series GetSeries(string seriesId, string seriesName, User user) + private Series GetSeries(string seriesId, User user) { if (!string.IsNullOrWhiteSpace(seriesId)) { return _libraryManager.GetItemById(seriesId) as Series; } - if (!string.IsNullOrWhiteSpace(seriesName)) - { - return _libraryManager.GetItemList(new InternalItemsQuery(user) - { - Name = seriesName, - IncludeItemTypes = new string[] { typeof(Series).Name } - - }).OfType().FirstOrDefault(); - } - return null; } @@ -508,7 +482,7 @@ namespace MediaBrowser.Api } else if (request.Season.HasValue) { - var series = GetSeries(request.Id, request.SeriesName, user); + var series = GetSeries(request.Id, user); if (series == null) { @@ -528,7 +502,7 @@ namespace MediaBrowser.Api } else { - var series = GetSeries(request.Id, request.SeriesName, user); + var series = GetSeries(request.Id, user); if (series == null) { diff --git a/MediaBrowser.Controller/Library/IMediaSourceManager.cs b/MediaBrowser.Controller/Library/IMediaSourceManager.cs index 1ab0e4cb0..2f8f37789 100644 --- a/MediaBrowser.Controller/Library/IMediaSourceManager.cs +++ b/MediaBrowser.Controller/Library/IMediaSourceManager.cs @@ -68,10 +68,9 @@ namespace MediaBrowser.Controller.Library /// Opens the media source. /// /// The request. - /// if set to true [enable automatic close]. /// The cancellation token. /// Task<MediaSourceInfo>. - Task OpenLiveStream(LiveStreamRequest request, bool enableAutoClose, CancellationToken cancellationToken); + Task OpenLiveStream(LiveStreamRequest request, CancellationToken cancellationToken); /// /// Gets the live stream. @@ -82,14 +81,6 @@ namespace MediaBrowser.Controller.Library Task GetLiveStream(string id, CancellationToken cancellationToken); Task> GetLiveStreamWithDirectStreamProvider(string id, CancellationToken cancellationToken); - - /// - /// Pings the media source. - /// - /// The live stream identifier. - /// The cancellation token. - /// Task. - Task PingLiveStream(string id, CancellationToken cancellationToken); /// /// Closes the media source. diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 387195245..956d4cc95 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -99,6 +99,8 @@ namespace MediaBrowser.Controller.Session /// Task OnPlaybackProgress(PlaybackProgressInfo info); + Task OnPlaybackProgress(PlaybackProgressInfo info, bool isAutomated); + /// /// Used to report that playback has ended for an item /// diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 6cb6f4bb6..4cb08de9f 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -257,7 +257,7 @@ namespace MediaBrowser.Controller.Session try { - await _sessionManager.OnPlaybackProgress(progressInfo).ConfigureAwait(false); + await _sessionManager.OnPlaybackProgress(progressInfo, true).ConfigureAwait(false); } catch (Exception ex) { diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index c0440e132..e402c2bac 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -356,7 +356,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { OpenToken = state.MediaSource.OpenToken - }, false, cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false); EncodingHelper.AttachMediaSourceInfo(state, liveStreamResponse.MediaSource, null); -- cgit v1.2.3