diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-08-05 15:05:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-05 15:05:30 -0400 |
| commit | d8c2dd253277ba2ce7a5a7496b278db0e4e85106 (patch) | |
| tree | 176e34705fb03d79d9302cf7f8f8aa3f88958cca /MediaBrowser.Controller | |
| parent | e169eaee6cb2f91e4102f4fe7ac9075659feba95 (diff) | |
| parent | 804f19fc424e72ede16e66bc7809eab3450e528e (diff) | |
Merge pull request #2795 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Controller')
14 files changed, 115 insertions, 50 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 873ac3104..26e46b63a 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -9,6 +9,7 @@ using System.Globalization; using System.Linq; using System.Threading; using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities.Audio @@ -193,6 +194,23 @@ namespace MediaBrowser.Controller.Entities.Audio return base.GetBlockUnratedType(); } + public List<MediaStream> GetMediaStreams() + { + return MediaSourceManager.GetMediaStreams(new MediaStreamQuery + { + ItemId = Id + }); + } + + public List<MediaStream> GetMediaStreams(MediaStreamType type) + { + return MediaSourceManager.GetMediaStreams(new MediaStreamQuery + { + ItemId = Id, + Type = type + }); + } + public SongInfo GetLookupInfo() { var info = GetItemLookupInfo<SongInfo>(); @@ -204,7 +222,7 @@ namespace MediaBrowser.Controller.Entities.Audio return info; } - public virtual IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public virtual List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { if (SourceType == SourceType.Channel) { @@ -248,7 +266,7 @@ namespace MediaBrowser.Controller.Entities.Audio { Id = i.Id.ToString("N"), Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, - MediaStreams = MediaSourceManager.GetMediaStreams(i.Id).ToList(), + MediaStreams = MediaSourceManager.GetMediaStreams(i.Id), Name = i.Name, Path = enablePathSubstituion ? GetMappedPath(i, i.Path, locationType) : i.Path, RunTimeTicks = i.RunTimeTicks, diff --git a/MediaBrowser.Controller/Entities/IHasId.cs b/MediaBrowser.Controller/Entities/IHasId.cs deleted file mode 100644 index 9698adf7a..000000000 --- a/MediaBrowser.Controller/Entities/IHasId.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace MediaBrowser.Controller.Entities -{ - public interface IHasId - { - Guid Id { get; } - } -} diff --git a/MediaBrowser.Controller/Entities/IHasImages.cs b/MediaBrowser.Controller/Entities/IHasImages.cs index d793c82e2..db69df31a 100644 --- a/MediaBrowser.Controller/Entities/IHasImages.cs +++ b/MediaBrowser.Controller/Entities/IHasImages.cs @@ -10,7 +10,7 @@ using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.Entities { - public interface IHasImages : IHasProviderIds, IHasId + public interface IHasImages : IHasProviderIds, IHasUserData { /// <summary> /// Gets the name. diff --git a/MediaBrowser.Controller/Entities/IHasMediaSources.cs b/MediaBrowser.Controller/Entities/IHasMediaSources.cs index 832b9f6c1..bf4acdfbd 100644 --- a/MediaBrowser.Controller/Entities/IHasMediaSources.cs +++ b/MediaBrowser.Controller/Entities/IHasMediaSources.cs @@ -1,5 +1,6 @@ using MediaBrowser.Model.Dto; using System.Collections.Generic; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Entities { @@ -10,6 +11,7 @@ namespace MediaBrowser.Controller.Entities /// </summary> /// <param name="enablePathSubstitution">if set to <c>true</c> [enable path substitution].</param> /// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns> - IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution); + List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution); + List<MediaStream> GetMediaStreams(); } } diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index 62c67336c..17143c4d4 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -65,5 +65,6 @@ namespace MediaBrowser.Controller.Entities int InheritedParentalRatingValue { get; set; } List<string> GetInheritedTags(); List<string> InheritedTags { get; set; } + long? RunTimeTicks { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/IHasUserData.cs b/MediaBrowser.Controller/Entities/IHasUserData.cs index 0029947ee..ce4a482ba 100644 --- a/MediaBrowser.Controller/Entities/IHasUserData.cs +++ b/MediaBrowser.Controller/Entities/IHasUserData.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Threading.Tasks; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; @@ -8,7 +9,7 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Interface IHasUserData /// </summary> - public interface IHasUserData : IHasId + public interface IHasUserData { List<string> GetUserDataKeys(); @@ -20,5 +21,7 @@ namespace MediaBrowser.Controller.Entities bool EnableRememberingTrackSelections { get; } bool SupportsPlayedStatus { get; } + + Guid Id { get; } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 1e1d161c5..c027a3541 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -149,11 +149,6 @@ namespace MediaBrowser.Controller.Entities public Video3DFormat? Video3DFormat { get; set; } /// <summary> - /// If the video is a folder-rip, this will hold the file list for the largest playlist - /// </summary> - public List<string> PlayableStreamFileNames { get; set; } - - /// <summary> /// Gets the playable stream files. /// </summary> /// <returns>List{System.String}.</returns> @@ -162,6 +157,11 @@ namespace MediaBrowser.Controller.Entities return GetPlayableStreamFiles(Path); } + public List<string> GetPlayableStreamFileNames() + { + return GetPlayableStreamFiles().Select(System.IO.Path.GetFileName).ToList(); ; + } + /// <summary> /// Gets or sets the aspect ratio. /// </summary> @@ -170,7 +170,6 @@ namespace MediaBrowser.Controller.Entities public Video() { - PlayableStreamFileNames = new List<string>(); AdditionalParts = new List<string>(); LocalAlternateVersions = new List<string>(); SubtitleFiles = new List<string>(); @@ -395,11 +394,45 @@ namespace MediaBrowser.Controller.Entities { var allFiles = FileSystem.GetFilePaths(rootPath, true).ToList(); - return PlayableStreamFileNames.Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase))) + var videoType = VideoType; + + if (videoType == VideoType.Iso && IsoType == Model.Entities.IsoType.BluRay) + { + videoType = VideoType.BluRay; + } + else if (videoType == VideoType.Iso && IsoType == Model.Entities.IsoType.Dvd) + { + videoType = VideoType.Dvd; + } + + return QueryPlayableStreamFiles(rootPath, videoType).Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase))) .Where(f => !string.IsNullOrEmpty(f)) .ToList(); } + public static List<string> QueryPlayableStreamFiles(string rootPath, VideoType videoType) + { + if (videoType == VideoType.Dvd) + { + return FileSystem.GetFiles(rootPath, new[] { ".vob" }, false, true) + .OrderByDescending(i => i.Length) + .ThenBy(i => i.FullName) + .Take(1) + .Select(i => i.FullName) + .ToList(); + } + if (videoType == VideoType.BluRay) + { + return FileSystem.GetFiles(rootPath, new[] { ".m2ts" }, false, true) + .OrderByDescending(i => i.Length) + .ThenBy(i => i.FullName) + .Take(1) + .Select(i => i.FullName) + .ToList(); + } + return new List<string>(); + } + /// <summary> /// Gets a value indicating whether [is3 D]. /// </summary> @@ -505,17 +538,12 @@ namespace MediaBrowser.Controller.Entities return base.GetDeletePaths(); } - public IEnumerable<MediaStream> GetMediaStreams() + public List<MediaStream> GetMediaStreams() { - var mediaSource = GetMediaSources(false) - .FirstOrDefault(); - - if (mediaSource == null) + return MediaSourceManager.GetMediaStreams(new MediaStreamQuery { - return new List<MediaStream>(); - } - - return mediaSource.MediaStreams; + ItemId = Id + }); } public virtual MediaStream GetDefaultVideoStream() @@ -563,7 +591,7 @@ namespace MediaBrowser.Controller.Entities return list; } - public virtual IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public virtual List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { if (SourceType == SourceType.Channel) { @@ -610,8 +638,7 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("media"); } - var mediaStreams = MediaSourceManager.GetMediaStreams(media.Id) - .ToList(); + var mediaStreams = MediaSourceManager.GetMediaStreams(media.Id); var locationType = media.LocationType; @@ -630,7 +657,6 @@ namespace MediaBrowser.Controller.Entities Size = media.Size, Timestamp = media.Timestamp, Type = type, - PlayableStreamFileNames = media.PlayableStreamFileNames.ToList(), SupportsDirectStream = media.VideoType == VideoType.VideoFile, IsRemote = media.IsShortcut }; diff --git a/MediaBrowser.Controller/Library/IMediaSourceManager.cs b/MediaBrowser.Controller/Library/IMediaSourceManager.cs index 2f8f37789..204033e1d 100644 --- a/MediaBrowser.Controller/Library/IMediaSourceManager.cs +++ b/MediaBrowser.Controller/Library/IMediaSourceManager.cs @@ -24,19 +24,19 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="itemId">The item identifier.</param> /// <returns>IEnumerable<MediaStream>.</returns> - IEnumerable<MediaStream> GetMediaStreams(Guid itemId); + List<MediaStream> GetMediaStreams(Guid itemId); /// <summary> /// Gets the media streams. /// </summary> /// <param name="mediaSourceId">The media source identifier.</param> /// <returns>IEnumerable<MediaStream>.</returns> - IEnumerable<MediaStream> GetMediaStreams(string mediaSourceId); + List<MediaStream> GetMediaStreams(string mediaSourceId); /// <summary> /// Gets the media streams. /// </summary> /// <param name="query">The query.</param> /// <returns>IEnumerable<MediaStream>.</returns> - IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query); + List<MediaStream> GetMediaStreams(MediaStreamQuery query); /// <summary> /// Gets the playack media sources. @@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.Library /// <param name="enablePathSubstitution">if set to <c>true</c> [enable path substitution].</param> /// <param name="user">The user.</param> /// <returns>IEnumerable<MediaSourceInfo>.</returns> - IEnumerable<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user = null); + List<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user = null); /// <summary> /// Gets the static media source. diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 9f8234402..25bc10dec 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -151,9 +151,9 @@ namespace MediaBrowser.Controller.LiveTv return user.Policy.EnableLiveTvManagement; } - public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public override List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { - var list = base.GetMediaSources(enablePathSubstitution).ToList(); + var list = base.GetMediaSources(enablePathSubstitution); foreach (var mediaSource in list) { diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 898ea9ff4..4a93d0399 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -122,7 +122,7 @@ namespace MediaBrowser.Controller.LiveTv return new List<BaseItem>(); } - public IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { var list = new List<MediaSourceInfo>(); @@ -144,6 +144,11 @@ namespace MediaBrowser.Controller.LiveTv return list; } + public List<MediaStream> GetMediaStreams() + { + return new List<MediaStream>(); + } + protected override string GetInternalMetadataPath(string basePath) { return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"), "metadata"); diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 35351ae22..2c26d3556 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -150,9 +150,9 @@ namespace MediaBrowser.Controller.LiveTv return user.Policy.EnableLiveTvManagement; } - public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public override List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { - var list = base.GetMediaSources(enablePathSubstitution).ToList(); + var list = base.GetMediaSources(enablePathSubstitution); foreach (var mediaSource in list) { diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 9cba48b74..e5fbf599a 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -99,7 +99,6 @@ <Compile Include="Entities\GameSystem.cs" /> <Compile Include="Entities\IHasAspectRatio.cs" /> <Compile Include="Entities\IHasDisplayOrder.cs" /> - <Compile Include="Entities\IHasId.cs" /> <Compile Include="Entities\IHasImages.cs" /> <Compile Include="Entities\IHasMediaSources.cs" /> <Compile Include="Entities\IHasProgramAttributes.cs" /> diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index afbb99d39..190ccdd9c 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Threading; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; @@ -1671,14 +1672,33 @@ namespace MediaBrowser.Controller.MediaEncoding state.RunTimeTicks = mediaSource.RunTimeTicks; state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders; + state.IsoType = mediaSource.IsoType; + if (mediaSource.VideoType.HasValue) { state.VideoType = mediaSource.VideoType.Value; - } - - state.IsoType = mediaSource.IsoType; - state.PlayableStreamFileNames = mediaSource.PlayableStreamFileNames.ToList(); + if (mediaSource.VideoType.Value == VideoType.BluRay || mediaSource.VideoType.Value == VideoType.Dvd) + { + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, mediaSource.VideoType.Value); + } + else if (mediaSource.VideoType.Value == VideoType.Iso && state.IsoType == IsoType.BluRay) + { + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.BluRay); + } + else if (mediaSource.VideoType.Value == VideoType.Iso && state.IsoType == IsoType.Dvd) + { + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.Dvd); + } + else + { + state.PlayableStreamFileNames = new List<string>(); + } + } + else + { + state.PlayableStreamFileNames = new List<string>(); + } if (mediaSource.Timestamp.HasValue) { diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index 58ae1f3b0..b26b44258 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -89,7 +89,7 @@ namespace MediaBrowser.Controller.Persistence /// </summary> /// <param name="query">The query.</param> /// <returns>IEnumerable{MediaStream}.</returns> - IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query); + List<MediaStream> GetMediaStreams(MediaStreamQuery query); /// <summary> /// Saves the media streams. |
