mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
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")]
|
||||
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>
|
||||
/// Gets the order by.
|
||||
/// </summary>
|
||||
@ -511,6 +514,12 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
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
|
||||
if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Session;
|
||||
@ -325,7 +326,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
/// Class GetSpecialFeatures
|
||||
/// </summary>
|
||||
[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>>
|
||||
{
|
||||
/// <summary>
|
||||
@ -404,18 +405,42 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
// Get everything
|
||||
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 movie = item as Movie;
|
||||
|
||||
// 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, movie));
|
||||
.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>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
|
@ -532,6 +532,10 @@ namespace MediaBrowser.Controller.Dto
|
||||
dto.AirDays = series.AirDays;
|
||||
dto.AirTime = series.AirTime;
|
||||
dto.Status = series.Status;
|
||||
|
||||
dto.SpecialFeatureCount = series.SpecialFeatureIds.Count;
|
||||
|
||||
dto.SeasonCount = series.SeasonCount;
|
||||
}
|
||||
|
||||
if (episode != null)
|
||||
|
@ -13,9 +13,15 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
/// </summary>
|
||||
public class Series : Folder
|
||||
{
|
||||
public List<Guid> SpecialFeatureIds { get; set; }
|
||||
|
||||
public int SeasonCount { get; set; }
|
||||
|
||||
public Series()
|
||||
{
|
||||
AirDays = new List<DayOfWeek>();
|
||||
|
||||
SpecialFeatureIds = new List<Guid>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -138,6 +138,8 @@ namespace MediaBrowser.Model.Dto
|
||||
/// <value>The production year.</value>
|
||||
public int? ProductionYear { get; set; }
|
||||
|
||||
public int? SeasonCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the players supported by a game.
|
||||
/// </summary>
|
||||
|
@ -176,6 +176,8 @@ namespace MediaBrowser.Model.Querying
|
||||
/// <value>The max official rating.</value>
|
||||
public string MaxOfficialRating { get; set; }
|
||||
|
||||
public int? MinIndexNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ItemQuery"/> class.
|
||||
/// </summary>
|
||||
|
@ -107,6 +107,7 @@
|
||||
<Compile Include="TV\SeasonProviderFromXml.cs" />
|
||||
<Compile Include="TV\SeriesProviderFromXml.cs" />
|
||||
<Compile Include="TV\SeriesXmlParser.cs" />
|
||||
<Compile Include="TV\SeriesPostScanTask.cs" />
|
||||
<Compile Include="TV\TvdbPersonImageProvider.cs" />
|
||||
<Compile Include="TV\TvdbPrescanTask.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