move collections back under movies. add movie suggestions page.
This commit is contained in:
parent
38e5e32b42
commit
6825cad562
|
@ -1,9 +1,16 @@
|
|||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using ServiceStack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Api.Movies
|
||||
{
|
||||
|
@ -23,6 +30,32 @@ namespace MediaBrowser.Api.Movies
|
|||
}
|
||||
}
|
||||
|
||||
[Route("/Movies/Recommendations", "GET")]
|
||||
[Api(Description = "Gets movie recommendations")]
|
||||
public class GetMovieRecommendations : IReturn<RecommendationDto[]>, IHasItemFields
|
||||
{
|
||||
[ApiMember(Name = "CategoryLimit", Description = "The max number of categories to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int CategoryLimit { get; set; }
|
||||
|
||||
[ApiMember(Name = "ItemLimit", Description = "The max number of items to return per category", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int ItemLimit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "Optional. Filter by user id, and attach user data", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public Guid? UserId { get; set; }
|
||||
|
||||
public GetMovieRecommendations()
|
||||
{
|
||||
CategoryLimit = 5;
|
||||
ItemLimit = 8;
|
||||
}
|
||||
|
||||
public string Fields { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class MoviesService
|
||||
/// </summary>
|
||||
|
@ -78,5 +111,214 @@ namespace MediaBrowser.Api.Movies
|
|||
|
||||
return ToOptimizedSerializedResultUsingCache(result);
|
||||
}
|
||||
|
||||
public object Get(GetMovieRecommendations request)
|
||||
{
|
||||
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
||||
|
||||
var folder = user.RootFolder;
|
||||
var movies = folder.RecursiveChildren.OfType<Movie>().ToList();
|
||||
|
||||
var result = GetRecommendationCategories(user, movies, request.CategoryLimit, request.ItemLimit, request.GetItemFields().ToList());
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
private IEnumerable<RecommendationDto> GetRecommendationCategories(User user, List<Movie> allMovies, int categoryLimit, int itemLimit, List<ItemFields> fields)
|
||||
{
|
||||
var categories = new List<RecommendationDto>();
|
||||
|
||||
var recentlyPlayedMovies = allMovies
|
||||
.Select(i =>
|
||||
{
|
||||
var userdata = _userDataRepository.GetUserData(user.Id, i.GetUserDataKey());
|
||||
return new Tuple<Movie, bool, DateTime>(i, userdata.Played, userdata.LastPlayedDate ?? DateTime.MinValue);
|
||||
})
|
||||
.Where(i => i.Item2)
|
||||
.OrderByDescending(i => i.Item3)
|
||||
.Select(i => i.Item1)
|
||||
.ToList();
|
||||
|
||||
var excludeFromLiked = recentlyPlayedMovies.Take(10);
|
||||
var likedMovies = allMovies
|
||||
.Select(i =>
|
||||
{
|
||||
var score = 0;
|
||||
var userData = _userDataRepository.GetUserData(user.Id, i.GetUserDataKey());
|
||||
|
||||
if (userData.IsFavorite)
|
||||
{
|
||||
score = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
score = userData.Likes.HasValue ? userData.Likes.Value ? 1 : -1 : 0;
|
||||
}
|
||||
|
||||
return new Tuple<Movie, int>(i, score);
|
||||
})
|
||||
.OrderByDescending(i => i.Item2)
|
||||
.ThenBy(i => Guid.NewGuid())
|
||||
.Where(i => i.Item2 > 0)
|
||||
.Select(i => i.Item1)
|
||||
.Where(i => !excludeFromLiked.Contains(i));
|
||||
|
||||
var mostRecentMovies = recentlyPlayedMovies.Take(6).ToList();
|
||||
// Get recently played directors
|
||||
var recentDirectors = GetDirectors(mostRecentMovies)
|
||||
.OrderBy(i => Guid.NewGuid())
|
||||
.ToList();
|
||||
|
||||
// Get recently played actors
|
||||
var recentActors = GetActors(mostRecentMovies)
|
||||
.OrderBy(i => Guid.NewGuid())
|
||||
.ToList();
|
||||
|
||||
var similarToRecentlyPlayed = GetSimilarTo(user, allMovies, recentlyPlayedMovies.Take(10).OrderBy(i => Guid.NewGuid()), itemLimit, fields, RecommendationType.SimilarToRecentlyPlayed).GetEnumerator();
|
||||
var similarToLiked = GetSimilarTo(user, allMovies, likedMovies, itemLimit, fields, RecommendationType.SimilarToLikedItem).GetEnumerator();
|
||||
|
||||
var hasDirectorFromRecentlyPlayed = GetWithDirector(user, allMovies, recentDirectors, itemLimit, fields, RecommendationType.HasDirectorFromRecentlyPlayed).GetEnumerator();
|
||||
var hasActorFromRecentlyPlayed = GetWithActor(user, allMovies, recentActors, itemLimit, fields, RecommendationType.HasActorFromRecentlyPlayed).GetEnumerator();
|
||||
|
||||
var categoryTypes = new List<IEnumerator<RecommendationDto>>
|
||||
{
|
||||
// Give this extra weight
|
||||
similarToRecentlyPlayed,
|
||||
similarToRecentlyPlayed,
|
||||
|
||||
// Give this extra weight
|
||||
similarToLiked,
|
||||
similarToLiked,
|
||||
|
||||
hasDirectorFromRecentlyPlayed,
|
||||
hasActorFromRecentlyPlayed
|
||||
};
|
||||
|
||||
while (categories.Count < categoryLimit)
|
||||
{
|
||||
var allEmpty = true;
|
||||
|
||||
foreach (var category in categoryTypes)
|
||||
{
|
||||
if (category.MoveNext())
|
||||
{
|
||||
categories.Add(category.Current);
|
||||
allEmpty = false;
|
||||
|
||||
if (categories.Count >= categoryLimit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allEmpty)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//// Get the lead actor for all movies
|
||||
//var allActors = GetActors(allMovies)
|
||||
// .ToList();
|
||||
|
||||
//foreach (var actor in recentActors)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
return categories.OrderBy(i => i.RecommendationType).ThenBy(i => Guid.NewGuid());
|
||||
}
|
||||
|
||||
private IEnumerable<RecommendationDto> GetWithDirector(User user, List<Movie> allMovies, IEnumerable<string> directors, int itemLimit, List<ItemFields> fields, RecommendationType type)
|
||||
{
|
||||
var userId = user.Id;
|
||||
|
||||
foreach (var director in directors)
|
||||
{
|
||||
var items = allMovies
|
||||
.Where(i => !_userDataRepository.GetUserData(userId, i.GetUserDataKey()).Played && i.People.Any(p => string.Equals(p.Type, PersonType.Director, StringComparison.OrdinalIgnoreCase) && string.Equals(p.Name, director, StringComparison.OrdinalIgnoreCase)))
|
||||
.Take(itemLimit)
|
||||
.ToList();
|
||||
|
||||
if (items.Count > 0)
|
||||
{
|
||||
yield return new RecommendationDto
|
||||
{
|
||||
BaselineItemName = director,
|
||||
CategoryId = director.GetMD5().ToString("N"),
|
||||
RecommendationType = type,
|
||||
Items = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<RecommendationDto> GetWithActor(User user, List<Movie> allMovies, IEnumerable<string> names, int itemLimit, List<ItemFields> fields, RecommendationType type)
|
||||
{
|
||||
var userId = user.Id;
|
||||
|
||||
foreach (var name in names)
|
||||
{
|
||||
var items = allMovies
|
||||
.Where(i => !_userDataRepository.GetUserData(userId, i.GetUserDataKey()).Played && i.People.Any(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase)))
|
||||
.Take(itemLimit)
|
||||
.ToList();
|
||||
|
||||
if (items.Count > 0)
|
||||
{
|
||||
yield return new RecommendationDto
|
||||
{
|
||||
BaselineItemName = name,
|
||||
CategoryId = name.GetMD5().ToString("N"),
|
||||
RecommendationType = type,
|
||||
Items = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<Movie> allMovies, IEnumerable<Movie> baselineItems, int itemLimit, List<ItemFields> fields, RecommendationType type)
|
||||
{
|
||||
var userId = user.Id;
|
||||
|
||||
foreach (var item in baselineItems)
|
||||
{
|
||||
var similar = SimilarItemsHelper
|
||||
.GetSimilaritems(item, allMovies, SimilarItemsHelper.GetSimiliarityScore)
|
||||
.Where(i => !_userDataRepository.GetUserData(userId, i.GetUserDataKey()).Played)
|
||||
.Take(itemLimit)
|
||||
.ToList();
|
||||
|
||||
if (similar.Count > 0)
|
||||
{
|
||||
yield return new RecommendationDto
|
||||
{
|
||||
BaselineItemName = item.Name,
|
||||
CategoryId = item.Id.ToString("N"),
|
||||
RecommendationType = type,
|
||||
Items = similar.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetActors(IEnumerable<BaseItem> items)
|
||||
{
|
||||
// Get the two leading actors for all movies
|
||||
return items
|
||||
.SelectMany(i => i.People.Where(p => !string.Equals(PersonType.Director, p.Type, StringComparison.OrdinalIgnoreCase)).Take(2))
|
||||
.Select(i => i.Name)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetDirectors(IEnumerable<BaseItem> items)
|
||||
{
|
||||
return items
|
||||
.Select(i => i.People.FirstOrDefault(p => string.Equals(PersonType.Director, p.Type, StringComparison.OrdinalIgnoreCase)))
|
||||
.Where(i => i != null)
|
||||
.Select(i => i.Name)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace MediaBrowser.Api
|
|||
|
||||
var item = string.IsNullOrEmpty(request.Id) ?
|
||||
(request.UserId.HasValue ? user.RootFolder :
|
||||
(Folder)libraryManager.RootFolder) : dtoService.GetItemByDtoId(request.Id, request.UserId);
|
||||
libraryManager.RootFolder) : dtoService.GetItemByDtoId(request.Id, request.UserId);
|
||||
|
||||
var fields = request.GetItemFields().ToList();
|
||||
|
||||
|
@ -81,7 +81,7 @@ namespace MediaBrowser.Api
|
|||
? libraryManager.RootFolder.GetRecursiveChildren(i => i.Id != item.Id)
|
||||
: user.RootFolder.GetRecursiveChildren(user, i => i.Id != item.Id);
|
||||
|
||||
var items = GetSimilaritems(item, inputItems, includeInSearch, getSimilarityScore)
|
||||
var items = GetSimilaritems(item, inputItems.Where(includeInSearch), getSimilarityScore)
|
||||
.ToList();
|
||||
|
||||
IEnumerable<BaseItem> returnItems = items;
|
||||
|
@ -106,12 +106,12 @@ namespace MediaBrowser.Api
|
|||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="inputItems">The input items.</param>
|
||||
/// <param name="includeInSearch">The include in search.</param>
|
||||
/// <param name="getSimilarityScore">The get similarity score.</param>
|
||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
internal static IEnumerable<BaseItem> GetSimilaritems(BaseItem item, IEnumerable<BaseItem> inputItems, Func<BaseItem, bool> includeInSearch, Func<BaseItem, BaseItem, int> getSimilarityScore)
|
||||
internal static IEnumerable<BaseItem> GetSimilaritems(BaseItem item, IEnumerable<BaseItem> inputItems, Func<BaseItem, BaseItem, int> getSimilarityScore)
|
||||
{
|
||||
inputItems = inputItems.Where(includeInSearch);
|
||||
var itemId = item.Id;
|
||||
inputItems = inputItems.Where(i => i.Id != itemId);
|
||||
|
||||
return inputItems.Select(i => new Tuple<BaseItem, int>(i, getSimilarityScore(item, i)))
|
||||
.Where(i => i.Item2 > 2)
|
||||
|
|
|
@ -300,11 +300,13 @@ namespace MediaBrowser.Api
|
|||
|
||||
return FilterSeries(request, series)
|
||||
.AsParallel()
|
||||
.Select(i => GetNextUp(i, currentUser, request).Item1)
|
||||
.Where(i => i != null)
|
||||
.Select(i => GetNextUp(i, currentUser))
|
||||
.Where(i => i.Item1 != null)
|
||||
.OrderByDescending(i =>
|
||||
{
|
||||
var seriesUserData = _userDataManager.GetUserData(user.Id, i.Series.GetUserDataKey());
|
||||
var episode = i.Item1;
|
||||
|
||||
var seriesUserData = _userDataManager.GetUserData(user.Id, episode.Series.GetUserDataKey());
|
||||
|
||||
if (seriesUserData.IsFavorite)
|
||||
{
|
||||
|
@ -318,7 +320,9 @@ namespace MediaBrowser.Api
|
|||
|
||||
return 0;
|
||||
})
|
||||
.ThenByDescending(i => i.PremiereDate ?? DateTime.MinValue);
|
||||
.ThenByDescending(i =>i.Item2)
|
||||
.ThenByDescending(i => i.Item1.PremiereDate ?? DateTime.MinValue)
|
||||
.Select(i => i.Item1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -326,9 +330,8 @@ namespace MediaBrowser.Api
|
|||
/// </summary>
|
||||
/// <param name="series">The series.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{Episode}.</returns>
|
||||
private Tuple<Episode, DateTime> GetNextUp(Series series, User user, GetNextUpEpisodes request)
|
||||
private Tuple<Episode, DateTime> GetNextUp(Series series, User user)
|
||||
{
|
||||
// Get them in display order, then reverse
|
||||
var allEpisodes = series.GetSeasons(user, true, true)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -28,30 +29,31 @@ namespace MediaBrowser.Controller.Channels
|
|||
/// Searches the specified search term.
|
||||
/// </summary>
|
||||
/// <param name="searchTerm">The search term.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{ChannelItemInfo}}.</returns>
|
||||
Task<IEnumerable<ChannelItemInfo>> Search(string searchTerm, CancellationToken cancellationToken);
|
||||
|
||||
Task<IEnumerable<ChannelItemInfo>> Search(string searchTerm, User user, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel items.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{ChannelItem}}.</returns>
|
||||
Task<IEnumerable<ChannelItemInfo>> GetChannelItems(CancellationToken cancellationToken);
|
||||
Task<IEnumerable<ChannelItemInfo>> GetChannelItems(User user, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel items.
|
||||
/// </summary>
|
||||
/// <param name="categoryId">The category identifier.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{ChannelItem}}.</returns>
|
||||
Task<IEnumerable<ChannelItemInfo>> GetChannelItems(string categoryId, CancellationToken cancellationToken);
|
||||
Task<IEnumerable<ChannelItemInfo>> GetChannelItems(string categoryId, User user, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
public class ChannelCapabilities
|
||||
{
|
||||
public bool CanSearch { get; set; }
|
||||
|
||||
public bool CanBeIndexed { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Dto\ItemIndex.cs">
|
||||
<Link>Dto\ItemIndex.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\RecommendationDto.cs">
|
||||
<Link>Dto\RecommendationDto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\StreamOptions.cs">
|
||||
<Link>Dto\StreamOptions.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -121,6 +121,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Dto\ItemIndex.cs">
|
||||
<Link>Dto\ItemIndex.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\RecommendationDto.cs">
|
||||
<Link>Dto\RecommendationDto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\StreamOptions.cs">
|
||||
<Link>Dto\StreamOptions.cs</Link>
|
||||
</Compile>
|
||||
|
|
29
MediaBrowser.Model/Dto/RecommendationDto.cs
Normal file
29
MediaBrowser.Model/Dto/RecommendationDto.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
public class RecommendationDto
|
||||
{
|
||||
public BaseItemDto[] Items { get; set; }
|
||||
|
||||
public RecommendationType RecommendationType { get; set; }
|
||||
|
||||
public string BaselineItemName { get; set; }
|
||||
|
||||
public string CategoryId { get; set; }
|
||||
}
|
||||
|
||||
public enum RecommendationType
|
||||
{
|
||||
SimilarToRecentlyPlayed = 0,
|
||||
|
||||
SimilarToLikedItem = 1,
|
||||
|
||||
HasDirectorFromRecentlyPlayed = 2,
|
||||
|
||||
HasActorFromRecentlyPlayed = 3,
|
||||
|
||||
HasLikedDirector = 4,
|
||||
|
||||
HasLikedActor = 5
|
||||
}
|
||||
}
|
|
@ -46,6 +46,30 @@ namespace MediaBrowser.Model.Entities
|
|||
/// <value>The primary image tag.</value>
|
||||
public Guid? PrimaryImageTag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the thumb image tag.
|
||||
/// </summary>
|
||||
/// <value>The thumb image tag.</value>
|
||||
public Guid? ThumbImageTag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the thumb item identifier.
|
||||
/// </summary>
|
||||
/// <value>The thumb item identifier.</value>
|
||||
public string ThumbItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the thumb image tag.
|
||||
/// </summary>
|
||||
/// <value>The thumb image tag.</value>
|
||||
public Guid? BackdropImageTag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the thumb item identifier.
|
||||
/// </summary>
|
||||
/// <value>The thumb item identifier.</value>
|
||||
public string BackdropItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance has primary image.
|
||||
/// </summary>
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
<Compile Include="Dto\ItemByNameCounts.cs" />
|
||||
<Compile Include="Dto\ItemCounts.cs" />
|
||||
<Compile Include="Dto\ItemIndex.cs" />
|
||||
<Compile Include="Dto\RecommendationDto.cs" />
|
||||
<Compile Include="Entities\PackageReviewInfo.cs" />
|
||||
<Compile Include="FileOrganization\FileOrganizationResult.cs" />
|
||||
<Compile Include="FileOrganization\FileOrganizationQuery.cs" />
|
||||
|
|
|
@ -305,22 +305,20 @@ namespace MediaBrowser.Providers.Manager
|
|||
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.ImageUpdate;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(localItem.Item.Name))
|
||||
if (string.IsNullOrWhiteSpace(localItem.Item.Name))
|
||||
{
|
||||
MergeData(localItem.Item, temp, new List<MetadataFields>(), !options.ReplaceAllMetadata, true);
|
||||
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport;
|
||||
|
||||
// Only one local provider allowed per item
|
||||
hasLocalMetadata = true;
|
||||
break;
|
||||
localItem.Item.Name = item.Name ?? Path.GetFileNameWithoutExtension(item.Path);
|
||||
}
|
||||
|
||||
Logger.Error("Invalid local metadata found for: " + item.Path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Debug("{0} returned no metadata for {1}", providerName, item.Path ?? item.Name);
|
||||
MergeData(localItem.Item, temp, new List<MetadataFields>(), !options.ReplaceAllMetadata, true);
|
||||
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport;
|
||||
|
||||
// Only one local provider allowed per item
|
||||
hasLocalMetadata = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Logger.Debug("{0} returned no metadata for {1}", providerName, item.Path ?? item.Name);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
|
|
@ -307,6 +307,57 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
|
||||
info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);
|
||||
|
||||
var backropItem = item.HasImage(ImageType.Backdrop) ? item : null;
|
||||
|
||||
var thumbItem = item.HasImage(ImageType.Thumb) ? item : null;
|
||||
|
||||
if (thumbItem == null)
|
||||
{
|
||||
var episode = item as Episode;
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
var series = episode.Series;
|
||||
|
||||
if (series != null && series.HasImage(ImageType.Thumb))
|
||||
{
|
||||
thumbItem = series;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (backropItem == null)
|
||||
{
|
||||
var episode = item as Episode;
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
var series = episode.Series;
|
||||
|
||||
if (series != null && series.HasImage(ImageType.Backdrop))
|
||||
{
|
||||
backropItem = series;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (thumbItem == null)
|
||||
{
|
||||
thumbItem = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Thumb));
|
||||
}
|
||||
|
||||
if (thumbItem != null)
|
||||
{
|
||||
info.ThumbImageTag = GetImageCacheTag(thumbItem, ImageType.Thumb);
|
||||
info.ThumbItemId = GetDtoId(thumbItem);
|
||||
}
|
||||
|
||||
if (thumbItem != null)
|
||||
{
|
||||
info.BackdropImageTag = GetImageCacheTag(backropItem, ImageType.Backdrop);
|
||||
info.BackdropItemId = GetDtoId(backropItem);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using MediaBrowser.Common.ScheduledTasks;
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
|
|
|
@ -89,34 +89,31 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
|||
// Find movies with their own folders
|
||||
if (isDirectory)
|
||||
{
|
||||
if (args.Path.IndexOf("[trailers]", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return FindMovie<Trailer>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService);
|
||||
return FindMovie<Trailer>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService, false);
|
||||
}
|
||||
|
||||
if (args.Path.IndexOf("[musicvideos]", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return FindMovie<MusicVideo>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService);
|
||||
return FindMovie<MusicVideo>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService, false);
|
||||
}
|
||||
|
||||
if (args.Path.IndexOf("[adultvideos]", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
string.Equals(collectionType, CollectionType.AdultVideos, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(collectionType, CollectionType.AdultVideos, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return FindMovie<AdultVideo>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService);
|
||||
return FindMovie<AdultVideo>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService, true);
|
||||
}
|
||||
|
||||
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService);
|
||||
return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService, true);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(collectionType) ||
|
||||
string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return FindMovie<Movie>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService);
|
||||
return FindMovie<Movie>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService, true);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -202,8 +199,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
|||
/// <param name="path">The path.</param>
|
||||
/// <param name="parent">The parent.</param>
|
||||
/// <param name="fileSystemEntries">The file system entries.</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="supportMultiFileItems">if set to <c>true</c> [support multi file items].</param>
|
||||
/// <returns>Movie.</returns>
|
||||
private T FindMovie<T>(string path, Folder parent, IEnumerable<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService)
|
||||
private T FindMovie<T>(string path, Folder parent, IEnumerable<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, bool supportMultiFileItems)
|
||||
where T : Video, new()
|
||||
{
|
||||
var movies = new List<T>();
|
||||
|
@ -264,7 +263,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
|||
}
|
||||
}
|
||||
|
||||
if (movies.Count > 1)
|
||||
if (movies.Count > 1 && supportMultiFileItems)
|
||||
{
|
||||
return GetMultiFileMovie(movies);
|
||||
}
|
||||
|
|
|
@ -523,6 +523,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|||
"moviegenres.js",
|
||||
"moviecollections.js",
|
||||
"movies.js",
|
||||
"movieslatest.js",
|
||||
"moviepeople.js",
|
||||
"moviesrecommended.js",
|
||||
"moviestudios.js",
|
||||
|
|
|
@ -261,6 +261,9 @@
|
|||
<Content Include="dashboard-ui\livetvtimers.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\movieslatest.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\musicalbumartists.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@ -546,6 +549,9 @@
|
|||
<Content Include="dashboard-ui\scripts\editorsidebar.js">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\scripts\movieslatest.js">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\scripts\musicalbumartists.js">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
|
@ -254,4 +254,4 @@ Global
|
|||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
EndGlobal
|
||||
|
|
Loading…
Reference in New Issue
Block a user