mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 02:18:54 -07:00
Create new series backend implementation
This commit is contained in:
parent
26cf0df9ce
commit
5bc7089990
@ -54,7 +54,7 @@ namespace MediaBrowser.Api.Library
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Library/FileOrganizations/{Id}/Episode/Organize", "POST", Summary = "Performs an organization")]
|
||||
[Route("/Library/FileOrganizations/{Id}/Episode/Organize", "POST", Summary = "Performs organization of a tv episode")]
|
||||
public class OrganizeEpisode
|
||||
{
|
||||
[ApiMember(Name = "Id", Description = "Result Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||
@ -74,6 +74,18 @@ namespace MediaBrowser.Api.Library
|
||||
|
||||
[ApiMember(Name = "RememberCorrection", Description = "Whether or not to apply the same correction to future episodes of the same series.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
|
||||
public bool RememberCorrection { get; set; }
|
||||
|
||||
[ApiMember(Name = "NewSeriesProviderIds", Description = "A list of provider IDs identifying a new series.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string NewSeriesProviderIds { get; set; }
|
||||
|
||||
[ApiMember(Name = "NewSeriesName", Description = "Name of a series to add.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string NewSeriesName { get; set; }
|
||||
|
||||
[ApiMember(Name = "NewSeriesYear", Description = "Year of a series to add.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string NewSeriesYear { get; set; }
|
||||
|
||||
[ApiMember(Name = "TargetFolder", Description = "Target Folder", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string TargetFolder { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Library/FileOrganizations/SmartMatches", "GET", Summary = "Gets smart match entries")]
|
||||
@ -152,9 +164,17 @@ namespace MediaBrowser.Api.Library
|
||||
RememberCorrection = request.RememberCorrection,
|
||||
ResultId = request.Id,
|
||||
SeasonNumber = request.SeasonNumber,
|
||||
SeriesId = request.SeriesId
|
||||
SeriesId = request.SeriesId,
|
||||
NewSeriesName = request.NewSeriesName,
|
||||
NewSeriesYear = request.NewSeriesYear,
|
||||
NewSeriesProviderIds = request.NewSeriesProviderIds,
|
||||
TargetFolder = request.TargetFolder
|
||||
});
|
||||
|
||||
// For async processing (close dialog early instead of waiting until the file has been copied)
|
||||
//var tasks = new Task[] { task };
|
||||
//Task.WaitAll(tasks, 8000);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace MediaBrowser.Model.FileOrganization
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Model.FileOrganization
|
||||
{
|
||||
public class EpisodeFileOrganizationRequest
|
||||
{
|
||||
@ -13,5 +15,38 @@
|
||||
public int? EndingEpisodeNumber { get; set; }
|
||||
|
||||
public bool RememberCorrection { get; set; }
|
||||
public string NewSeriesName { get; set; }
|
||||
|
||||
public string NewSeriesYear { get; set; }
|
||||
|
||||
public string NewSeriesProviderIds { get; set; }
|
||||
|
||||
public string TargetFolder { get; set; }
|
||||
|
||||
public Dictionary<string, string> NewSeriesProviderIdsDictionary
|
||||
{
|
||||
get
|
||||
{
|
||||
var dic = new Dictionary<string, string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(NewSeriesProviderIds))
|
||||
{
|
||||
var str = NewSeriesProviderIds.Replace("{", "").Replace("}", "").Replace("\"", "");
|
||||
|
||||
foreach (var item in str.Split(','))
|
||||
{
|
||||
var itemArr = item.Split(':');
|
||||
if (itemArr.Length > 1)
|
||||
{
|
||||
var key = itemArr[0].Trim();
|
||||
var val = itemArr[1].Trim();
|
||||
dic.Add(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dic;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -157,7 +157,43 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
{
|
||||
var result = _organizationService.GetResult(request.ResultId);
|
||||
|
||||
var series = (Series)_libraryManager.GetItemById(new Guid(request.SeriesId));
|
||||
Series series = null;
|
||||
|
||||
if (request.NewSeriesProviderIdsDictionary.Count > 0)
|
||||
{
|
||||
// We're having a new series here
|
||||
SeriesInfo seriesRequest = new SeriesInfo();
|
||||
seriesRequest.ProviderIds = request.NewSeriesProviderIdsDictionary;
|
||||
|
||||
var refreshOptions = new MetadataRefreshOptions(_fileSystem);
|
||||
series = new Series();
|
||||
series.Id = Guid.NewGuid();
|
||||
series.Name = request.NewSeriesName;
|
||||
|
||||
int year;
|
||||
if (int.TryParse(request.NewSeriesYear, out year))
|
||||
{
|
||||
series.ProductionYear = year;
|
||||
}
|
||||
|
||||
var seriesFolderName = series.Name;
|
||||
if (series.ProductionYear.HasValue)
|
||||
{
|
||||
seriesFolderName = string.Format("{0} ({1})", seriesFolderName, series.ProductionYear);
|
||||
}
|
||||
|
||||
series.Path = Path.Combine(request.TargetFolder, seriesFolderName);
|
||||
|
||||
series.ProviderIds = request.NewSeriesProviderIdsDictionary;
|
||||
|
||||
await series.RefreshMetadata(refreshOptions, cancellationToken);
|
||||
}
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
// Existing Series
|
||||
series = (Series)_libraryManager.GetItemById(new Guid(request.SeriesId));
|
||||
}
|
||||
|
||||
await OrganizeEpisode(result.OriginalPath,
|
||||
series,
|
||||
|
Loading…
Reference in New Issue
Block a user