You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.1 KiB
69 lines
2.1 KiB
7 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using Newtonsoft.Json;
|
||
|
using NzbDrone.Core.Music;
|
||
7 years ago
|
using Lidarr.Api.V1.TrackFiles;
|
||
|
using Lidarr.Api.V1.Artist;
|
||
7 years ago
|
using Lidarr.Http.REST;
|
||
|
|
||
7 years ago
|
namespace Lidarr.Api.V1.Tracks
|
||
7 years ago
|
{
|
||
|
public class TrackResource : RestResource
|
||
|
{
|
||
|
public int ArtistId { get; set; }
|
||
|
public int TrackFileId { get; set; }
|
||
|
public int AlbumId { get; set; }
|
||
|
public bool Explicit { get; set; }
|
||
|
public int TrackNumber { get; set; }
|
||
|
public string Title { get; set; }
|
||
|
public int Duration { get; set; }
|
||
|
public TrackFileResource TrackFile { get; set; }
|
||
|
|
||
|
public bool HasFile { get; set; }
|
||
|
public bool Monitored { get; set; }
|
||
|
//public string SeriesTitle { get; set; }
|
||
|
public ArtistResource Artist { get; set; }
|
||
|
public Ratings Ratings { get; set; }
|
||
|
|
||
|
//Hiding this so people don't think its usable (only used to set the initial state)
|
||
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||
|
public bool Grabbed { get; set; }
|
||
|
}
|
||
|
|
||
|
public static class TrackResourceMapper
|
||
|
{
|
||
|
public static TrackResource ToResource(this Track model)
|
||
|
{
|
||
|
if (model == null) return null;
|
||
|
|
||
|
return new TrackResource
|
||
|
{
|
||
|
Id = model.Id,
|
||
|
|
||
|
ArtistId = model.ArtistId,
|
||
|
TrackFileId = model.TrackFileId,
|
||
|
AlbumId = model.AlbumId,
|
||
|
Explicit = model.Explicit,
|
||
|
TrackNumber = model.TrackNumber,
|
||
|
Title = model.Title,
|
||
|
Duration = model.Duration,
|
||
|
//EpisodeFile
|
||
|
|
||
|
HasFile = model.HasFile,
|
||
|
Monitored = model.Monitored,
|
||
|
Ratings = model.Ratings,
|
||
|
//SeriesTitle = model.SeriesTitle,
|
||
|
//Series = model.Series.MapToResource(),
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public static List<TrackResource> ToResource(this IEnumerable<Track> models)
|
||
|
{
|
||
|
if (models == null) return null;
|
||
|
|
||
|
return models.Select(ToResource).ToList();
|
||
|
}
|
||
|
}
|
||
|
}
|