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.
Lidarr/src/Lidarr.Api.V1/Artist/ArtistResource.cs

174 lines
5.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http.REST;
using Newtonsoft.Json;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Music;
namespace Lidarr.Api.V1.Artist
{
public class ArtistResource : RestResource
{
// 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
[JsonIgnore]
public int ArtistMetadataId { get; set; }
public ArtistStatusType Status { get; set; }
public bool Ended => Status == ArtistStatusType.Ended;
public string ArtistName { get; set; }
public string ForeignArtistId { get; set; }
public string MBId { get; set; }
public int TADBId { get; set; }
public int DiscogsId { get; set; }
public string AllMusicId { get; set; }
public string Overview { get; set; }
public string ArtistType { get; set; }
public string Disambiguation { get; set; }
public List<Links> Links { get; set; }
public Album NextAlbum { get; set; }
public Album LastAlbum { get; set; }
public List<MediaCover> Images { get; set; }
public List<Member> Members { get; set; }
public string RemotePoster { get; set; }
// View & Edit
public string Path { get; set; }
public int QualityProfileId { get; set; }
public int MetadataProfileId { get; set; }
// Editing Only
public bool Monitored { get; set; }
public NewItemMonitorTypes MonitorNewItems { get; set; }
public string RootFolderPath { get; set; }
public List<string> Genres { get; set; }
public string CleanName { get; set; }
public string SortName { get; set; }
public HashSet<int> Tags { get; set; }
public DateTime Added { get; set; }
public AddArtistOptions AddOptions { get; set; }
public Ratings Ratings { get; set; }
public ArtistStatisticsResource Statistics { get; set; }
}
public static class ArtistResourceMapper
{
public static ArtistResource ToResource(this NzbDrone.Core.Music.Artist model)
{
if (model == null)
{
return null;
}
return new ArtistResource
{
Id = model.Id,
ArtistMetadataId = model.ArtistMetadataId,
ArtistName = model.Name,
// AlternateTitles
SortName = model.SortName,
Status = model.Metadata.Value.Status,
Overview = model.Metadata.Value.Overview,
ArtistType = model.Metadata.Value.Type,
Disambiguation = model.Metadata.Value.Disambiguation,
Whole album matching and fingerprinting (#592) * Cache result of GetAllArtists * Fixed: Manual import not respecting album import notifications * Fixed: partial album imports stay in queue, prompting manual import * Fixed: Allow release if tracks are missing * Fixed: Be tolerant of missing/extra "The" at start of artist name * Improve manual import UI * Omit video tracks from DB entirely * Revert "faster test packaging in build.sh" This reverts commit 2723e2a7b86bcbff9051fd2aced07dd807b4bcb7. -u and -T are not supported on macOS * Fix tests on linux and macOS * Actually lint on linux On linux yarn runs scripts with sh not bash so ** doesn't recursively glob * Match whole albums * Option to disable fingerprinting * Rip out MediaInfo * Don't split up things that have the same album selected in manual import * Try to speed up IndentificationService * More speedups * Some fixes and increase power of recording id * Fix NRE when no tags * Fix NRE when some (but not all) files in a directory have missing tags * Bump taglib, tidy up tag parsing * Add a health check * Remove media info setting * Tags -> audioTags * Add some tests where tags are null * Rename history events * Add missing method to interface * Reinstate MediaInfo tags and update info with artist scan Also adds migration to remove old format media info * This file no longer exists * Don't penalise year if missing from tags * Formatting improvements * Use correct system newline * Switch to the netstandard2.0 library to support net 461 * TagLib.File is IDisposable so should be in a using * Improve filename matching and add tests * Neater logging of parsed tags * Fix disk scan tests for new media info update * Fix quality detection source * Fix Inexact Artist/Album match * Add button to clear track mapping * Fix warning * Pacify eslint * Use \ not / * Fix UI updates * Fix media covers Prevent localizing URL propaging back to the metadata object * Reduce database overhead broadcasting UI updates * Relax timings a bit to make test pass * Remove irrelevant tests * Test framework for identification service * Fix PreferMissingToBadMatch test case * Make fingerprinting more robust * More logging * Penalize unknown media format and country * Prefer USA to UK * Allow Data CD * Fix exception if fingerprinting fails for all files * Fix tests * Fix NRE * Allow apostrophes and remove accents in filename aggregation * Address codacy issues * Cope with old versions of fpcalc and suggest upgrade * fpcalc health check passes if fingerprinting disabled * Get the Artist meta with the artist * Fix the mapper so that lazy loaded lists will be populated on Join And therefore we can join TrackFiles on Tracks by default and avoid an extra query * Rename subtitle -> lyric * Tidy up MediaInfoFormatter
5 years ago
Images = model.Metadata.Value.Images.JsonClone(),
Path = model.Path,
QualityProfileId = model.QualityProfileId,
MetadataProfileId = model.MetadataProfileId,
Links = model.Metadata.Value.Links,
Monitored = model.Monitored,
MonitorNewItems = model.MonitorNewItems,
CleanName = model.CleanName,
ForeignArtistId = model.Metadata.Value.ForeignArtistId,
// Root folder path is now calculated from the artist path
// RootFolderPath = model.RootFolderPath,
Genres = model.Metadata.Value.Genres,
Tags = model.Tags,
Added = model.Added,
AddOptions = model.AddOptions,
Ratings = model.Metadata.Value.Ratings,
Statistics = new ArtistStatisticsResource()
};
}
public static NzbDrone.Core.Music.Artist ToModel(this ArtistResource resource)
{
if (resource == null)
{
return null;
}
return new NzbDrone.Core.Music.Artist
{
Id = resource.Id,
Metadata = new NzbDrone.Core.Music.ArtistMetadata
{
ForeignArtistId = resource.ForeignArtistId,
Name = resource.ArtistName,
Status = resource.Status,
Overview = resource.Overview,
Links = resource.Links,
Images = resource.Images,
Genres = resource.Genres,
Ratings = resource.Ratings,
Type = resource.ArtistType
},
// AlternateTitles
SortName = resource.SortName,
Path = resource.Path,
QualityProfileId = resource.QualityProfileId,
MetadataProfileId = resource.MetadataProfileId,
Monitored = resource.Monitored,
MonitorNewItems = resource.MonitorNewItems,
CleanName = resource.CleanName,
RootFolderPath = resource.RootFolderPath,
Tags = resource.Tags,
Added = resource.Added,
AddOptions = resource.AddOptions,
};
}
public static NzbDrone.Core.Music.Artist ToModel(this ArtistResource resource, NzbDrone.Core.Music.Artist artist)
{
var updatedArtist = resource.ToModel();
artist.ApplyChanges(updatedArtist);
return artist;
}
public static List<ArtistResource> ToResource(this IEnumerable<NzbDrone.Core.Music.Artist> artist)
{
return artist.Select(ToResource).ToList();
}
public static List<NzbDrone.Core.Music.Artist> ToModel(this IEnumerable<ArtistResource> resources)
{
return resources.Select(ToModel).ToList();
}
}
}