Query media streams by type instead of filtering
This commit is contained in:
parent
c32a421ea7
commit
7cf5767949
|
@ -126,15 +126,6 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
return base.GetBlockUnratedType();
|
||||
}
|
||||
|
||||
public List<MediaStream> GetMediaStreams(MediaStreamType type)
|
||||
{
|
||||
return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
|
||||
{
|
||||
ItemId = Id,
|
||||
Type = type
|
||||
});
|
||||
}
|
||||
|
||||
public SongInfo GetLookupInfo()
|
||||
{
|
||||
var info = GetItemLookupInfo<SongInfo>();
|
||||
|
|
|
@ -1107,10 +1107,16 @@ namespace MediaBrowser.Controller.Entities
|
|||
}
|
||||
|
||||
public virtual List<MediaStream> GetMediaStreams()
|
||||
{
|
||||
return GetMediaStreams(null);
|
||||
}
|
||||
|
||||
public virtual List<MediaStream> GetMediaStreams(MediaStreamType? type)
|
||||
{
|
||||
return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
|
||||
{
|
||||
ItemId = Id
|
||||
ItemId = Id,
|
||||
Type = type
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -49,10 +49,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
{
|
||||
var audio = (Audio)item;
|
||||
|
||||
var imageStreams =
|
||||
audio.GetMediaStreams(MediaStreamType.EmbeddedImage)
|
||||
.Where(i => i.Type == MediaStreamType.EmbeddedImage)
|
||||
.ToList();
|
||||
var imageStreams = audio.GetMediaStreams(MediaStreamType.EmbeddedImage);
|
||||
|
||||
// Can't extract if we didn't find a video stream in the file
|
||||
if (imageStreams.Count == 0)
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
}
|
||||
|
||||
// Fall back to EmbeddedImage streams
|
||||
var imageStreams = item.GetMediaStreams().FindAll(i => i.Type == MediaStreamType.EmbeddedImage);
|
||||
var imageStreams = item.GetMediaStreams(MediaStreamType.EmbeddedImage);
|
||||
|
||||
if (imageStreams.Count == 0)
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
? TimeSpan.FromTicks(item.RunTimeTicks.Value / 10)
|
||||
: TimeSpan.FromSeconds(10);
|
||||
|
||||
var videoStream = item.GetDefaultVideoStream() ?? item.GetMediaStreams().FirstOrDefault(i => i.Type == MediaStreamType.Video);
|
||||
var videoStream = item.GetDefaultVideoStream() ?? item.GetMediaStreams(MediaStreamType.Video).FirstOrDefault();
|
||||
|
||||
if (videoStream == null)
|
||||
{
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
|
|||
|
||||
movie.Setup(item => item.GetMediaSources(It.IsAny<bool>()))
|
||||
.Returns(new List<MediaSourceInfo> { new () { MediaAttachments = mediaAttachments } } );
|
||||
movie.Setup(item => item.GetMediaStreams())
|
||||
movie.Setup(item => item.GetMediaStreams(MediaStreamType.EmbeddedImage))
|
||||
.Returns(mediaStreams);
|
||||
|
||||
return movie.Object;
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
|
|||
|
||||
movie.Setup(item => item.GetDefaultVideoStream())
|
||||
.Returns(defaultStream!);
|
||||
movie.Setup(item => item.GetMediaStreams())
|
||||
movie.Setup(item => item.GetMediaStreams(MediaStreamType.Video))
|
||||
.Returns(mediaStreams);
|
||||
|
||||
return movie.Object;
|
||||
|
|
Loading…
Reference in New Issue
Block a user