diff options
Diffstat (limited to 'MediaBrowser.Controller/Entities/Video.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 125 |
1 files changed, 74 insertions, 51 deletions
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index c5d9b9203..fbeefbbd9 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -16,6 +16,7 @@ using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.Entities { @@ -30,9 +31,9 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public string PrimaryVersionId { get; set; } - public List<string> AdditionalParts { get; set; } - public List<string> LocalAlternateVersions { get; set; } - public List<LinkedChild> LinkedAlternateVersions { get; set; } + public string[] AdditionalParts { get; set; } + public string[] LocalAlternateVersions { get; set; } + public LinkedChild[] LinkedAlternateVersions { get; set; } [IgnoreDataMember] public override bool SupportsPlayedStatus @@ -52,6 +53,12 @@ namespace MediaBrowser.Controller.Entities } } + /// <summary> + /// Gets or sets the display type of the media. + /// </summary> + /// <value>The display type of the media.</value> + public string DisplayMediaType { get; set; } + [IgnoreDataMember] public override bool SupportsPositionTicksResume { @@ -77,15 +84,6 @@ namespace MediaBrowser.Controller.Entities } } - [IgnoreDataMember] - protected override bool SupportsIsInMixedFolderDetection - { - get - { - return true; - } - } - public override string CreatePresentationUniqueKey() { if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) @@ -121,7 +119,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the subtitle paths. /// </summary> /// <value>The subtitle paths.</value> - public List<string> SubtitleFiles { get; set; } + public string[] SubtitleFiles { get; set; } /// <summary> /// Gets or sets a value indicating whether this instance has subtitles. @@ -158,11 +156,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> @@ -171,6 +164,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> @@ -179,17 +177,15 @@ namespace MediaBrowser.Controller.Entities public Video() { - PlayableStreamFileNames = new List<string>(); - AdditionalParts = new List<string>(); - LocalAlternateVersions = new List<string>(); - SubtitleFiles = new List<string>(); - LinkedAlternateVersions = new List<LinkedChild>(); + AdditionalParts = EmptyStringArray; + LocalAlternateVersions = EmptyStringArray; + SubtitleFiles = EmptyStringArray; + LinkedAlternateVersions = EmptyLinkedChildArray; } public override bool CanDownload() { - if (VideoType == VideoType.HdDvd || VideoType == VideoType.Dvd || - VideoType == VideoType.BluRay) + if (VideoType == VideoType.Dvd || VideoType == VideoType.BluRay) { return false; } @@ -218,20 +214,20 @@ namespace MediaBrowser.Controller.Entities return item.MediaSourceCount; } } - return LinkedAlternateVersions.Count + LocalAlternateVersions.Count + 1; + return LinkedAlternateVersions.Length + LocalAlternateVersions.Length + 1; } } [IgnoreDataMember] public bool IsStacked { - get { return AdditionalParts.Count > 0; } + get { return AdditionalParts.Length > 0; } } [IgnoreDataMember] public bool HasLocalAlternateVersions { - get { return LocalAlternateVersions.Count > 0; } + get { return LocalAlternateVersions.Length > 0; } } public IEnumerable<Guid> GetAdditionalPartIds() @@ -339,8 +335,7 @@ namespace MediaBrowser.Controller.Entities if (!IsPlaceHolder) { - if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd || - VideoType == VideoType.HdDvd) + if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd) { return Path; } @@ -357,7 +352,7 @@ namespace MediaBrowser.Controller.Entities { if (LocationType == LocationType.FileSystem) { - if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd || VideoType == VideoType.HdDvd) + if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd) { return System.IO.Path.GetFileName(Path); } @@ -402,13 +397,52 @@ namespace MediaBrowser.Controller.Entities /// <returns>List{System.String}.</returns> public List<string> GetPlayableStreamFiles(string rootPath) { + if (VideoType == VideoType.VideoFile) + { + return new List<string>(); + } + 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> @@ -500,7 +534,7 @@ namespace MediaBrowser.Controller.Entities public override IEnumerable<FileSystemMetadata> GetDeletePaths() { - if (!DetectIsInMixedFolder()) + if (!IsInMixedFolder) { return new[] { new FileSystemMetadata @@ -514,17 +548,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() @@ -572,7 +601,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) { @@ -619,8 +648,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; @@ -639,7 +667,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 }; @@ -714,10 +741,6 @@ namespace MediaBrowser.Controller.Entities { terms.Add("DVD"); } - else if (video.VideoType == VideoType.HdDvd) - { - terms.Add("HD-DVD"); - } else if (video.VideoType == VideoType.Iso) { if (video.IsoType.HasValue) @@ -781,7 +804,7 @@ namespace MediaBrowser.Controller.Entities } } - return string.Join("/", terms.ToArray()); + return string.Join("/", terms.ToArray(terms.Count)); } } |
