added IHasImages and IHasUserData

This commit is contained in:
Luke Pulverenti
2013-12-19 16:51:32 -05:00
parent e1e5d35434
commit cd859ac2e6
59 changed files with 1293 additions and 653 deletions

View File

@@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.MediaInfo
InputType type;
var inputPath = MediaEncoderHelpers.GetInputArgument(video, null, out type);
var inputPath = MediaEncoderHelpers.GetInputArgument(video.Path, false, video.VideoType, video.IsoType, null, video.PlayableStreamFileNames, out type);
try
{
@@ -233,33 +233,23 @@ namespace MediaBrowser.Controller.MediaInfo
/// <summary>
/// Gets the subtitle cache path.
/// </summary>
/// <param name="input">The input.</param>
/// <param name="subtitleStreamIndex">Index of the subtitle stream.</param>
/// <param name="mediaPath">The media path.</param>
/// <param name="subtitleStream">The subtitle stream.</param>
/// <param name="offset">The offset.</param>
/// <param name="outputExtension">The output extension.</param>
/// <returns>System.String.</returns>
public string GetSubtitleCachePath(Video input, int subtitleStreamIndex, TimeSpan? offset, string outputExtension)
public string GetSubtitleCachePath(string mediaPath, MediaStream subtitleStream, TimeSpan? offset, string outputExtension)
{
var ticksParam = offset.HasValue ? "_" + offset.Value.Ticks : "";
var stream = _itemRepo.GetMediaStreams(new MediaStreamQuery
if (subtitleStream.IsExternal)
{
ItemId = input.Id,
Index = subtitleStreamIndex
}).FirstOrDefault();
if (stream == null)
{
return null;
ticksParam += _fileSystem.GetLastWriteTimeUtc(subtitleStream.Path).Ticks;
}
if (stream.IsExternal)
{
ticksParam += _fileSystem.GetLastWriteTimeUtc(stream.Path).Ticks;
}
var date = _fileSystem.GetLastWriteTimeUtc(mediaPath);
var filename = (input.Id + "_" + subtitleStreamIndex.ToString(_usCulture) + "_" + input.DateModified.Ticks.ToString(_usCulture) + ticksParam).GetMD5() + outputExtension;
var filename = (mediaPath + "_" + subtitleStream.Index.ToString(_usCulture) + "_" + date.Ticks.ToString(_usCulture) + ticksParam).GetMD5() + outputExtension;
var prefix = filename.Substring(0, 1);

View File

@@ -1,5 +1,8 @@
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller.Entities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
@@ -13,43 +16,47 @@ namespace MediaBrowser.Controller.MediaInfo
/// <summary>
/// Gets the input argument.
/// </summary>
/// <param name="video">The video.</param>
/// <param name="videoPath">The video path.</param>
/// <param name="isRemote">if set to <c>true</c> [is remote].</param>
/// <param name="videoType">Type of the video.</param>
/// <param name="isoType">Type of the iso.</param>
/// <param name="isoMount">The iso mount.</param>
/// <param name="playableStreamFileNames">The playable stream file names.</param>
/// <param name="type">The type.</param>
/// <returns>System.String[][].</returns>
public static string[] GetInputArgument(Video video, IIsoMount isoMount, out InputType type)
public static string[] GetInputArgument(string videoPath, bool isRemote, VideoType videoType, IsoType? isoType, IIsoMount isoMount, IEnumerable<string> playableStreamFileNames, out InputType type)
{
var inputPath = isoMount == null ? new[] { video.Path } : new[] { isoMount.MountedPath };
var inputPath = isoMount == null ? new[] { videoPath } : new[] { isoMount.MountedPath };
type = InputType.VideoFile;
switch (video.VideoType)
switch (videoType)
{
case VideoType.BluRay:
type = InputType.Bluray;
break;
case VideoType.Dvd:
type = InputType.Dvd;
inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
inputPath = GetPlayableStreamFiles(inputPath[0], playableStreamFileNames).ToArray();
break;
case VideoType.Iso:
if (video.IsoType.HasValue)
if (isoType.HasValue)
{
switch (video.IsoType.Value)
switch (isoType.Value)
{
case IsoType.BluRay:
type = InputType.Bluray;
break;
case IsoType.Dvd:
type = InputType.Dvd;
inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
inputPath = GetPlayableStreamFiles(inputPath[0], playableStreamFileNames).ToArray();
break;
}
}
break;
case VideoType.VideoFile:
{
if (video.LocationType == LocationType.Remote)
if (isRemote)
{
type = InputType.Url;
}
@@ -60,6 +67,17 @@ namespace MediaBrowser.Controller.MediaInfo
return inputPath;
}
public static List<string> GetPlayableStreamFiles(string rootPath, IEnumerable<string> filenames)
{
var allFiles = Directory
.EnumerateFiles(rootPath, "*", SearchOption.AllDirectories)
.ToList();
return filenames.Select(name => allFiles.FirstOrDefault(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)))
.Where(f => !string.IsNullOrEmpty(f))
.ToList();
}
/// <summary>
/// Gets the type of the input.
/// </summary>