diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index f91a35dca4..fa49698781 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1159,6 +1159,72 @@ namespace MediaBrowser.Api.Playback return null; } + /// + /// Parses the parameters. + /// + /// The request. + private void ParseParams(StreamRequest request) + { + var vals = request.Params.Split(';'); + + var videoRequest = request as VideoStreamRequest; + + for (var i = 0; i < vals.Length; i++) + { + var val = vals[i]; + + if (string.IsNullOrWhiteSpace(val)) + { + continue; + } + + if (i == 0) + { + request.DeviceId = val; + } + else if (i == 1) + { + if (videoRequest != null) + { + videoRequest.VideoCodec = (VideoCodecs)Enum.Parse(typeof(VideoCodecs), val, true); + } + } + else if (i == 2) + { + request.AudioCodec = (AudioCodecs)Enum.Parse(typeof(AudioCodecs), val, true); + } + else if (i == 3) + { + if (videoRequest != null) + { + videoRequest.AudioStreamIndex = int.Parse(val, UsCulture); + } + } + else if (i == 4) + { + if (videoRequest != null) + { + videoRequest.SubtitleStreamIndex = int.Parse(val, UsCulture); + } + } + else if (i == 5) + { + if (videoRequest != null) + { + videoRequest.VideoBitRate = int.Parse(val, UsCulture); + } + } + else if (i == 6) + { + request.AudioBitRate = int.Parse(val, UsCulture); + } + else if (i == 7) + { + request.AudioChannels = int.Parse(val, UsCulture); + } + } + } + /// /// Gets the state. /// @@ -1167,6 +1233,11 @@ namespace MediaBrowser.Api.Playback /// StreamState. protected async Task GetState(StreamRequest request, CancellationToken cancellationToken) { + if (!string.IsNullOrWhiteSpace(request.Params)) + { + ParseParams(request); + } + if (request.ThrowDebugError) { throw new InvalidOperationException("You asked for a debug error, you got one."); diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index 78682d54a2..a73a8f0d90 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -60,16 +60,12 @@ namespace MediaBrowser.Api.Playback [ApiMember(Name = "Static", Description = "Optional. If true, the original file will be streamed statically without any encoding. Use either no url extension or the original file extension. true/false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool Static { get; set; } - /// - /// This is an xbox 360 param that is used with dlna. If true the item's image should be returned instead of audio or video. - /// No need to put this in api docs since it's dlna only - /// - public bool AlbumArt { get; set; } - /// /// For testing purposes /// public bool ThrowDebugError { get; set; } + + public string Params { get; set; } } public class VideoStreamRequest : StreamRequest diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 9ddefdd053..8e94d2c83a 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -189,7 +189,7 @@ namespace MediaBrowser.Api { throw new ArgumentNullException("xmlSerializer"); } - + _xmlSerializer = xmlSerializer; _userManager = userManager; _dtoService = dtoService; diff --git a/MediaBrowser.Controller/Entities/AdultVideo.cs b/MediaBrowser.Controller/Entities/AdultVideo.cs index fc7632152c..9791f7cf79 100644 --- a/MediaBrowser.Controller/Entities/AdultVideo.cs +++ b/MediaBrowser.Controller/Entities/AdultVideo.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using MediaBrowser.Controller.Providers; namespace MediaBrowser.Controller.Entities { @@ -22,5 +23,26 @@ namespace MediaBrowser.Controller.Entities { Taglines = new List(); } + + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + if (!ProductionYear.HasValue) + { + int? yearInName = null; + string name; + + NameParser.ParseName(Name, out name, out yearInName); + + if (yearInName.HasValue) + { + ProductionYear = yearInName; + hasChanges = true; + } + } + + return hasChanges; + } } } diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 5cabe1cfe4..362096b5e3 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -66,7 +66,7 @@ namespace MediaBrowser.Controller.Entities { var path = ContainingFolderPath; - var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, LibraryManager) + var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, LibraryManager, directoryService) { FileInfo = new DirectoryInfo(path), Path = path, diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 8dcf086425..415b49f808 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -472,7 +472,7 @@ namespace MediaBrowser.Controller.Entities /// Loads local trailers from the file system /// /// List{Video}. - private IEnumerable LoadLocalTrailers(List fileSystemChildren) + private IEnumerable LoadLocalTrailers(List fileSystemChildren, IDirectoryService directoryService) { var files = fileSystemChildren.OfType() .Where(i => string.Equals(i.Name, TrailerFolderName, StringComparison.OrdinalIgnoreCase)) @@ -484,7 +484,7 @@ namespace MediaBrowser.Controller.Entities .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.Name).EndsWith(XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase) && !string.Equals(Path, i.FullName, StringComparison.OrdinalIgnoreCase)) ); - return LibraryManager.ResolvePaths(files, null).Select(video => + return LibraryManager.ResolvePaths(files, directoryService, null).Select(video => { // Try to retrieve it from the db. If we don't find it, use the resolved version var dbItem = LibraryManager.GetItemById(video.Id) as Trailer; @@ -504,7 +504,7 @@ namespace MediaBrowser.Controller.Entities /// Loads the theme songs. /// /// List{Audio.Audio}. - private IEnumerable LoadThemeSongs(List fileSystemChildren) + private IEnumerable LoadThemeSongs(List fileSystemChildren, IDirectoryService directoryService) { var files = fileSystemChildren.OfType() .Where(i => string.Equals(i.Name, ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase)) @@ -516,7 +516,7 @@ namespace MediaBrowser.Controller.Entities .Where(i => string.Equals(System.IO.Path.GetFileNameWithoutExtension(i.Name), ThemeSongFilename, StringComparison.OrdinalIgnoreCase)) ); - return LibraryManager.ResolvePaths(files, null).Select(audio => + return LibraryManager.ResolvePaths(files, directoryService, null).Select(audio => { // Try to retrieve it from the db. If we don't find it, use the resolved version var dbItem = LibraryManager.GetItemById(audio.Id) as Audio.Audio; @@ -536,13 +536,13 @@ namespace MediaBrowser.Controller.Entities /// Loads the video backdrops. /// /// List{Video}. - private IEnumerable