2017-09-04 02:20:56 +00:00
|
|
|
using System;
|
2019-02-23 22:39:11 +00:00
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
2017-09-04 02:20:56 +00:00
|
|
|
using NzbDrone.Core.Languages;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using Lidarr.Http.REST;
|
2019-06-08 19:13:58 +00:00
|
|
|
using NzbDrone.Common.Extensions;
|
2017-09-04 02:20:56 +00:00
|
|
|
|
2017-10-31 01:28:29 +00:00
|
|
|
namespace Lidarr.Api.V1.TrackFiles
|
2017-09-04 02:20:56 +00:00
|
|
|
{
|
|
|
|
public class TrackFileResource : RestResource
|
|
|
|
{
|
|
|
|
public int ArtistId { get; set; }
|
|
|
|
public int AlbumId { get; set; }
|
|
|
|
public string RelativePath { get; set; }
|
|
|
|
public string Path { get; set; }
|
|
|
|
public long Size { get; set; }
|
|
|
|
public DateTime DateAdded { get; set; }
|
|
|
|
//public string SceneName { get; set; }
|
|
|
|
public Language Language { get; set; }
|
|
|
|
public QualityModel Quality { get; set; }
|
|
|
|
public MediaInfoResource MediaInfo { get; set; }
|
|
|
|
|
|
|
|
public bool QualityCutoffNotMet { get; set; }
|
2017-12-30 03:23:04 +00:00
|
|
|
public bool LanguageCutoffNotMet { get; set; }
|
|
|
|
|
2017-09-04 02:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static class TrackFileResourceMapper
|
|
|
|
{
|
|
|
|
private static TrackFileResource ToResource(this TrackFile model)
|
|
|
|
{
|
|
|
|
if (model == null) return null;
|
|
|
|
|
|
|
|
return new TrackFileResource
|
|
|
|
{
|
|
|
|
Id = model.Id,
|
|
|
|
|
2019-02-16 14:49:24 +00:00
|
|
|
ArtistId = model.Artist.Value.Id,
|
2017-09-04 02:20:56 +00:00
|
|
|
AlbumId = model.AlbumId,
|
2019-06-08 19:13:58 +00:00
|
|
|
RelativePath = model.Artist.Value.Path.GetRelativePath(model.Path),
|
|
|
|
Path = model.Path,
|
2017-09-04 02:20:56 +00:00
|
|
|
Size = model.Size,
|
|
|
|
DateAdded = model.DateAdded,
|
|
|
|
// SceneName = model.SceneName,
|
|
|
|
Language = model.Language,
|
|
|
|
Quality = model.Quality,
|
2018-01-18 02:28:47 +00:00
|
|
|
MediaInfo = model.MediaInfo.ToResource()
|
2017-09-04 02:20:56 +00:00
|
|
|
//QualityCutoffNotMet
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static TrackFileResource ToResource(this TrackFile model, NzbDrone.Core.Music.Artist artist, IUpgradableSpecification upgradableSpecification)
|
|
|
|
{
|
|
|
|
if (model == null) return null;
|
|
|
|
|
|
|
|
return new TrackFileResource
|
|
|
|
{
|
|
|
|
Id = model.Id,
|
|
|
|
|
2019-02-16 14:49:24 +00:00
|
|
|
ArtistId = artist.Id,
|
2017-09-04 02:20:56 +00:00
|
|
|
AlbumId = model.AlbumId,
|
2019-06-08 19:13:58 +00:00
|
|
|
Path = model.Path,
|
|
|
|
RelativePath = artist.Path.GetRelativePath(model.Path),
|
2017-09-04 02:20:56 +00:00
|
|
|
Size = model.Size,
|
|
|
|
DateAdded = model.DateAdded,
|
|
|
|
//SceneName = model.SceneName,
|
|
|
|
Language = model.Language,
|
|
|
|
Quality = model.Quality,
|
2018-01-18 02:28:47 +00:00
|
|
|
MediaInfo = model.MediaInfo.ToResource(),
|
2019-02-23 22:39:11 +00:00
|
|
|
QualityCutoffNotMet = upgradableSpecification.QualityCutoffNotMet(artist.QualityProfile.Value, model.Quality),
|
2017-12-30 03:23:04 +00:00
|
|
|
LanguageCutoffNotMet = upgradableSpecification.LanguageCutoffNotMet(artist.LanguageProfile.Value, model.Language)
|
2017-09-04 02:20:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|