parent
dec0e3eec3
commit
d76423a305
@ -1,9 +0,0 @@
|
||||
namespace NzbDrone.Core.MetadataSource.SkyHook.Resource
|
||||
{
|
||||
public class ActorResource
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Character { get; set; }
|
||||
public string Image { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Core.Movies.Credits
|
||||
{
|
||||
public class Credit : ModelBase
|
||||
{
|
||||
public Credit()
|
||||
{
|
||||
Images = new List<MediaCover.MediaCover>();
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string CreditTmdbId { get; set; }
|
||||
public int PersonTmdbId { get; set; }
|
||||
public int MovieId { get; set; }
|
||||
public List<MediaCover.MediaCover> Images { get; set; }
|
||||
public string Department { get; set; }
|
||||
public string Job { get; set; }
|
||||
public string Character { get; set; }
|
||||
public int Order { get; set; }
|
||||
public CreditType Type { get; set; }
|
||||
}
|
||||
|
||||
public enum CreditType
|
||||
{
|
||||
Cast,
|
||||
Crew
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Movies.Credits;
|
||||
using Radarr.Http;
|
||||
|
||||
namespace Radarr.Api.V3.Credits
|
||||
{
|
||||
public class CreditModule : RadarrRestModule<CreditResource>
|
||||
{
|
||||
private readonly ICreditService _creditService;
|
||||
|
||||
public CreditModule(ICreditService creditService)
|
||||
{
|
||||
_creditService = creditService;
|
||||
|
||||
GetResourceById = GetCredit;
|
||||
GetResourceAll = GetCredits;
|
||||
}
|
||||
|
||||
private CreditResource GetCredit(int id)
|
||||
{
|
||||
return _creditService.GetById(id).ToResource();
|
||||
}
|
||||
|
||||
private List<CreditResource> GetCredits()
|
||||
{
|
||||
var movieIdQuery = Request.Query.MovieId;
|
||||
|
||||
if (movieIdQuery.HasValue)
|
||||
{
|
||||
int movieId = Convert.ToInt32(movieIdQuery.Value);
|
||||
|
||||
return _creditService.GetAllCreditsForMovie(movieId).ToResource();
|
||||
}
|
||||
|
||||
return _creditService.GetAllCredits().ToResource();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Movies.Credits;
|
||||
using Radarr.Http.REST;
|
||||
|
||||
namespace Radarr.Api.V3.Credits
|
||||
{
|
||||
public class CreditResource : RestResource
|
||||
{
|
||||
public CreditResource()
|
||||
{
|
||||
}
|
||||
|
||||
public string PersonName { get; set; }
|
||||
public string CreditTmdbId { get; set; }
|
||||
public int PersonTmdbId { get; set; }
|
||||
public int MovieId { get; set; }
|
||||
public List<MediaCover> Images { get; set; }
|
||||
public string Department { get; set; }
|
||||
public string Job { get; set; }
|
||||
public string Character { get; set; }
|
||||
public int Order { get; set; }
|
||||
public CreditType Type { get; set; }
|
||||
}
|
||||
|
||||
public static class CreditResourceMapper
|
||||
{
|
||||
public static CreditResource ToResource(this Credit model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CreditResource
|
||||
{
|
||||
Id = model.Id,
|
||||
MovieId = model.MovieId,
|
||||
CreditTmdbId = model.CreditTmdbId,
|
||||
PersonTmdbId = model.PersonTmdbId,
|
||||
PersonName = model.Name,
|
||||
Order = model.Order,
|
||||
Character = model.Character,
|
||||
Department = model.Department,
|
||||
Images = model.Images,
|
||||
Job = model.Job,
|
||||
Type = model.Type
|
||||
};
|
||||
}
|
||||
|
||||
public static List<CreditResource> ToResource(this IEnumerable<Credit> credits)
|
||||
{
|
||||
return credits.Select(ToResource).ToList();
|
||||
}
|
||||
|
||||
public static Credit ToModel(this CreditResource resource)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Credit
|
||||
{
|
||||
Id = resource.Id,
|
||||
MovieId = resource.MovieId,
|
||||
Name = resource.PersonName,
|
||||
Order = resource.Order,
|
||||
Character = resource.Character,
|
||||
Department = resource.Department,
|
||||
Job = resource.Job,
|
||||
Type = resource.Type,
|
||||
Images = resource.Images,
|
||||
CreditTmdbId = resource.CreditTmdbId,
|
||||
PersonTmdbId = resource.PersonTmdbId
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue