2018-02-22 04:40:26 +00:00
|
|
|
using System;
|
2016-03-25 00:56:29 +00:00
|
|
|
using System.IO;
|
2017-02-11 06:46:39 +00:00
|
|
|
using NzbDrone.Core.DecisionEngine;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using Sonarr.Http.REST;
|
2014-01-18 11:44:36 +00:00
|
|
|
using NzbDrone.Core.Qualities;
|
2015-07-12 16:44:33 +00:00
|
|
|
using NzbDrone.Core.Languages;
|
2013-08-21 06:46:23 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Api.EpisodeFiles
|
|
|
|
{
|
|
|
|
public class EpisodeFileResource : RestResource
|
|
|
|
{
|
2015-10-03 17:45:26 +00:00
|
|
|
public int SeriesId { get; set; }
|
|
|
|
public int SeasonNumber { get; set; }
|
|
|
|
public string RelativePath { get; set; }
|
|
|
|
public string Path { get; set; }
|
|
|
|
public long Size { get; set; }
|
2013-08-21 06:46:23 +00:00
|
|
|
public DateTime DateAdded { get; set; }
|
2015-10-03 17:45:26 +00:00
|
|
|
public string SceneName { get; set; }
|
2013-08-21 06:46:23 +00:00
|
|
|
public QualityModel Quality { get; set; }
|
2015-07-12 16:44:33 +00:00
|
|
|
public Language Language { get; set; }
|
2018-02-22 04:40:26 +00:00
|
|
|
public MediaInfoResource MediaInfo { get; set; }
|
2018-12-07 04:24:11 +00:00
|
|
|
public string OriginalFilePath { get; set; }
|
2014-08-18 22:24:44 +00:00
|
|
|
|
2015-10-03 17:45:26 +00:00
|
|
|
public bool QualityCutoffNotMet { get; set; }
|
2013-08-21 06:46:23 +00:00
|
|
|
}
|
2016-03-25 00:56:29 +00:00
|
|
|
|
|
|
|
public static class EpisodeFileResourceMapper
|
|
|
|
{
|
2017-02-11 06:46:39 +00:00
|
|
|
private static EpisodeFileResource ToResource(this EpisodeFile model)
|
2016-03-25 00:56:29 +00:00
|
|
|
{
|
|
|
|
if (model == null) return null;
|
|
|
|
|
|
|
|
return new EpisodeFileResource
|
|
|
|
{
|
|
|
|
Id = model.Id,
|
|
|
|
|
|
|
|
SeriesId = model.SeriesId,
|
|
|
|
SeasonNumber = model.SeasonNumber,
|
|
|
|
RelativePath = model.RelativePath,
|
|
|
|
//Path
|
|
|
|
Size = model.Size,
|
|
|
|
DateAdded = model.DateAdded,
|
|
|
|
SceneName = model.SceneName,
|
|
|
|
Quality = model.Quality,
|
2018-12-07 04:24:11 +00:00
|
|
|
MediaInfo = model.MediaInfo.ToResource(model.SceneName),
|
|
|
|
OriginalFilePath = model.OriginalFilePath
|
2016-03-25 00:56:29 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-07-12 16:44:33 +00:00
|
|
|
public static EpisodeFileResource ToResource(this EpisodeFile model, Core.Tv.Series series, IUpgradableSpecification upgradableSpecification)
|
2016-03-25 00:56:29 +00:00
|
|
|
{
|
|
|
|
if (model == null) return null;
|
|
|
|
|
|
|
|
return new EpisodeFileResource
|
|
|
|
{
|
|
|
|
Id = model.Id,
|
|
|
|
|
|
|
|
SeriesId = model.SeriesId,
|
|
|
|
SeasonNumber = model.SeasonNumber,
|
|
|
|
RelativePath = model.RelativePath,
|
|
|
|
Path = Path.Combine(series.Path, model.RelativePath),
|
|
|
|
Size = model.Size,
|
|
|
|
DateAdded = model.DateAdded,
|
|
|
|
SceneName = model.SceneName,
|
|
|
|
Quality = model.Quality,
|
2015-07-12 16:44:33 +00:00
|
|
|
Language = model.Language,
|
2017-02-11 06:46:39 +00:00
|
|
|
QualityCutoffNotMet = upgradableSpecification.QualityCutoffNotMet(series.Profile.Value, model.Quality),
|
2018-02-22 04:40:26 +00:00
|
|
|
MediaInfo = model.MediaInfo.ToResource(model.SceneName),
|
2018-12-07 04:24:11 +00:00
|
|
|
OriginalFilePath = model.OriginalFilePath
|
2016-03-25 00:56:29 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2013-08-21 06:46:23 +00:00
|
|
|
}
|