The Free Software Media System - Server Backend & API
update recording layout
Luke Pulverenticc7b150b90e2
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex 545ac162ff..f6817e0e7b 100644--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs@@ -155,6 +155,9 @@ namespace MediaBrowser.Api.LiveTv[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]public bool? EnableUserData { get; set; }+ public bool? IsMovie { get; set; }+ public bool? IsSeries { get; set; }+public GetRecordings(){EnableTotalRecordCount = true;@@ -863,7 +866,9 @@ namespace MediaBrowser.Api.LiveTvStatus = request.Status,SeriesTimerId = request.SeriesTimerId,IsInProgress = request.IsInProgress,- EnableTotalRecordCount = request.EnableTotalRecordCount+ EnableTotalRecordCount = request.EnableTotalRecordCount,+ IsMovie = request.IsMovie,+ IsSeries = request.IsSeries}, options, CancellationToken.None).ConfigureAwait(false);diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex e626d49f42..b419250f71 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -1786,6 +1786,16 @@ namespace MediaBrowser.Api.Playback// state.SegmentLength = 6;//}+ if (state.VideoRequest != null)+ {+ if (!string.IsNullOrWhiteSpace(state.VideoRequest.VideoCodec))+ {+ state.SupportedVideoCodecs = state.VideoRequest.VideoCodec.Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();+ state.VideoRequest.VideoCodec = state.SupportedVideoCodecs.FirstOrDefault(i => MediaEncoder.CanEncodeToAudioCodec(i))+ ?? state.SupportedVideoCodecs.FirstOrDefault();+ }+ }+if (!string.IsNullOrWhiteSpace(request.AudioCodec)){state.SupportedAudioCodecs = request.AudioCodec.Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();@@ -2028,7 +2038,7 @@ namespace MediaBrowser.Api.Playback}// Source and target codecs must match- if (!string.Equals(request.VideoCodec, videoStream.Codec, StringComparison.OrdinalIgnoreCase))+ if (string.IsNullOrEmpty(videoStream.Codec) || !state.SupportedVideoCodecs.Contains(videoStream.Codec, StringComparer.OrdinalIgnoreCase)){return false;}diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.csindex d7d94c69b4..2e92c4a499 100644--- a/MediaBrowser.Api/Playback/StreamState.cs+++ b/MediaBrowser.Api/Playback/StreamState.cs@@ -112,6 +112,7 @@ namespace MediaBrowser.Api.Playbackpublic string OutputVideoSync = "-1";public List<string> SupportedAudioCodecs { get; set; }+ public List<string> SupportedVideoCodecs { get; set; }public string UserAgent { get; set; }public StreamState(IMediaSourceManager mediaSourceManager, ILogger logger)@@ -119,6 +120,7 @@ namespace MediaBrowser.Api.Playback_mediaSourceManager = mediaSourceManager;_logger = logger;SupportedAudioCodecs = new List<string>();+ SupportedVideoCodecs = new List<string>();PlayableStreamFileNames = new List<string>();RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);}diff --git a/MediaBrowser.Model/LiveTv/RecordingQuery.cs b/MediaBrowser.Model/LiveTv/RecordingQuery.csindex 923d303f80..cedc0b8525 100644--- a/MediaBrowser.Model/LiveTv/RecordingQuery.cs+++ b/MediaBrowser.Model/LiveTv/RecordingQuery.cs@@ -68,6 +68,8 @@ namespace MediaBrowser.Model.LiveTv/// <value>The fields.</value>public ItemFields[] Fields { get; set; }public bool? EnableImages { get; set; }+ public bool? IsMovie { get; set; }+ public bool? IsSeries { get; set; }public int? ImageTypeLimit { get; set; }public ImageType[] EnableImageTypes { get; set; }diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.csindex 3d1de5b379..c4d056a612 100644--- a/MediaBrowser.Model/System/SystemInfo.cs+++ b/MediaBrowser.Model/System/SystemInfo.cs@@ -8,6 +8,8 @@ namespace MediaBrowser.Model.System/// </summary>public class SystemInfo : PublicSystemInfo{+ public PackageVersionClass SystemUpdateLevel { get; set; }+/// <summary>/// Gets or sets the display name of the operating system./// </summary>diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 88017aa59d..3d9a0f80ed 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -31,6 +31,8 @@ using CommonIO;using IniParser;using IniParser.Model;using MediaBrowser.Common.Events;+using MediaBrowser.Controller.Entities.Movies;+using MediaBrowser.Controller.Entities.TV;using MediaBrowser.Model.Events;namespace MediaBrowser.Server.Implementations.LiveTv@@ -1423,6 +1425,32 @@ namespace MediaBrowser.Server.Implementations.LiveTvreturn new QueryResult<BaseItem>();}+ var includeItemTypes = new List<string>();+ var excludeItemTypes = new List<string>();++ if (query.IsMovie.HasValue)+ {+ if (query.IsMovie.Value)+ {+ includeItemTypes.Add(typeof (Movie).Name);+ }+ else+ {+ excludeItemTypes.Add(typeof(Movie).Name);+ }+ }+ if (query.IsSeries.HasValue)+ {+ if (query.IsSeries.Value)+ {+ includeItemTypes.Add(typeof(Episode).Name);+ }+ else+ {+ excludeItemTypes.Add(typeof(Episode).Name);+ }+ }+return _libraryManager.GetItemsResult(new InternalItemsQuery(user){MediaTypes = new[] { MediaType.Video },@@ -1433,7 +1461,9 @@ namespace MediaBrowser.Server.Implementations.LiveTvLimit = Math.Min(200, query.Limit ?? int.MaxValue),SortBy = new[] { ItemSortBy.DateCreated },SortOrder = SortOrder.Descending,- EnableTotalRecordCount = query.EnableTotalRecordCount+ EnableTotalRecordCount = query.EnableTotalRecordCount,+ IncludeItemTypes = includeItemTypes.ToArray(),+ ExcludeItemTypes = excludeItemTypes.ToArray()});}@@ -1492,6 +1522,18 @@ namespace MediaBrowser.Server.Implementations.LiveTvrecordings = recordings.Where(i => i.Status == val);}+ if (query.IsMovie.HasValue)+ {+ var val = query.IsMovie.Value;+ recordings = recordings.Where(i => i.IsMovie == val);+ }++ if (query.IsSeries.HasValue)+ {+ var val = query.IsSeries.Value;+ recordings = recordings.Where(i => i.IsSeries == val);+ }+if (!string.IsNullOrEmpty(query.SeriesTimerId)){var guid = new Guid(query.SeriesTimerId);@@ -1950,16 +1992,16 @@ namespace MediaBrowser.Server.Implementations.LiveTvdto.Number = channel.Number;dto.ChannelNumber = channel.Number;dto.ChannelType = channel.ChannelType;- dto.ServiceName = GetService(channel).Name;+ dto.ServiceName = channel.ServiceName;if (options.Fields.Contains(ItemFields.MediaSources)){dto.MediaSources = channel.GetMediaSources(true).ToList();}- var channelIdString = channel.Id.ToString("N");if (options.AddCurrentProgram){+ var channelIdString = channel.Id.ToString("N");var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString));if (currentProgram != null)diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex a25bd38123..86c5c06bc2 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -1096,7 +1096,8 @@ namespace MediaBrowser.Server.Startup.CommonLocalAddress = localAddress,SupportsLibraryMonitor = SupportsLibraryMonitor,EncoderLocationType = MediaEncoder.EncoderLocationType,- SystemArchitecture = NativeApp.Environment.SystemArchitecture+ SystemArchitecture = NativeApp.Environment.SystemArchitecture,+ SystemUpdateLevel = ConfigurationManager.CommonConfiguration.SystemUpdateLevel};}diff --git a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.csindex 1c90a74386..de898e66cb 100644--- a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs+++ b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs@@ -1,4 +1,5 @@using System;+using System.Collections.Generic;using System.Threading;using System.Threading.Tasks;using MediaBrowser.Common.Implementations.Updates;@@ -55,21 +56,39 @@ namespace MediaBrowser.Server.Startup.Common.Migrations}}- private async Task CheckVersion(Version currentVersion, PackageVersionClass updateLevel, CancellationToken cancellationToken)+ private async Task CheckVersion(Version currentVersion, PackageVersionClass currentUpdateLevel, CancellationToken cancellationToken){var releases = await new GithubUpdater(_httpClient, _jsonSerializer, TimeSpan.FromMinutes(3)).GetLatestReleases("MediaBrowser", "Emby", _releaseAssetFilename, cancellationToken).ConfigureAwait(false);- var newUpdateLevel = updateLevel;+ var newUpdateLevel = GetNewUpdateLevel(currentVersion, currentUpdateLevel, releases);++ if (newUpdateLevel != currentUpdateLevel)+ {+ _config.Configuration.SystemUpdateLevel = newUpdateLevel;+ _config.SaveConfiguration();+ }+ }++ private PackageVersionClass GetNewUpdateLevel(Version currentVersion, PackageVersionClass currentUpdateLevel, List<GithubUpdater.RootObject> releases)+ {+ var newUpdateLevel = currentUpdateLevel;// If the current version is later than current stable, set the update level to betaif (releases.Count >= 1){var release = releases[0];var version = ParseVersion(release.tag_name);- if (version != null && currentVersion > version)+ if (version != null){- newUpdateLevel = PackageVersionClass.Beta;+ if (currentVersion > version)+ {+ newUpdateLevel = PackageVersionClass.Beta;+ }+ else+ {+ return PackageVersionClass.Release;+ }}}@@ -78,17 +97,20 @@ namespace MediaBrowser.Server.Startup.Common.Migrations{var release = releases[1];var version = ParseVersion(release.tag_name);- if (version != null && currentVersion > version)+ if (version != null){- newUpdateLevel = PackageVersionClass.Dev;+ if (currentVersion > version)+ {+ newUpdateLevel = PackageVersionClass.Dev;+ }+ else+ {+ return PackageVersionClass.Beta;+ }}}- if (newUpdateLevel != updateLevel)- {- _config.Configuration.SystemUpdateLevel = newUpdateLevel;- _config.SaveConfiguration();- }+ return newUpdateLevel;}private Version ParseVersion(string versionString)