mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-20 13:06:57 +00:00
Fixed small issue in ProfileService. Reimplemented the metadata with LidarrAPI.Metadata
This commit is contained in:
parent
775f96c865
commit
704983f652
8 changed files with 35 additions and 40 deletions
|
@ -17,8 +17,10 @@ public LidarrCloudRequestBuilder()
|
|||
Services = new HttpRequestBuilder("http://services.lidarr.tv/v1/")
|
||||
.CreateFactory();
|
||||
|
||||
Search = new HttpRequestBuilder("https://api.spotify.com/{version}/{route}/") // TODO: maybe use {version}
|
||||
.SetSegment("version", "v1")
|
||||
//Search = new HttpRequestBuilder("https://api.spotify.com/{version}/{route}/") // TODO: maybe use {version}
|
||||
// .SetSegment("version", "v1")
|
||||
// .CreateFactory();
|
||||
Search = new HttpRequestBuilder("http://localhost:5000/{route}/") // TODO: maybe use {version}
|
||||
.CreateFactory();
|
||||
|
||||
InternalSearch = new HttpRequestBuilder("https://itunes.apple.com/WebObjects/MZStore.woa/wa/{route}") //viewArtist or search
|
||||
|
|
|
@ -11,12 +11,16 @@ public AlbumInfoResource()
|
|||
{
|
||||
|
||||
}
|
||||
public string AlbumType { get; set; } // Might need to make this a separate class
|
||||
//public string AlbumType { get; set; } // Might need to make this a separate class
|
||||
public List<ArtistInfoResource> Artists { get; set; } // Will always be length of 1 unless a compilation
|
||||
public string Url { get; set; } // Link to the endpoint api to give full info for this object
|
||||
public string Id { get; set; } // This is a unique Album ID. Needed for all future API calls
|
||||
public int Year { get; set; }
|
||||
public List<ImageResource> Images { get; set; }
|
||||
public string Name { get; set; } // In case of a takedown, this may be empty
|
||||
public string AlbumName { get; set; } // In case of a takedown, this may be empty
|
||||
public string Overview { get; set; }
|
||||
public List<string> Genres { get; set; }
|
||||
public string Label { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,10 +11,9 @@ public ArtistInfoResource() { }
|
|||
|
||||
public List<string> Genres { get; set; }
|
||||
public string AristUrl { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public string Id { get; set; }
|
||||
public List<ImageResource> Images { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
// We may need external_urls.spotify to external linking...
|
||||
public string ArtistName { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public AristResultResource()
|
|||
}
|
||||
|
||||
public List<ArtistInfoResource> Items { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
public class AlbumResultResource
|
||||
|
@ -24,6 +25,7 @@ public AlbumResultResource()
|
|||
}
|
||||
|
||||
public List<AlbumInfoResource> Items { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
public class TrackResultResource
|
||||
|
@ -34,6 +36,7 @@ public TrackResultResource()
|
|||
}
|
||||
|
||||
public List<TrackInfoResource> Items { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
public class ArtistResource
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ public TrackInfoResource()
|
|||
public int DurationMs { get; set; }
|
||||
public string Href { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string TrackName { get; set; }
|
||||
public int TrackNumber { get; set; }
|
||||
public bool Explicit { get; set; }
|
||||
public List<ArtistInfoResource> Artists { get; set; }
|
||||
|
|
|
@ -79,9 +79,6 @@ public Tuple<Artist, List<Track>> GetArtistInfo(string spotifyId)
|
|||
|
||||
_logger.Debug("Getting Artist with SpotifyId of {0}", spotifyId);
|
||||
|
||||
///v1/albums/{id}
|
||||
//
|
||||
|
||||
// We need to perform a direct lookup of the artist
|
||||
var httpRequest = _requestBuilder.Create()
|
||||
.SetSegment("route", "artists/" + spotifyId)
|
||||
|
@ -95,7 +92,7 @@ public Tuple<Artist, List<Track>> GetArtistInfo(string spotifyId)
|
|||
httpRequest.AllowAutoRedirect = true;
|
||||
httpRequest.SuppressHttpError = true;
|
||||
|
||||
var httpResponse = _httpClient.Get<ArtistInfoResource>(httpRequest);
|
||||
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest);
|
||||
|
||||
|
||||
if (httpResponse.HasHttpError)
|
||||
|
@ -110,10 +107,11 @@ public Tuple<Artist, List<Track>> GetArtistInfo(string spotifyId)
|
|||
}
|
||||
}
|
||||
|
||||
// It is safe to assume an id will only return one Artist back
|
||||
Artist artist = new Artist();
|
||||
artist.ArtistName = httpResponse.Resource.Name;
|
||||
artist.SpotifyId = httpResponse.Resource.Id;
|
||||
artist.Genres = httpResponse.Resource.Genres;
|
||||
artist.ArtistName = httpResponse.Resource.Artists.Items[0].ArtistName;
|
||||
artist.SpotifyId = httpResponse.Resource.Artists.Items[0].Id;
|
||||
artist.Genres = httpResponse.Resource.Artists.Items[0].Genres;
|
||||
|
||||
var albumRet = MapAlbums(artist);
|
||||
artist = albumRet.Item1;
|
||||
|
@ -147,7 +145,7 @@ private Tuple<Artist, List<Track>> MapAlbums(Artist artist)
|
|||
{
|
||||
Album album = new Album();
|
||||
album.AlbumId = albumResource.Id;
|
||||
album.Title = albumResource.Name;
|
||||
album.Title = albumResource.AlbumName;
|
||||
album.ArtworkUrl = albumResource.Images.Count > 0 ? albumResource.Images[0].Url : "";
|
||||
album.Tracks = MapTracksToAlbum(album);
|
||||
masterTracks.InsertRange(masterTracks.Count, album.Tracks);
|
||||
|
@ -190,7 +188,7 @@ private List<Track> MapTracksToAlbum(Album album)
|
|||
track.Explict = trackResource.Explicit;
|
||||
track.Compilation = trackResource.Artists.Count > 1;
|
||||
track.TrackNumber = trackResource.TrackNumber;
|
||||
track.Title = trackResource.Name;
|
||||
track.Title = trackResource.TrackName;
|
||||
tracks.Add(track);
|
||||
}
|
||||
|
||||
|
@ -226,8 +224,8 @@ public List<Artist> SearchForNewArtist(string title)
|
|||
|
||||
var httpRequest = _requestBuilder.Create()
|
||||
.SetSegment("route", "search")
|
||||
.AddQueryParam("type", "artist,album")
|
||||
.AddQueryParam("q", title.ToLower().Trim())
|
||||
.AddQueryParam("type", "artist") // TODO: LidarrAPI.Metadata is getting , encoded. Needs to be raw ,
|
||||
.AddQueryParam("query", title.ToLower().Trim())
|
||||
.Build();
|
||||
|
||||
|
||||
|
@ -250,20 +248,6 @@ public List<Artist> SearchForNewArtist(string title)
|
|||
}
|
||||
}
|
||||
|
||||
private Artist MapArtistInfo(ArtistInfoResource resource)
|
||||
{
|
||||
// This expects ArtistInfoResource, thus just need to populate one artist
|
||||
Artist artist = new Artist();
|
||||
//artist.Overview = resource.artistBio;
|
||||
//artist.ArtistName = resource.name;
|
||||
//foreach(var genre in resource.genreNames)
|
||||
//{
|
||||
// artist.Genres.Add(genre);
|
||||
//}
|
||||
|
||||
return artist;
|
||||
}
|
||||
|
||||
private List<Artist> MapArtists(ArtistResource resource)
|
||||
{
|
||||
|
||||
|
@ -272,10 +256,12 @@ private List<Artist> MapArtists(ArtistResource resource)
|
|||
foreach(var artistResource in resource.Artists.Items)
|
||||
{
|
||||
Artist artist = new Artist();
|
||||
artist.ArtistName = artistResource.Name;
|
||||
artist.SpotifyId = artistResource.Id;
|
||||
artist.ArtistName = artistResource.ArtistName;
|
||||
artist.SpotifyId = artistResource.Id; // TODO: Rename spotifyId to LidarrId
|
||||
artist.Genres = artistResource.Genres;
|
||||
artist.ArtistSlug = Parser.Parser.CleanArtistTitle(artist.ArtistName);
|
||||
//artist.Images = artistResource.Images;
|
||||
|
||||
artists.Add(artist);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ private Artist AddSkyhookData(Artist newArtist)
|
|||
{
|
||||
tuple = _artistInfo.GetArtistInfo(newArtist.SpotifyId);
|
||||
}
|
||||
catch (SeriesNotFoundException)
|
||||
catch (ArtistNotFoundException)
|
||||
{
|
||||
_logger.Error("SpotifyId {1} was not found, it may have been removed from Spotify.", newArtist.SpotifyId);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Profiles
|
||||
{
|
||||
|
@ -22,13 +23,13 @@ public interface IProfileService
|
|||
public class ProfileService : IProfileService, IHandle<ApplicationStartedEvent>
|
||||
{
|
||||
private readonly IProfileRepository _profileRepository;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly IArtistService _artistService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public ProfileService(IProfileRepository profileRepository, ISeriesService seriesService, Logger logger)
|
||||
public ProfileService(IProfileRepository profileRepository, IArtistService artistService, Logger logger)
|
||||
{
|
||||
_profileRepository = profileRepository;
|
||||
_seriesService = seriesService;
|
||||
_artistService = artistService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
@ -44,7 +45,7 @@ public void Update(Profile profile)
|
|||
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (_seriesService.GetAllSeries().Any(c => c.ProfileId == id))
|
||||
if (_artistService.GetAllArtists().Any(c => c.ProfileId == id))
|
||||
{
|
||||
throw new ProfileInUseException(id);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue