Added poor man's multi-file movie support

This commit is contained in:
Luke Pulverenti
2013-06-12 17:46:50 -04:00
parent 455de48a65
commit def3428199
20 changed files with 353 additions and 54 deletions

View File

@@ -8,6 +8,7 @@ using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
{
@@ -17,7 +18,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
public class MovieResolver : BaseVideoResolver<Video>
{
private IServerApplicationPaths ApplicationPaths { get; set; }
public MovieResolver(IServerApplicationPaths appPaths)
{
ApplicationPaths = appPaths;
@@ -196,10 +197,41 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
}
}
// If there are multiple video files, return null, and let the VideoResolver catch them later as plain videos
if (movies.Count > 1)
{
return GetMultiFileMovie(movies);
}
return movies.Count == 1 ? movies[0] : null;
}
/// <summary>
/// Gets the multi file movie.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="movies">The movies.</param>
/// <returns>``0.</returns>
private T GetMultiFileMovie<T>(List<T> movies)
where T : Video, new()
{
var multiPartMovies = movies.OrderBy(i => i.Path)
.Where(i => EntityResolutionHelper.IsMultiPartFile(i.Path))
.ToList();
// They must all be part of the sequence
if (multiPartMovies.Count != movies.Count)
{
return null;
}
var firstPart = multiPartMovies[0];
firstPart.IsMultiPart = true;
return firstPart;
}
/// <summary>
/// Determines whether [is DVD directory] [the specified directory name].
/// </summary>
@@ -209,6 +241,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
{
return directoryName.Equals("video_ts", StringComparison.OrdinalIgnoreCase);
}
/// <summary>
/// Determines whether [is hd DVD directory] [the specified directory name].
/// </summary>

View File

@@ -142,9 +142,15 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
var video = item as Video;
if (video != null && video.Chapters != null)
if (video != null)
{
images = images.Concat(video.Chapters.Where(i => !string.IsNullOrEmpty(i.ImagePath)).Select(i => i.ImagePath));
if (video.Chapters != null)
{
images = images.Concat(video.Chapters.Where(i => !string.IsNullOrEmpty(i.ImagePath)).Select(i => i.ImagePath));
}
var additionalParts = _itemRepo.GetItems(video.AdditionalPartIds).ToList();
images = additionalParts.Aggregate(images, (current, subItem) => current.Concat(GetPathsInUse(subItem)));
}
var movie = item as Movie;

View File

@@ -222,6 +222,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
items.AddRange(themeVideos);
items.AddRange(videos.SelectMany(i => _itemRepo.GetItems(i.AdditionalPartIds).Cast<Video>()).ToList());
items.AddRange(videos.OfType<Movie>().SelectMany(i => _itemRepo.GetItems(i.SpecialFeatureIds).Cast<Video>()).ToList());
return items.Where(i =>