using MediaBrowser.Model.Entities;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
namespace MediaBrowser.Controller.Entities
{
///
/// Class Video
///
public class Video : BaseItem, IHasMediaStreams
{
///
/// Gets or sets the type of the video.
///
/// The type of the video.
public VideoType VideoType { get; set; }
///
/// Gets or sets the type of the iso.
///
/// The type of the iso.
public IsoType? IsoType { get; set; }
///
/// Gets or sets the format of the video.
///
/// The format of the video.
public VideoFormat VideoFormat { get; set; }
///
/// Gets or sets the media streams.
///
/// The media streams.
public List MediaStreams { get; set; }
///
/// Gets or sets the chapters.
///
/// The chapters.
public List Chapters { get; set; }
///
/// If the video is a folder-rip, this will hold the file list for the largest playlist
///
public List PlayableStreamFileNames { get; set; }
///
/// Gets the playable stream files.
///
/// List{System.String}.
public List GetPlayableStreamFiles()
{
return GetPlayableStreamFiles(Path);
}
///
/// Gets the playable stream files.
///
/// The root path.
/// List{System.String}.
public List GetPlayableStreamFiles(string rootPath)
{
if (PlayableStreamFileNames == null)
{
return null;
}
var allFiles = Directory.EnumerateFiles(rootPath, "*", SearchOption.AllDirectories).ToList();
return PlayableStreamFileNames.Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, System.StringComparison.OrdinalIgnoreCase)))
.Where(f => !string.IsNullOrEmpty(f))
.ToList();
}
///
/// The default video stream for this video. Use this to determine media info for this item.
///
/// The default video stream.
[IgnoreDataMember]
public MediaStream DefaultVideoStream
{
get { return MediaStreams != null ? MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video) : null; }
}
///
/// Gets a value indicating whether [is3 D].
///
/// true if [is3 D]; otherwise, false.
[IgnoreDataMember]
public bool Is3D
{
get { return VideoFormat > 0; }
}
///
/// Gets the type of the media.
///
/// The type of the media.
public override string MediaType
{
get
{
return Model.Entities.MediaType.Video;
}
}
}
}