Radarr/src/Radarr.Api.V3/Movies/AlternativeTitleResource.cs

74 lines
2.4 KiB
C#
Raw Normal View History

2018-11-23 07:03:32 +00:00
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Languages;
2019-12-22 22:08:53 +00:00
using NzbDrone.Core.Movies.AlternativeTitles;
using Radarr.Http.REST;
2018-11-23 07:03:32 +00:00
namespace Radarr.Api.V3.Movies
2018-11-23 07:03:32 +00:00
{
public class AlternativeTitleResource : RestResource
{
2022-11-20 18:27:45 +00:00
// Todo: Sorters should be done completely on the client
// Todo: Is there an easy way to keep IgnoreArticlesWhenSorting in sync between, Series, History, Missing?
// Todo: We should get the entire Profile instead of ID and Name separately
2018-11-23 07:03:32 +00:00
public SourceType SourceType { get; set; }
2022-03-20 15:55:47 +00:00
public int MovieMetadataId { get; set; }
2018-11-23 07:03:32 +00:00
public string Title { get; set; }
public string CleanTitle { get; set; }
public int SourceId { get; set; }
public int Votes { get; set; }
public int VoteCount { get; set; }
public Language Language { get; set; }
2022-11-20 18:27:45 +00:00
// TODO: Add series statistics as a property of the series (instead of individual properties)
2018-11-23 07:03:32 +00:00
}
public static class AlternativeTitleResourceMapper
{
public static AlternativeTitleResource ToResource(this AlternativeTitle model)
{
2019-12-22 22:08:53 +00:00
if (model == null)
{
return null;
}
2018-11-23 07:03:32 +00:00
return new AlternativeTitleResource
{
Id = model.Id,
SourceType = model.SourceType,
2022-03-20 15:55:47 +00:00
MovieMetadataId = model.MovieMetadataId,
2018-11-23 07:03:32 +00:00
Title = model.Title,
SourceId = model.SourceId,
Votes = model.Votes,
VoteCount = model.VoteCount,
Language = model.Language
};
}
public static AlternativeTitle ToModel(this AlternativeTitleResource resource)
{
2019-12-22 22:08:53 +00:00
if (resource == null)
{
return null;
}
2018-11-23 07:03:32 +00:00
return new AlternativeTitle
{
Id = resource.Id,
SourceType = resource.SourceType,
2022-03-20 15:55:47 +00:00
MovieMetadataId = resource.MovieMetadataId,
2018-11-23 07:03:32 +00:00
Title = resource.Title,
SourceId = resource.SourceId,
Votes = resource.Votes,
VoteCount = resource.VoteCount,
Language = resource.Language
};
}
public static List<AlternativeTitleResource> ToResource(this IEnumerable<AlternativeTitle> movies)
{
return movies.Select(ToResource).ToList();
}
}
}