aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-08-05 15:02:33 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-08-05 15:02:33 -0400
commitdb315c4e3279a0f7c5fd5507887b32c6436b90af (patch)
treeec0b852762595883dd34f18c8ae22d42133484b4
parent3fe1c25c3ea8d6519aba3b5c3ef0d6a9154413b2 (diff)
update media source methods
-rw-r--r--Emby.Dlna/Didl/DidlBuilder.cs4
-rw-r--r--Emby.Dlna/PlayTo/PlayToController.cs2
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs25
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserDataRepository.cs2
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs4
-rw-r--r--Emby.Server.Implementations/Emby.Server.Implementations.csproj3
-rw-r--r--Emby.Server.Implementations/Library/MediaSourceManager.cs15
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs3
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/es.txt1
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/ro.txt1
-rw-r--r--Emby.Server.Implementations/MediaEncoder/EncodingManager.cs22
-rw-r--r--MediaBrowser.Controller/Entities/Audio/Audio.cs22
-rw-r--r--MediaBrowser.Controller/Entities/IHasId.cs9
-rw-r--r--MediaBrowser.Controller/Entities/IHasImages.cs2
-rw-r--r--MediaBrowser.Controller/Entities/IHasMediaSources.cs4
-rw-r--r--MediaBrowser.Controller/Entities/IHasMetadata.cs1
-rw-r--r--MediaBrowser.Controller/Entities/IHasUserData.cs7
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs66
-rw-r--r--MediaBrowser.Controller/Library/IMediaSourceManager.cs8
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs4
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvChannel.cs7
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs4
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj1
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs28
-rw-r--r--MediaBrowser.Controller/Persistence/IItemRepository.cs2
-rw-r--r--MediaBrowser.Model/Dto/MediaSourceInfo.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs4
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs78
-rw-r--r--MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs138
-rw-r--r--MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs9
31 files changed, 235 insertions, 247 deletions
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs
index a1b692d98..71a049394 100644
--- a/Emby.Dlna/Didl/DidlBuilder.cs
+++ b/Emby.Dlna/Didl/DidlBuilder.cs
@@ -193,7 +193,7 @@ namespace Emby.Dlna.Didl
{
if (streamInfo == null)
{
- var sources = _mediaSourceManager.GetStaticMediaSources(video, true, _user).ToList();
+ var sources = _mediaSourceManager.GetStaticMediaSources(video, true, _user);
streamInfo = new StreamBuilder(_mediaEncoder, GetStreamBuilderLogger(options)).BuildVideoItem(new VideoOptions
{
@@ -508,7 +508,7 @@ namespace Emby.Dlna.Didl
if (streamInfo == null)
{
- var sources = _mediaSourceManager.GetStaticMediaSources(audio, true, _user).ToList();
+ var sources = _mediaSourceManager.GetStaticMediaSources(audio, true, _user);
streamInfo = new StreamBuilder(_mediaEncoder, GetStreamBuilderLogger(options)).BuildAudioItem(new AudioOptions
{
diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs
index 15d73e824..7164cf598 100644
--- a/Emby.Dlna/PlayTo/PlayToController.cs
+++ b/Emby.Dlna/PlayTo/PlayToController.cs
@@ -503,7 +503,7 @@ namespace Emby.Dlna.PlayTo
var hasMediaSources = item as IHasMediaSources;
var mediaSources = hasMediaSources != null
- ? (_mediaSourceManager.GetStaticMediaSources(hasMediaSources, true, user)).ToList()
+ ? (_mediaSourceManager.GetStaticMediaSources(hasMediaSources, true, user))
: new List<MediaSourceInfo>();
var playlistItem = GetPlaylistItem(item, mediaSources, profile, _session.DeviceId, mediaSourceId, audioStreamIndex, subtitleStreamIndex);
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 80a5defd6..3825389bf 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -113,7 +113,7 @@ namespace Emby.Server.Implementations.Data
{
get
{
- return true;
+ return false;
}
}
@@ -1972,20 +1972,7 @@ namespace Emby.Server.Implementations.Data
/// <returns>Task{IEnumerable{ItemReview}}.</returns>
public IEnumerable<ItemReview> GetCriticReviews(Guid itemId)
{
- try
- {
- var path = Path.Combine(_criticReviewsPath, itemId + ".json");
-
- return _jsonSerializer.DeserializeFromFile<List<ItemReview>>(path);
- }
- catch (FileNotFoundException)
- {
- return new List<ItemReview>();
- }
- catch (IOException)
- {
- return new List<ItemReview>();
- }
+ return new List<ItemReview>();
}
private readonly Task _cachedTask = Task.FromResult(true);
@@ -1997,12 +1984,6 @@ namespace Emby.Server.Implementations.Data
/// <returns>Task.</returns>
public Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews)
{
- _fileSystem.CreateDirectory(_criticReviewsPath);
-
- var path = Path.Combine(_criticReviewsPath, itemId + ".json");
-
- _jsonSerializer.SerializeToFile(criticReviews.ToList(), path);
-
return _cachedTask;
}
@@ -5610,7 +5591,7 @@ namespace Emby.Server.Implementations.Data
return item;
}
- public IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query)
+ public List<MediaStream> GetMediaStreams(MediaStreamQuery query)
{
CheckDisposed();
diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
index bf6388f5d..b76555bde 100644
--- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
@@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.Data
{
get
{
- return true;
+ return false;
}
}
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index a57ee0b9b..c50e5600a 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -359,11 +359,11 @@ namespace Emby.Server.Implementations.Dto
{
if (user == null)
{
- dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true).ToList();
+ dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true);
}
else
{
- dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true, user).ToList();
+ dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true, user);
}
}
}
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index 3d6e02816..ed69c9755 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
@@ -413,6 +413,9 @@
<ItemGroup>
<EmbeddedResource Include="Localization\Ratings\es.txt" />
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Localization\Ratings\ro.txt" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs
index c1360c887..6e0489d88 100644
--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs
+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs
@@ -49,10 +49,9 @@ namespace Emby.Server.Implementations.Library
_providers = providers.ToArray();
}
- public IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query)
+ public List<MediaStream> GetMediaStreams(MediaStreamQuery query)
{
- var list = _itemRepo.GetMediaStreams(query)
- .ToList();
+ var list = _itemRepo.GetMediaStreams(query);
foreach (var stream in list)
{
@@ -77,7 +76,7 @@ namespace Emby.Server.Implementations.Library
return false;
}
- public IEnumerable<MediaStream> GetMediaStreams(string mediaSourceId)
+ public List<MediaStream> GetMediaStreams(string mediaSourceId)
{
var list = GetMediaStreams(new MediaStreamQuery
{
@@ -87,7 +86,7 @@ namespace Emby.Server.Implementations.Library
return GetMediaStreamsForItem(list);
}
- public IEnumerable<MediaStream> GetMediaStreams(Guid itemId)
+ public List<MediaStream> GetMediaStreams(Guid itemId)
{
var list = GetMediaStreams(new MediaStreamQuery
{
@@ -97,7 +96,7 @@ namespace Emby.Server.Implementations.Library
return GetMediaStreamsForItem(list);
}
- private IEnumerable<MediaStream> GetMediaStreamsForItem(IEnumerable<MediaStream> streams)
+ private List<MediaStream> GetMediaStreamsForItem(IEnumerable<MediaStream> streams)
{
var list = streams.ToList();
@@ -253,7 +252,7 @@ namespace Emby.Server.Implementations.Library
return sources.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
}
- public IEnumerable<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user = null)
+ public List<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user = null)
{
if (item == null)
{
@@ -265,7 +264,7 @@ namespace Emby.Server.Implementations.Library
return item.GetMediaSources(enablePathSubstitution);
}
- var sources = item.GetMediaSources(enablePathSubstitution).ToList();
+ var sources = item.GetMediaSources(enablePathSubstitution);
if (user != null)
{
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index 10aab4054..48c74681f 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1957,7 +1957,7 @@ namespace Emby.Server.Implementations.LiveTv
if (dto.MediaSources == null)
{
- dto.MediaSources = recording.GetMediaSources(true).ToList();
+ dto.MediaSources = recording.GetMediaSources(true);
}
if (dto.MediaStreams == null)
@@ -2365,7 +2365,7 @@ namespace Emby.Server.Implementations.LiveTv
if (addMediaSources)
{
- dto.MediaSources = channel.GetMediaSources(true).ToList();
+ dto.MediaSources = channel.GetMediaSources(true);
}
if (addCurrentProgram)
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
index 919c0f10d..a7e69776c 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
@@ -78,8 +78,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var hasMediaSources = (IHasMediaSources)item;
- sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false)
- .ToList();
+ sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false);
forceRequireOpening = true;
}
diff --git a/Emby.Server.Implementations/Localization/Ratings/es.txt b/Emby.Server.Implementations/Localization/Ratings/es.txt
index 1ba24fb99..32a1e6438 100644
--- a/Emby.Server.Implementations/Localization/Ratings/es.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/es.txt
@@ -1,4 +1,5 @@
ES-A,1
+ES-APTA,1
ES-7,3
ES-12,6
ES-16,8
diff --git a/Emby.Server.Implementations/Localization/Ratings/ro.txt b/Emby.Server.Implementations/Localization/Ratings/ro.txt
new file mode 100644
index 000000000..3fdaed9cc
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/ro.txt
@@ -0,0 +1 @@
+RO-AG,1 \ No newline at end of file
diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
index e4eb41e3a..181a49034 100644
--- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
+++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
@@ -29,9 +29,9 @@ namespace Emby.Server.Implementations.MediaEncoder
private readonly IChapterManager _chapterManager;
private readonly ILibraryManager _libraryManager;
- public EncodingManager(IFileSystem fileSystem,
- ILogger logger,
- IMediaEncoder encoder,
+ public EncodingManager(IFileSystem fileSystem,
+ ILogger logger,
+ IMediaEncoder encoder,
IChapterManager chapterManager, ILibraryManager libraryManager)
{
_fileSystem = fileSystem;
@@ -121,12 +121,16 @@ namespace Emby.Server.Implementations.MediaEncoder
{
continue;
}
+
+ List<string> playableStreamFileNames = null;
if (video.VideoType == VideoType.BluRay || video.VideoType == VideoType.Dvd)
{
- if (video.PlayableStreamFileNames.Count != 1)
- {
- continue;
- }
+ continue;
+ }
+
+ if (playableStreamFileNames == null)
+ {
+ playableStreamFileNames = new List<string>();
}
try
@@ -136,7 +140,7 @@ namespace Emby.Server.Implementations.MediaEncoder
var protocol = MediaProtocol.File;
- var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, video.PlayableStreamFileNames);
+ var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, playableStreamFileNames);
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
@@ -151,7 +155,7 @@ namespace Emby.Server.Implementations.MediaEncoder
}
catch
{
-
+
}
chapter.ImagePath = path;
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&lt;MediaStream&gt;.</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&lt;MediaStream&gt;.</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&lt;MediaStream&gt;.</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&lt;MediaSourceInfo&gt;.</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.
diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs
index a70e74774..1bf67f66c 100644
--- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs
+++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs
@@ -53,7 +53,6 @@ namespace MediaBrowser.Model.Dto
public Video3DFormat? Video3DFormat { get; set; }
public List<MediaStream> MediaStreams { get; set; }
- public List<string> PlayableStreamFileNames { get; set; }
public List<string> Formats { get; set; }
@@ -73,7 +72,6 @@ namespace MediaBrowser.Model.Dto
Formats = new List<string>();
MediaStreams = new List<MediaStream>();
RequiredHttpHeaders = new Dictionary<string, string>();
- PlayableStreamFileNames = new List<string>();
SupportsTranscoding = true;
SupportsDirectStream = true;
SupportsDirectPlay = true;
diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
index cc5e7aef9..e406932ed 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
@@ -41,9 +41,7 @@ namespace MediaBrowser.Providers.MediaInfo
var audio = (Audio)item;
var imageStreams =
- audio.GetMediaSources(false)
- .Take(1)
- .SelectMany(i => i.MediaStreams)
+ audio.GetMediaStreams(MediaStreamType.EmbeddedImage)
.Where(i => i.Type == MediaStreamType.EmbeddedImage)
.ToList();
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
index 06267f33a..143ec8fdd 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
@@ -80,35 +80,45 @@ namespace MediaBrowser.Providers.MediaInfo
try
{
- if (item.VideoType == VideoType.BluRay || (item.IsoType.HasValue && item.IsoType == IsoType.BluRay))
- {
- var inputPath = isoMount != null ? isoMount.MountedPath : item.Path;
+ List<string> streamFileNames = null;
- blurayDiscInfo = GetBDInfo(inputPath);
+ if (item.VideoType == VideoType.Iso)
+ {
+ item.IsoType = DetermineIsoType(isoMount);
}
- OnPreFetch(item, isoMount, blurayDiscInfo);
-
- // If we didn't find any satisfying the min length, just take them all
if (item.VideoType == VideoType.Dvd || (item.IsoType.HasValue && item.IsoType == IsoType.Dvd))
{
- if (item.PlayableStreamFileNames.Count == 0)
+ streamFileNames = FetchFromDvdLib(item, isoMount);
+
+ if (streamFileNames.Count == 0)
{
_logger.Error("No playable vobs found in dvd structure, skipping ffprobe.");
return ItemUpdateType.MetadataImport;
}
}
- if (item.VideoType == VideoType.BluRay || (item.IsoType.HasValue && item.IsoType == IsoType.BluRay))
+ else if (item.VideoType == VideoType.BluRay || (item.IsoType.HasValue && item.IsoType == IsoType.BluRay))
{
- if (item.PlayableStreamFileNames.Count == 0)
+ var inputPath = isoMount != null ? isoMount.MountedPath : item.Path;
+
+ blurayDiscInfo = GetBDInfo(inputPath);
+
+ streamFileNames = blurayDiscInfo.Files;
+
+ if (streamFileNames.Count == 0)
{
_logger.Error("No playable vobs found in bluray structure, skipping ffprobe.");
return ItemUpdateType.MetadataImport;
}
}
- var result = await GetMediaInfo(item, isoMount, cancellationToken).ConfigureAwait(false);
+ if (streamFileNames == null)
+ {
+ streamFileNames = new List<string>();
+ }
+
+ var result = await GetMediaInfo(item, isoMount, streamFileNames, cancellationToken).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested();
@@ -126,10 +136,9 @@ namespace MediaBrowser.Providers.MediaInfo
return ItemUpdateType.MetadataImport;
}
- private const string SchemaVersion = "6";
-
- private async Task<Model.MediaInfo.MediaInfo> GetMediaInfo(Video item,
+ private Task<Model.MediaInfo.MediaInfo> GetMediaInfo(Video item,
IIsoMount isoMount,
+ List<string> streamFileNames,
CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -138,9 +147,9 @@ namespace MediaBrowser.Providers.MediaInfo
? MediaProtocol.Http
: MediaProtocol.File;
- var result = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest
+ return _mediaEncoder.GetMediaInfo(new MediaInfoRequest
{
- PlayableStreamFileNames = item.PlayableStreamFileNames,
+ PlayableStreamFileNames = streamFileNames,
MountedIso = isoMount,
ExtractChapters = true,
VideoType = item.VideoType,
@@ -148,12 +157,7 @@ namespace MediaBrowser.Providers.MediaInfo
InputPath = item.Path,
Protocol = protocol
- }, cancellationToken).ConfigureAwait(false);
-
- //Directory.CreateDirectory(_fileSystem.GetDirectoryName(cachePath));
- //_json.SerializeToFile(result, cachePath);
-
- return result;
+ }, cancellationToken);
}
protected async Task Fetch(Video video,
@@ -266,7 +270,7 @@ namespace MediaBrowser.Providers.MediaInfo
{
var video = (Video)item;
- video.PlayableStreamFileNames = blurayInfo.Files.ToList();
+ //video.PlayableStreamFileNames = blurayInfo.Files.ToList();
// Use BD Info if it has multiple m2ts. Otherwise, treat it like a video file and rely more on ffprobe output
if (blurayInfo.Files.Count > 1)
@@ -559,31 +563,7 @@ namespace MediaBrowser.Providers.MediaInfo
}
}
- /// <summary>
- /// Called when [pre fetch].
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="mount">The mount.</param>
- /// <param name="blurayDiscInfo">The bluray disc information.</param>
- private void OnPreFetch(Video item, IIsoMount mount, BlurayDiscInfo blurayDiscInfo)
- {
- if (item.VideoType == VideoType.Iso)
- {
- item.IsoType = DetermineIsoType(mount);
- }
-
- if (item.VideoType == VideoType.Dvd || (item.IsoType.HasValue && item.IsoType == IsoType.Dvd))
- {
- FetchFromDvdLib(item, mount);
- }
-
- if (blurayDiscInfo != null)
- {
- item.PlayableStreamFileNames = blurayDiscInfo.Files.ToList();
- }
- }
-
- private void FetchFromDvdLib(Video item, IIsoMount mount)
+ private List<string> FetchFromDvdLib(Video item, IIsoMount mount)
{
var path = mount == null ? item.Path : mount.MountedPath;
var dvd = new Dvd(path, _fileSystem);
@@ -598,7 +578,7 @@ namespace MediaBrowser.Providers.MediaInfo
item.RunTimeTicks = GetRuntime(primaryTitle);
}
- item.PlayableStreamFileNames = GetPrimaryPlaylistVobFiles(item, mount, titleNumber)
+ return GetPrimaryPlaylistVobFiles(item, mount, titleNumber)
.Select(Path.GetFileName)
.ToList();
}
diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
index bb1c4e647..cdf5772c2 100644
--- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
@@ -18,44 +18,17 @@ namespace MediaBrowser.Providers.MediaInfo
{
public class VideoImageProvider : IDynamicImageProvider, IHasItemChangeMonitor, IHasOrder
{
- private readonly IIsoManager _isoManager;
private readonly IMediaEncoder _mediaEncoder;
- private readonly IServerConfigurationManager _config;
- private readonly ILibraryManager _libraryManager;
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
- public VideoImageProvider(IIsoManager isoManager, IMediaEncoder mediaEncoder, IServerConfigurationManager config, ILibraryManager libraryManager, ILogger logger, IFileSystem fileSystem)
+ public VideoImageProvider(IMediaEncoder mediaEncoder, ILogger logger, IFileSystem fileSystem)
{
- _isoManager = isoManager;
_mediaEncoder = mediaEncoder;
- _config = config;
- _libraryManager = libraryManager;
_logger = logger;
_fileSystem = fileSystem;
}
- /// <summary>
- /// The null mount task result
- /// </summary>
- protected readonly Task<IIsoMount> NullMountTaskResult = Task.FromResult<IIsoMount>(null);
-
- /// <summary>
- /// Mounts the iso if needed.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task{IIsoMount}.</returns>
- protected Task<IIsoMount> MountIsoIfNeeded(Video item, CancellationToken cancellationToken)
- {
- if (item.VideoType == VideoType.Iso)
- {
- return _isoManager.Mount(item.Path, cancellationToken);
- }
-
- return NullMountTaskResult;
- }
-
public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
{
return new List<ImageType> { ImageType.Primary };
@@ -71,8 +44,8 @@ namespace MediaBrowser.Providers.MediaInfo
return Task.FromResult(new DynamicImageResponse { HasImage = false });
}
- // Can't extract from iso's if we weren't unable to determine iso type
- if (video.VideoType == VideoType.Iso && !video.IsoType.HasValue)
+ // No support for this
+ if (video.VideoType == VideoType.Iso)
{
return Task.FromResult(new DynamicImageResponse { HasImage = false });
}
@@ -89,81 +62,66 @@ namespace MediaBrowser.Providers.MediaInfo
public async Task<DynamicImageResponse> GetVideoImage(Video item, CancellationToken cancellationToken)
{
- var isoMount = await MountIsoIfNeeded(item, cancellationToken).ConfigureAwait(false);
-
- try
- {
- var protocol = item.LocationType == LocationType.Remote
- ? MediaProtocol.Http
- : MediaProtocol.File;
+ var protocol = item.LocationType == LocationType.Remote
+ ? MediaProtocol.Http
+ : MediaProtocol.File;
- var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, item.Path, protocol, isoMount, item.PlayableStreamFileNames);
+ var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, item.Path, protocol, null, item.GetPlayableStreamFileNames());
- var mediaStreams =
- item.GetMediaSources(false)
- .Take(1)
- .SelectMany(i => i.MediaStreams)
- .ToList();
+ var mediaStreams =
+ item.GetMediaStreams();
- var imageStreams =
- mediaStreams
- .Where(i => i.Type == MediaStreamType.EmbeddedImage)
- .ToList();
+ var imageStreams =
+ mediaStreams
+ .Where(i => i.Type == MediaStreamType.EmbeddedImage)
+ .ToList();
- var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("front", StringComparison.OrdinalIgnoreCase) != -1) ??
- imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("cover", StringComparison.OrdinalIgnoreCase) != -1) ??
- imageStreams.FirstOrDefault();
+ var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("front", StringComparison.OrdinalIgnoreCase) != -1) ??
+ imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("cover", StringComparison.OrdinalIgnoreCase) != -1) ??
+ imageStreams.FirstOrDefault();
- string extractedImagePath;
+ string extractedImagePath;
- if (imageStream != null)
+ if (imageStream != null)
+ {
+ // Instead of using the raw stream index, we need to use nth video/embedded image stream
+ var videoIndex = -1;
+ foreach (var mediaStream in mediaStreams)
{
- // Instead of using the raw stream index, we need to use nth video/embedded image stream
- var videoIndex = -1;
- foreach (var mediaStream in mediaStreams)
+ if (mediaStream.Type == MediaStreamType.Video ||
+ mediaStream.Type == MediaStreamType.EmbeddedImage)
{
- if (mediaStream.Type == MediaStreamType.Video ||
- mediaStream.Type == MediaStreamType.EmbeddedImage)
- {
- videoIndex++;
- }
- if (mediaStream == imageStream)
- {
- break;
- }
+ videoIndex++;
+ }
+ if (mediaStream == imageStream)
+ {
+ break;
}
-
- extractedImagePath = await _mediaEncoder.ExtractVideoImage(inputPath, item.Container, protocol, imageStream, videoIndex, cancellationToken).ConfigureAwait(false);
}
- else
- {
- // If we know the duration, grab it from 10% into the video. Otherwise just 10 seconds in.
- // Always use 10 seconds for dvd because our duration could be out of whack
- var imageOffset = item.VideoType != VideoType.Dvd && item.RunTimeTicks.HasValue &&
- item.RunTimeTicks.Value > 0
- ? TimeSpan.FromTicks(Convert.ToInt64(item.RunTimeTicks.Value * .1))
- : TimeSpan.FromSeconds(10);
- var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
+ extractedImagePath = await _mediaEncoder.ExtractVideoImage(inputPath, item.Container, protocol, imageStream, videoIndex, cancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ // If we know the duration, grab it from 10% into the video. Otherwise just 10 seconds in.
+ // Always use 10 seconds for dvd because our duration could be out of whack
+ var imageOffset = item.VideoType != VideoType.Dvd && item.RunTimeTicks.HasValue &&
+ item.RunTimeTicks.Value > 0
+ ? TimeSpan.FromTicks(Convert.ToInt64(item.RunTimeTicks.Value * .1))
+ : TimeSpan.FromSeconds(10);
- extractedImagePath = await _mediaEncoder.ExtractVideoImage(inputPath, item.Container, protocol, videoStream, item.Video3DFormat, imageOffset, cancellationToken).ConfigureAwait(false);
- }
+ var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
- return new DynamicImageResponse
- {
- Format = ImageFormat.Jpg,
- HasImage = true,
- Path = extractedImagePath,
- Protocol = MediaProtocol.File
- };
+ extractedImagePath = await _mediaEncoder.ExtractVideoImage(inputPath, item.Container, protocol, videoStream, item.Video3DFormat, imageOffset, cancellationToken).ConfigureAwait(false);
}
- finally
+
+ return new DynamicImageResponse
{
- if (isoMount != null)
- {
- isoMount.Dispose();
- }
- }
+ Format = ImageFormat.Jpg,
+ HasImage = true,
+ Path = extractedImagePath,
+ Protocol = MediaProtocol.File
+ };
}
public string Name
diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
index 510e6e252..f37b9442c 100644
--- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
+++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
@@ -300,9 +300,9 @@ namespace MediaBrowser.XbmcMetadata.Savers
writer.WriteStartElement("fileinfo");
writer.WriteStartElement("streamdetails");
- var mediaSource = item.GetMediaSources(false).First();
+ var mediaStreams = item.GetMediaStreams();
- foreach (var stream in mediaSource.MediaStreams)
+ foreach (var stream in mediaStreams)
{
writer.WriteStartElement(stream.Type.ToString().ToLower());
@@ -378,9 +378,10 @@ namespace MediaBrowser.XbmcMetadata.Savers
if (stream.Type == MediaStreamType.Video)
{
- if (mediaSource.RunTimeTicks.HasValue)
+ var runtimeTicks = ((IHasMetadata) item).RunTimeTicks;
+ if (runtimeTicks.HasValue)
{
- var timespan = TimeSpan.FromTicks(mediaSource.RunTimeTicks.Value);
+ var timespan = TimeSpan.FromTicks(runtimeTicks.Value);
writer.WriteElementString("duration", Convert.ToInt32(timespan.TotalMinutes).ToString(UsCulture));
writer.WriteElementString("durationinseconds", Convert.ToInt32(timespan.TotalSeconds).ToString(UsCulture));