mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-15 09:33:52 -07:00
Now returns one artist back with albums.
This commit is contained in:
parent
2813fccc78
commit
a08ebcc0c2
5 changed files with 56 additions and 47 deletions
|
@ -9,10 +9,10 @@ namespace NzbDrone.Api.Music
|
||||||
public class AlbumResource
|
public class AlbumResource
|
||||||
{
|
{
|
||||||
public int AlbumId { get; set; }
|
public int AlbumId { get; set; }
|
||||||
|
public string AlbumName { get; set; }
|
||||||
public bool Monitored { get; set; }
|
public bool Monitored { get; set; }
|
||||||
//public string Overview { get; set; }
|
|
||||||
public int Year { get; set; }
|
public int Year { get; set; }
|
||||||
//public SeasonStatisticsResource Statistics { get; set; }
|
public List<string> Genre { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AlbumResourceMapper
|
public static class AlbumResourceMapper
|
||||||
|
@ -25,8 +25,8 @@ namespace NzbDrone.Api.Music
|
||||||
{
|
{
|
||||||
AlbumId = model.AlbumId,
|
AlbumId = model.AlbumId,
|
||||||
Monitored = model.Monitored,
|
Monitored = model.Monitored,
|
||||||
//Overview = model.Overview; //TODO: Inspect if Album needs an overview
|
Year = model.Year,
|
||||||
Year = model.Year
|
AlbumName = model.Title
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ namespace NzbDrone.Api.Music
|
||||||
{
|
{
|
||||||
AlbumId = resource.AlbumId,
|
AlbumId = resource.AlbumId,
|
||||||
Monitored = resource.Monitored,
|
Monitored = resource.Monitored,
|
||||||
Year = resource.Year
|
Year = resource.Year,
|
||||||
|
Title = resource.AlbumName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,10 @@ namespace NzbDrone.Api.Music
|
||||||
Monitored = true;
|
Monitored = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
|
||||||
|
|
||||||
//View Only
|
//View Only
|
||||||
public string ArtistName { get; set; }
|
public string ArtistName { get; set; }
|
||||||
|
public int ItunesId { get; set; }
|
||||||
//public List<AlternateTitleResource> AlternateTitles { get; set; }
|
//public List<AlternateTitleResource> AlternateTitles { get; set; }
|
||||||
//public string SortTitle { get; set; }
|
//public string SortTitle { get; set; }
|
||||||
|
|
||||||
|
@ -55,17 +53,6 @@ namespace NzbDrone.Api.Music
|
||||||
public bool ArtistFolder { get; set; }
|
public bool ArtistFolder { get; set; }
|
||||||
public bool Monitored { get; set; }
|
public bool Monitored { get; set; }
|
||||||
|
|
||||||
//public bool UseSceneNumbering { get; set; }
|
|
||||||
//public int Runtime { get; set; }
|
|
||||||
//public int TvdbId { get; set; }
|
|
||||||
//public int TvRageId { get; set; }
|
|
||||||
//public int TvMazeId { get; set; }
|
|
||||||
//public DateTime? FirstAired { get; set; }
|
|
||||||
//public DateTime? LastInfoSync { get; set; }
|
|
||||||
//public SeriesTypes SeriesType { get; set; }
|
|
||||||
public string CleanTitle { get; set; }
|
|
||||||
public int ItunesId { get; set; }
|
|
||||||
//public string TitleSlug { get; set; }
|
|
||||||
public string RootFolderPath { get; set; }
|
public string RootFolderPath { get; set; }
|
||||||
public string Certification { get; set; }
|
public string Certification { get; set; }
|
||||||
public List<string> Genres { get; set; }
|
public List<string> Genres { get; set; }
|
||||||
|
@ -119,7 +106,6 @@ namespace NzbDrone.Api.Music
|
||||||
//FirstAired = resource.FirstAired,
|
//FirstAired = resource.FirstAired,
|
||||||
//LastInfoSync = resource.LastInfoSync,
|
//LastInfoSync = resource.LastInfoSync,
|
||||||
//SeriesType = resource.SeriesType,
|
//SeriesType = resource.SeriesType,
|
||||||
CleanTitle = model.CleanTitle,
|
|
||||||
ItunesId = model.ItunesId,
|
ItunesId = model.ItunesId,
|
||||||
ArtistSlug = model.ArtistSlug,
|
ArtistSlug = model.ArtistSlug,
|
||||||
|
|
||||||
|
@ -174,7 +160,6 @@ namespace NzbDrone.Api.Music
|
||||||
//FirstAired = resource.FirstAired,
|
//FirstAired = resource.FirstAired,
|
||||||
//LastInfoSync = resource.LastInfoSync,
|
//LastInfoSync = resource.LastInfoSync,
|
||||||
//SeriesType = resource.SeriesType,
|
//SeriesType = resource.SeriesType,
|
||||||
CleanTitle = resource.CleanTitle,
|
|
||||||
ItunesId = resource.ItunesId,
|
ItunesId = resource.ItunesId,
|
||||||
ArtistSlug = resource.ArtistSlug,
|
ArtistSlug = resource.ArtistSlug,
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook.Resource
|
||||||
public string ArtistName { get; set; }
|
public string ArtistName { get; set; }
|
||||||
public int ArtistId { get; set; }
|
public int ArtistId { get; set; }
|
||||||
public string CollectionName { get; set; }
|
public string CollectionName { get; set; }
|
||||||
|
public int CollectionId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ArtistResource
|
public class ArtistResource
|
||||||
|
|
|
@ -99,7 +99,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
Console.WriteLine("httpRequest: ", httpRequest);
|
Console.WriteLine("httpRequest: ", httpRequest);
|
||||||
|
|
||||||
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest);
|
var httpResponse = _httpClient.Get<List<ShowResource>>(httpRequest);
|
||||||
|
|
||||||
//Console.WriteLine("Response: ", httpResponse.GetType());
|
//Console.WriteLine("Response: ", httpResponse.GetType());
|
||||||
//_logger.Info("Response: ", httpResponse.Resource.ResultCount);
|
//_logger.Info("Response: ", httpResponse.Resource.ResultCount);
|
||||||
|
@ -111,7 +111,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
tempList.Add(tempSeries);
|
tempList.Add(tempSeries);
|
||||||
return tempList;
|
return tempList;
|
||||||
|
|
||||||
//return httpResponse.Resource.Results.SelectList(MapArtist);
|
return httpResponse.Resource.SelectList(MapSeries);
|
||||||
}
|
}
|
||||||
catch (HttpException)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
|
@ -131,26 +131,26 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
var lowerTitle = title.ToLowerInvariant();
|
var lowerTitle = title.ToLowerInvariant();
|
||||||
Console.WriteLine("Searching for " + lowerTitle);
|
Console.WriteLine("Searching for " + lowerTitle);
|
||||||
|
|
||||||
//if (lowerTitle.StartsWith("tvdb:") || lowerTitle.StartsWith("tvdbid:"))
|
if (lowerTitle.StartsWith("itunes:") || lowerTitle.StartsWith("itunesid:"))
|
||||||
//{
|
{
|
||||||
// var slug = lowerTitle.Split(':')[1].Trim();
|
var slug = lowerTitle.Split(':')[1].Trim();
|
||||||
|
|
||||||
// int tvdbId;
|
int itunesId;
|
||||||
|
|
||||||
// if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !int.TryParse(slug, out tvdbId) || tvdbId <= 0)
|
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !int.TryParse(slug, out itunesId) || itunesId <= 0)
|
||||||
// {
|
{
|
||||||
// return new List<Series>();
|
return new List<Artist>();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// try
|
//try
|
||||||
// {
|
//{
|
||||||
// return new List<Series> { GetSeriesInfo(tvdbId).Item1 };
|
// return new List<Artist> { GetArtistInfo(itunesId).Item1 };
|
||||||
// }
|
//}
|
||||||
// catch (SeriesNotFoundException)
|
//catch (ArtistNotFoundException)
|
||||||
// {
|
//{
|
||||||
// return new List<Series>();
|
// return new List<Artist>();
|
||||||
// }
|
//}
|
||||||
//}
|
}
|
||||||
|
|
||||||
var httpRequest = _requestBuilder.Create()
|
var httpRequest = _requestBuilder.Create()
|
||||||
.AddQueryParam("entity", "album")
|
.AddQueryParam("entity", "album")
|
||||||
|
@ -163,15 +163,37 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest);
|
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest);
|
||||||
|
|
||||||
|
|
||||||
//Console.WriteLine("Response: ", httpResponse.GetType());
|
//Console.WriteLine("Response: ", httpResponse.GetType());
|
||||||
//_logger.Info("Response: ", httpResponse.Resource.ResultCount);
|
//_logger.Info("Response: ", httpResponse.Resource.ResultCount);
|
||||||
|
|
||||||
//_logger.Info("HTTP Response: ", httpResponse.Resource.ResultCount);
|
//_logger.Info("HTTP Response: ", httpResponse.Resource.ResultCount);
|
||||||
var tempList = new List<Artist>();
|
//var tempList = new List<Artist>();
|
||||||
var tempSeries = new Artist();
|
//var tempSeries = new Artist();
|
||||||
tempSeries.ArtistName = "AFI";
|
//tempSeries.ArtistName = "AFI";
|
||||||
tempList.Add(tempSeries);
|
//tempList.Add(tempSeries);
|
||||||
return tempList;
|
//return tempList;
|
||||||
|
|
||||||
|
|
||||||
|
Album tempAlbum;
|
||||||
|
// TODO: This needs to handle multiple artists.
|
||||||
|
Artist artist = new Artist();
|
||||||
|
artist.ArtistName = httpResponse.Resource.Results[0].ArtistName;
|
||||||
|
artist.ItunesId = httpResponse.Resource.Results[0].ArtistId;
|
||||||
|
foreach (var album in httpResponse.Resource.Results)
|
||||||
|
{
|
||||||
|
tempAlbum = new Album();
|
||||||
|
tempAlbum.AlbumId = album.CollectionId;
|
||||||
|
tempAlbum.Title = album.CollectionName;
|
||||||
|
|
||||||
|
artist.Albums.Add(tempAlbum);
|
||||||
|
}
|
||||||
|
|
||||||
|
var temp = new List<Artist>();
|
||||||
|
temp.Add(artist);
|
||||||
|
return temp;
|
||||||
|
|
||||||
|
// I need to return a list of mapped artists.
|
||||||
|
|
||||||
//return httpResponse.Resource.Results.SelectList(MapArtist);
|
//return httpResponse.Resource.Results.SelectList(MapArtist);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +211,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
private static Artist MapArtist(ArtistResource artistQuery)
|
private static Artist MapArtist(ArtistResource artistQuery)
|
||||||
{
|
{
|
||||||
var artist = new Artist();
|
var artist = new Artist();
|
||||||
//artist.ItunesId = artistQuery.artistId;
|
//artist.ItunesId = artistQuery.ItunesId; ;
|
||||||
|
|
||||||
// artist.ArtistName = artistQuery.ArtistName;
|
// artist.ArtistName = artistQuery.ArtistName;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Music
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AlbumId { get; set; }
|
public int AlbumId { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; } // NOTE: This should be CollectionName in API
|
||||||
public int Year { get; set; }
|
public int Year { get; set; }
|
||||||
public int TrackCount { get; set; }
|
public int TrackCount { get; set; }
|
||||||
public int DiscCount { get; set; }
|
public int DiscCount { get; set; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue