mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-19 20:54:20 +01:00
update media source methods
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
public interface IHasId
|
||||
{
|
||||
Guid Id { get; }
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,5 +65,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
int InheritedParentalRatingValue { get; set; }
|
||||
List<string> GetInheritedTags();
|
||||
List<string> InheritedTags { get; set; }
|
||||
long? RunTimeTicks { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,11 +148,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <value>The video3 D format.</value>
|
||||
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>
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user