added new properties and endpoints for series special features
This commit is contained in:
parent
e031694a99
commit
b538dc31b1
|
@ -172,6 +172,9 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
[ApiMember(Name = "AdjacentTo", Description = "Optional. Return items that are siblings of a supplied item.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "AdjacentTo", Description = "Optional. Return items that are siblings of a supplied item.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string AdjacentTo { get; set; }
|
public string AdjacentTo { get; set; }
|
||||||
|
|
||||||
|
[ApiMember(Name = "MinIndexNumber", Description = "Optional filter index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||||
|
public int? MinIndexNumber { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the order by.
|
/// Gets the order by.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -511,6 +514,12 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
items = items.Where(i => i.Id == previousId || i.Id == nextId);
|
items = items.Where(i => i.Id == previousId || i.Id == nextId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Min index number
|
||||||
|
if (request.MinIndexNumber.HasValue)
|
||||||
|
{
|
||||||
|
items = items.Where(i => i.IndexNumber.HasValue && i.IndexNumber.Value >= request.MinIndexNumber.Value);
|
||||||
|
}
|
||||||
|
|
||||||
// Min official rating
|
// Min official rating
|
||||||
if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Movies;
|
using MediaBrowser.Controller.Entities.Movies;
|
||||||
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
|
@ -325,7 +326,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// Class GetSpecialFeatures
|
/// Class GetSpecialFeatures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("/Users/{UserId}/Items/{Id}/SpecialFeatures", "GET")]
|
[Route("/Users/{UserId}/Items/{Id}/SpecialFeatures", "GET")]
|
||||||
[Api(Description = "Gets special features for a movie")]
|
[Api(Description = "Gets special features for an item")]
|
||||||
public class GetSpecialFeatures : IReturn<List<BaseItemDto>>
|
public class GetSpecialFeatures : IReturn<List<BaseItemDto>>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -404,16 +405,40 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
// Get everything
|
// Get everything
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
||||||
|
|
||||||
var movie = (Movie)item;
|
|
||||||
|
|
||||||
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
|
||||||
|
|
||||||
var tasks = movie.SpecialFeatureIds
|
var movie = item as Movie;
|
||||||
.Select(_itemRepo.RetrieveItem)
|
|
||||||
.OrderBy(i => i.SortName)
|
|
||||||
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, movie));
|
|
||||||
|
|
||||||
return Task.WhenAll(tasks);
|
// Get them from the db
|
||||||
|
if (movie != null)
|
||||||
|
{
|
||||||
|
// Avoid implicitly captured closure
|
||||||
|
var movie1 = movie;
|
||||||
|
|
||||||
|
var tasks = movie.SpecialFeatureIds
|
||||||
|
.Select(_itemRepo.RetrieveItem)
|
||||||
|
.OrderBy(i => i.SortName)
|
||||||
|
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, movie1));
|
||||||
|
|
||||||
|
return Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
var series = item as Series;
|
||||||
|
|
||||||
|
// Get them from the child tree
|
||||||
|
if (series != null)
|
||||||
|
{
|
||||||
|
var tasks = series
|
||||||
|
.RecursiveChildren
|
||||||
|
.OfType<Episode>()
|
||||||
|
.Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
|
||||||
|
.OrderBy(i => i.SortName)
|
||||||
|
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user));
|
||||||
|
|
||||||
|
return Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("The item does not support special features");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -589,7 +614,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
|
|
||||||
return DtoBuilder.GetUserItemDataDto(data);
|
return DtoBuilder.GetUserItemDataDto(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Posts the specified request.
|
/// Posts the specified request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace MediaBrowser.Controller.Dto
|
||||||
.Select(i => i.ToString("N"))
|
.Select(i => i.ToString("N"))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure all the tasks we kicked off have completed.
|
// Make sure all the tasks we kicked off have completed.
|
||||||
if (tasks.Count > 0)
|
if (tasks.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -532,6 +532,10 @@ namespace MediaBrowser.Controller.Dto
|
||||||
dto.AirDays = series.AirDays;
|
dto.AirDays = series.AirDays;
|
||||||
dto.AirTime = series.AirTime;
|
dto.AirTime = series.AirTime;
|
||||||
dto.Status = series.Status;
|
dto.Status = series.Status;
|
||||||
|
|
||||||
|
dto.SpecialFeatureCount = series.SpecialFeatureIds.Count;
|
||||||
|
|
||||||
|
dto.SeasonCount = series.SeasonCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (episode != null)
|
if (episode != null)
|
||||||
|
@ -579,7 +583,7 @@ namespace MediaBrowser.Controller.Dto
|
||||||
{
|
{
|
||||||
dto.SeriesName = item.SeriesName;
|
dto.SeriesName = item.SeriesName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetMusicVideoProperties(BaseItemDto dto, MusicVideo item)
|
private void SetMusicVideoProperties(BaseItemDto dto, MusicVideo item)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(item.Album))
|
if (!string.IsNullOrEmpty(item.Album))
|
||||||
|
|
|
@ -13,9 +13,15 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Series : Folder
|
public class Series : Folder
|
||||||
{
|
{
|
||||||
|
public List<Guid> SpecialFeatureIds { get; set; }
|
||||||
|
|
||||||
|
public int SeasonCount { get; set; }
|
||||||
|
|
||||||
public Series()
|
public Series()
|
||||||
{
|
{
|
||||||
AirDays = new List<DayOfWeek>();
|
AirDays = new List<DayOfWeek>();
|
||||||
|
|
||||||
|
SpecialFeatureIds = new List<Guid>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -138,6 +138,8 @@ namespace MediaBrowser.Model.Dto
|
||||||
/// <value>The production year.</value>
|
/// <value>The production year.</value>
|
||||||
public int? ProductionYear { get; set; }
|
public int? ProductionYear { get; set; }
|
||||||
|
|
||||||
|
public int? SeasonCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the players supported by a game.
|
/// Gets or sets the players supported by a game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -176,6 +176,8 @@ namespace MediaBrowser.Model.Querying
|
||||||
/// <value>The max official rating.</value>
|
/// <value>The max official rating.</value>
|
||||||
public string MaxOfficialRating { get; set; }
|
public string MaxOfficialRating { get; set; }
|
||||||
|
|
||||||
|
public int? MinIndexNumber { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ItemQuery"/> class.
|
/// Initializes a new instance of the <see cref="ItemQuery"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -107,6 +107,7 @@
|
||||||
<Compile Include="TV\SeasonProviderFromXml.cs" />
|
<Compile Include="TV\SeasonProviderFromXml.cs" />
|
||||||
<Compile Include="TV\SeriesProviderFromXml.cs" />
|
<Compile Include="TV\SeriesProviderFromXml.cs" />
|
||||||
<Compile Include="TV\SeriesXmlParser.cs" />
|
<Compile Include="TV\SeriesXmlParser.cs" />
|
||||||
|
<Compile Include="TV\SeriesPostScanTask.cs" />
|
||||||
<Compile Include="TV\TvdbPersonImageProvider.cs" />
|
<Compile Include="TV\TvdbPersonImageProvider.cs" />
|
||||||
<Compile Include="TV\TvdbPrescanTask.cs" />
|
<Compile Include="TV\TvdbPrescanTask.cs" />
|
||||||
<Compile Include="TV\TvdbSeriesImageProvider.cs" />
|
<Compile Include="TV\TvdbSeriesImageProvider.cs" />
|
||||||
|
|
64
MediaBrowser.Providers/TV/SeriesPostScanTask.cs
Normal file
64
MediaBrowser.Providers/TV/SeriesPostScanTask.cs
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Providers.TV
|
||||||
|
{
|
||||||
|
class SeriesPostScanTask : ILibraryPostScanTask
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The _library manager
|
||||||
|
/// </summary>
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
|
public SeriesPostScanTask(ILibraryManager libraryManager)
|
||||||
|
{
|
||||||
|
_libraryManager = libraryManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return Task.Run(() => RunInternal(progress, cancellationToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunInternal(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var seriesList = _libraryManager.RootFolder
|
||||||
|
.RecursiveChildren
|
||||||
|
.OfType<Series>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var numComplete = 0;
|
||||||
|
|
||||||
|
foreach (var series in seriesList)
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var episodes = series.RecursiveChildren
|
||||||
|
.OfType<Episode>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
series.SpecialFeatureIds = episodes
|
||||||
|
.Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
|
||||||
|
.Select(i => i.Id)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
series.SeasonCount = episodes
|
||||||
|
.Select(i => i.ParentIndexNumber ?? 0)
|
||||||
|
.Where(i => i != 0)
|
||||||
|
.Distinct()
|
||||||
|
.Count();
|
||||||
|
|
||||||
|
numComplete++;
|
||||||
|
double percent = numComplete;
|
||||||
|
percent /= seriesList.Count;
|
||||||
|
percent *= 100;
|
||||||
|
|
||||||
|
progress.Report(percent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user