From af982114fbc540582b32243c38529806931083c7 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Tue, 23 Jul 2019 22:04:05 +0100 Subject: [PATCH] Added the integration to music brainz to get artist information. Next need to map that to a view model and surface a API for the UI to consume --- src/Ombi.Api.MusicBrainz/IMusicBrainzApi.cs | 2 + .../Models/Artist/ArtistInformation.cs | 58 +++++++++++++++++++ src/Ombi.Api.MusicBrainz/MusicBrainzApi.cs | 9 +++ 3 files changed, 69 insertions(+) create mode 100644 src/Ombi.Api.MusicBrainz/Models/Artist/ArtistInformation.cs diff --git a/src/Ombi.Api.MusicBrainz/IMusicBrainzApi.cs b/src/Ombi.Api.MusicBrainz/IMusicBrainzApi.cs index 5a5a769ca..cb1517d19 100644 --- a/src/Ombi.Api.MusicBrainz/IMusicBrainzApi.cs +++ b/src/Ombi.Api.MusicBrainz/IMusicBrainzApi.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Ombi.Api.MusicBrainz.Models.Artist; using Ombi.Api.MusicBrainz.Models.Browse; using Ombi.Api.MusicBrainz.Models.Search; @@ -9,5 +10,6 @@ namespace Ombi.Api.MusicBrainz { Task> SearchArtist(string artistQuery); Task> GetReleaseForArtist(string artistId); + Task GetArtistInformation(string artistId); } } \ No newline at end of file diff --git a/src/Ombi.Api.MusicBrainz/Models/Artist/ArtistInformation.cs b/src/Ombi.Api.MusicBrainz/Models/Artist/ArtistInformation.cs new file mode 100644 index 000000000..4453da632 --- /dev/null +++ b/src/Ombi.Api.MusicBrainz/Models/Artist/ArtistInformation.cs @@ -0,0 +1,58 @@ +using Newtonsoft.Json; + +namespace Ombi.Api.MusicBrainz.Models.Artist +{ + + public class ArtistInformation + { + public Begin_Area begin_area { get; set; } + [JsonProperty("gender-id")] + public object genderid { get; set; } + public string type { get; set; } + [JsonProperty("life-span")] + public LifeSpan lifespan { get; set; } + public string name { get; set; } + + [JsonProperty("type-id")] + public string typeid { get; set; } + public object end_area { get; set; } + public object[] ipis { get; set; } + [JsonProperty("sort-name")] + public string sortname { get; set; } + public string[] isnis { get; set; } + public object gender { get; set; } + public string id { get; set; } + public Area area { get; set; } + public string disambiguation { get; set; } + public string country { get; set; } + } + + public class Begin_Area + { + public string disambiguation { get; set; } + [JsonProperty("sort-name")] + public string sortname { get; set; } + public string id { get; set; } + public string name { get; set; } + } + + public class LifeSpan + { + public bool ended { get; set; } + public object end { get; set; } + public string begin { get; set; } + } + + public class Area + { + public string name { get; set; } + [JsonProperty("sort-name")] + public string sortname { get; set; } + public string disambiguation { get; set; } + public string id { get; set; } + + [JsonProperty("iso-3166-1-codes")] + public string[] iso31661codes { get; set; } + } + +} \ No newline at end of file diff --git a/src/Ombi.Api.MusicBrainz/MusicBrainzApi.cs b/src/Ombi.Api.MusicBrainz/MusicBrainzApi.cs index 8a6573042..812b427ac 100644 --- a/src/Ombi.Api.MusicBrainz/MusicBrainzApi.cs +++ b/src/Ombi.Api.MusicBrainz/MusicBrainzApi.cs @@ -5,6 +5,7 @@ using System.Net.Http; using System.Threading.Tasks; using Ombi.Api.MusicBrainz.Models; +using Ombi.Api.MusicBrainz.Models.Artist; using Ombi.Api.MusicBrainz.Models.Browse; using Ombi.Api.MusicBrainz.Models.Search; @@ -30,6 +31,14 @@ namespace Ombi.Api.MusicBrainz return albums.Data.Where(x => !x.type.Equals("Person", StringComparison.CurrentCultureIgnoreCase)); } + public async Task GetArtistInformation(string artistId) + { + var request = new Request($"artist/{artistId}", _baseUrl, HttpMethod.Get); + AddHeaders(request); + + return await _api.Request(request); + } + public async Task> GetReleaseForArtist(string artistId) { var request = new Request("release", _baseUrl, HttpMethod.Get);