!wip on music

This commit is contained in:
Jamie Rees 2019-07-24 22:18:29 +01:00
parent 7ce5074926
commit 0a192c5e83
17 changed files with 136 additions and 376 deletions

View file

@ -26,7 +26,7 @@
<entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MusicSearchEngineV2.cs"> <entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MusicSearchEngineV2.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240"> <state relative-caret-position="240">
<caret line="15" column="1" lean-forward="true" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" /> <caret line="15" column="1" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
<folding> <folding>
<marker date="1563971976383" expanded="true" signature="6:402" ph="..." /> <marker date="1563971976383" expanded="true" signature="6:402" ph="..." />
<marker date="1563971976383" expanded="true" signature="512:1600" ph="{...}" /> <marker date="1563971976383" expanded="true" signature="512:1600" ph="{...}" />
@ -42,7 +42,7 @@
<entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/Interfaces/IMusicSearchEngineV2.cs"> <entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/Interfaces/IMusicSearchEngineV2.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="48"> <state relative-caret-position="48">
<caret line="3" column="37" lean-forward="true" selection-start-line="3" selection-start-column="37" selection-end-line="3" selection-end-column="37" /> <caret line="3" column="37" selection-start-line="3" selection-start-column="37" selection-end-line="3" selection-end-column="37" />
<folding> <folding>
<marker date="1563971976358" expanded="true" signature="6:69" ph="..." /> <marker date="1563971976358" expanded="true" signature="6:69" ph="..." />
<marker date="1563971976358" expanded="true" signature="108:237" ph="{...}" /> <marker date="1563971976358" expanded="true" signature="108:237" ph="{...}" />
@ -99,7 +99,7 @@
<entry file="file://$PROJECT_DIR$/Ombi/Controllers/V2/SearchController.cs"> <entry file="file://$PROJECT_DIR$/Ombi/Controllers/V2/SearchController.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="290"> <state relative-caret-position="290">
<caret line="54" column="48" lean-forward="true" selection-start-line="54" selection-start-column="48" selection-end-line="54" selection-end-column="48" /> <caret line="54" column="48" selection-start-line="54" selection-start-column="48" selection-end-line="54" selection-end-column="48" />
<folding> <folding>
<marker date="1563972058760" expanded="false" signature="6:492" ph="..." /> <marker date="1563972058760" expanded="false" signature="6:492" ph="..." />
<marker date="1563972058760" expanded="true" signature="523:13818" ph="{...}" /> <marker date="1563972058760" expanded="true" signature="523:13818" ph="{...}" />
@ -175,7 +175,7 @@
<entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MultiSearchEngine.cs"> <entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MultiSearchEngine.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="146"> <state relative-caret-position="146">
<caret line="47" column="58" lean-forward="true" selection-start-line="47" selection-start-column="58" selection-end-line="47" selection-end-column="58" /> <caret line="47" column="58" selection-start-line="47" selection-start-column="58" selection-end-line="47" selection-end-column="58" />
<folding> <folding>
<marker date="1563908151735" expanded="false" signature="6:540" ph="..." /> <marker date="1563908151735" expanded="false" signature="6:540" ph="..." />
<marker date="1563908151735" expanded="true" signature="571:3867" ph="{...}" /> <marker date="1563908151735" expanded="true" signature="571:3867" ph="{...}" />
@ -216,8 +216,8 @@
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/Ombi.Api.MusicBrainz/MusicBrainzApi.cs"> <entry file="file://$PROJECT_DIR$/Ombi.Api.MusicBrainz/MusicBrainzApi.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="288"> <state relative-caret-position="320">
<caret line="30" column="21" selection-start-line="30" selection-start-column="21" selection-end-line="30" selection-end-column="21" /> <caret line="32" selection-start-line="32" selection-end-line="32" />
<folding> <folding>
<marker date="1563915793306" expanded="false" signature="6:281" ph="..." /> <marker date="1563915793306" expanded="false" signature="6:281" ph="..." />
<marker date="1563915793306" expanded="true" signature="313:1888" ph="{...}" /> <marker date="1563915793306" expanded="true" signature="313:1888" ph="{...}" />
@ -447,12 +447,12 @@
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1563957157468</updated> <updated>1563957157468</updated>
<workItem from="1563957162999" duration="5139000" /> <workItem from="1563957162999" duration="5401000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="5139000" /> <option name="totallyTimeSpent" value="5401000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -465,7 +465,6 @@
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="977" y="-1093" width="1936" height="1056" extended-state="6" /> <frame x="977" y="-1093" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout> <layout>
<window_info id="Favorites" order="0" side_tool="true" /> <window_info id="Favorites" order="0" side_tool="true" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
@ -481,7 +480,7 @@
<window_info anchor="bottom" id="Message" order="7" /> <window_info anchor="bottom" id="Message" order="7" />
<window_info anchor="bottom" id="Find" order="8" /> <window_info anchor="bottom" id="Find" order="8" />
<window_info anchor="bottom" id="Run" order="9" weight="0.32977587" /> <window_info anchor="bottom" id="Run" order="9" weight="0.32977587" />
<window_info active="true" anchor="bottom" id="Debug" order="10" sideWeight="0.49973363" visible="true" weight="0.29775882" /> <window_info anchor="bottom" id="Debug" order="10" sideWeight="0.49973363" weight="0.29775882" />
<window_info anchor="bottom" id="Cvs" order="11" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="11" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="12" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="12" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="13" weight="0.32977587" /> <window_info anchor="bottom" id="TODO" order="13" weight="0.32977587" />
@ -850,7 +849,7 @@
<entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MusicSearchEngineV2.cs"> <entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MusicSearchEngineV2.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240"> <state relative-caret-position="240">
<caret line="15" column="1" lean-forward="true" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" /> <caret line="15" column="1" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
<folding> <folding>
<marker date="1563971976383" expanded="true" signature="6:402" ph="..." /> <marker date="1563971976383" expanded="true" signature="6:402" ph="..." />
<marker date="1563971976383" expanded="true" signature="512:1600" ph="{...}" /> <marker date="1563971976383" expanded="true" signature="512:1600" ph="{...}" />
@ -878,7 +877,7 @@
<entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/Interfaces/IMusicSearchEngineV2.cs"> <entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/Interfaces/IMusicSearchEngineV2.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="48"> <state relative-caret-position="48">
<caret line="3" column="37" lean-forward="true" selection-start-line="3" selection-start-column="37" selection-end-line="3" selection-end-column="37" /> <caret line="3" column="37" selection-start-line="3" selection-start-column="37" selection-end-line="3" selection-end-column="37" />
<folding> <folding>
<marker date="1563971976358" expanded="true" signature="6:69" ph="..." /> <marker date="1563971976358" expanded="true" signature="6:69" ph="..." />
<marker date="1563971976358" expanded="true" signature="108:237" ph="{...}" /> <marker date="1563971976358" expanded="true" signature="108:237" ph="{...}" />
@ -913,7 +912,7 @@
<entry file="file://$PROJECT_DIR$/Ombi/Controllers/V2/SearchController.cs"> <entry file="file://$PROJECT_DIR$/Ombi/Controllers/V2/SearchController.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="290"> <state relative-caret-position="290">
<caret line="54" column="48" lean-forward="true" selection-start-line="54" selection-start-column="48" selection-end-line="54" selection-end-column="48" /> <caret line="54" column="48" selection-start-line="54" selection-start-column="48" selection-end-line="54" selection-end-column="48" />
<folding> <folding>
<marker date="1563972058760" expanded="false" signature="6:492" ph="..." /> <marker date="1563972058760" expanded="false" signature="6:492" ph="..." />
<marker date="1563972058760" expanded="true" signature="523:13818" ph="{...}" /> <marker date="1563972058760" expanded="true" signature="523:13818" ph="{...}" />
@ -985,7 +984,7 @@
<entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MultiSearchEngine.cs"> <entry file="file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MultiSearchEngine.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="146"> <state relative-caret-position="146">
<caret line="47" column="58" lean-forward="true" selection-start-line="47" selection-start-column="58" selection-end-line="47" selection-end-column="58" /> <caret line="47" column="58" selection-start-line="47" selection-start-column="58" selection-end-line="47" selection-end-column="58" />
<folding> <folding>
<marker date="1563908151735" expanded="false" signature="6:540" ph="..." /> <marker date="1563908151735" expanded="false" signature="6:540" ph="..." />
<marker date="1563908151735" expanded="true" signature="571:3867" ph="{...}" /> <marker date="1563908151735" expanded="true" signature="571:3867" ph="{...}" />
@ -1022,8 +1021,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/Ombi.Api.MusicBrainz/MusicBrainzApi.cs"> <entry file="file://$PROJECT_DIR$/Ombi.Api.MusicBrainz/MusicBrainzApi.cs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="288"> <state relative-caret-position="320">
<caret line="30" column="21" selection-start-line="30" selection-start-column="21" selection-end-line="30" selection-end-column="21" /> <caret line="32" selection-start-line="32" selection-end-line="32" />
<folding> <folding>
<marker date="1563915793306" expanded="false" signature="6:281" ph="..." /> <marker date="1563915793306" expanded="false" signature="6:281" ph="..." />
<marker date="1563915793306" expanded="true" signature="313:1888" ph="{...}" /> <marker date="1563915793306" expanded="true" signature="313:1888" ph="{...}" />

View file

@ -1,8 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Api.MusicBrainz.Models.Artist; using Hqub.MusicBrainz.API.Entities;
using Ombi.Api.MusicBrainz.Models.Browse;
using Ombi.Api.MusicBrainz.Models.Search;
namespace Ombi.Api.MusicBrainz namespace Ombi.Api.MusicBrainz
{ {
@ -10,6 +8,6 @@ namespace Ombi.Api.MusicBrainz
{ {
Task<IEnumerable<Artist>> SearchArtist(string artistQuery); Task<IEnumerable<Artist>> SearchArtist(string artistQuery);
Task<IEnumerable<Release>> GetReleaseForArtist(string artistId); Task<IEnumerable<Release>> GetReleaseForArtist(string artistId);
Task<ArtistInformation> GetArtistInformation(string artistId); Task<Artist> GetArtistInformation(string artistId);
} }
} }

View file

@ -1,58 +0,0 @@
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 string 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; }
}
}

View file

@ -1,106 +0,0 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Ombi.Api.MusicBrainz.Models.Browse
{
public class CoverArtArchive
{
public bool back { get; set; }
public bool artwork { get; set; }
public bool darkened { get; set; }
public int count { get; set; }
public bool front { get; set; }
}
public class TextRepresentation
{
public string script { get; set; }
public string language { get; set; }
}
public class Recording
{
public int length { get; set; }
public string disambiguation { get; set; }
public string title { get; set; }
public string id { get; set; }
public bool video { get; set; }
}
public class Track
{
public string title { get; set; }
public Recording recording { get; set; }
public string number { get; set; }
public string id { get; set; }
public int? length { get; set; }
public int position { get; set; }
}
public class Medium
{
[JsonProperty(PropertyName = "track-count")]
public int TrackCount { get; set; }
public string title { get; set; }
[JsonProperty(PropertyName = "track-offset")]
public int TrackOffset { get; set; }
public int position { get; set; }
[JsonProperty(PropertyName = "format-id")]
public string FormatId { get; set; }
public string format { get; set; }
public List<Track> tracks { get; set; }
}
public class Area
{
public string id { get; set; }
[JsonProperty(PropertyName = "sort-name")]
public string SortName { get; set; }
public string disambiguation { get; set; }
public string name { get; set; }
[JsonProperty(PropertyName = "iso-3166-1-codes")]
public List<string> Iso31661Codes { get; set; }
[JsonProperty(PropertyName = "iso-3166-2-codes")]
public List<string> Iso31662Codes { get; set; }
}
public class ReleaseEvent
{
public string date { get; set; }
public Area area { get; set; }
}
public class Release
{
public string quality { get; set; }
public string asin { get; set; }
public string date { get; set; }
public string status { get; set; }
public string barcode { get; set; }
[JsonProperty(PropertyName = "cover-art-archive")]
public CoverArtArchive CoverArtArchive { get; set; }
public string packaging { get; set; }
[JsonProperty(PropertyName = "packaging-id")]
public string PackagingId { get; set; }
[JsonProperty(PropertyName = "status-id")]
public string StatusId { get; set; }
public string disambiguation { get; set; }
public string country { get; set; }
[JsonProperty(PropertyName = "text-representation")]
public TextRepresentation TextRepresentation { get; set; }
public string title { get; set; }
public List<Medium> media { get; set; }
public string id { get; set; }
[JsonProperty(PropertyName = "release-events")]
public List<ReleaseEvent> ReleaseEvents { get; set; }
}
public class ReleaseResult
{
[JsonProperty(PropertyName = "release-count")]
public int ReleaseCount { get; set; }
[JsonProperty(PropertyName = "release-offset")]
public int ReleaseOffset { get; set; }
public List<Release> releases { get; set; }
}
}

View file

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
namespace Ombi.Api.MusicBrainz.Models
{
public class MusicBrainzResult<T>
{
public DateTime created { get; set; }
public int count { get; set; }
public int offset { get; set; }
[JsonPropertyNameBasedOnItemClass]
public List<T> Data { get; set; }
}
}

View file

@ -1,83 +0,0 @@
using Newtonsoft.Json;
namespace Ombi.Api.MusicBrainz.Models.Search
{
[JsonPluralName("artists")]
public class Artist
{
public string id { get; set; }
public string type { get; set; }
[JsonProperty(PropertyName = "type-id")]
public string typeid { get; set; }
public int score { get; set; }
public string name { get; set; }
[JsonProperty(PropertyName = "sort-name")]
public string sortname { get; set; }
public string country { get; set; }
public Area area { get; set; }
[JsonProperty(PropertyName = "begin-area")]
public BeginArea beginarea { get; set; }
[JsonProperty(PropertyName = "life-span")]
public LifeSpan2 lifespan { get; set; }
public Tag[] tags { get; set; }
[JsonProperty(PropertyName = "isni-list")]
public IsniList[] isnilist { get; set; }
public string disambiguation { get; set; }
}
public class Area
{
public string id { get; set; }
public string type { get; set; }
[JsonProperty(PropertyName = "type-id")]
public string typeid { get; set; }
public string name { get; set; }
[JsonProperty(PropertyName = "sort-name")]
public string sortname { get; set; }
[JsonProperty(PropertyName = "life-span")]
public LifeSpan lifespan { get; set; }
}
public class LifeSpan
{
public object ended { get; set; }
}
public class BeginArea
{
public string id { get; set; }
public string type { get; set; }
[JsonProperty(PropertyName = "type-id")]
public string typeid { get; set; }
public string name { get; set; }
[JsonProperty(PropertyName = "sort-name")]
public string sortname { get; set; }
[JsonProperty(PropertyName = "life-span")]
public LifeSpan1 lifespan { get; set; }
}
public class LifeSpan1
{
public object ended { get; set; }
}
public class LifeSpan2
{
public string begin { get; set; }
public object ended { get; set; }
}
public class Tag
{
public int count { get; set; }
public string name { get; set; }
}
public class IsniList
{
public string isni { get; set; }
}
}

View file

@ -3,52 +3,39 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hqub.MusicBrainz.API;
using Ombi.Api.MusicBrainz.Models; using Hqub.MusicBrainz.API.Entities;
using Ombi.Api.MusicBrainz.Models.Artist;
using Ombi.Api.MusicBrainz.Models.Browse;
using Ombi.Api.MusicBrainz.Models.Search;
namespace Ombi.Api.MusicBrainz namespace Ombi.Api.MusicBrainz
{ {
public class MusicBrainzApi : IMusicBrainzApi public class MusicBrainzApi : IMusicBrainzApi
{ {
public MusicBrainzApi(IApi api)
{
_api = api;
}
private readonly IApi _api;
private const string _baseUrl = "https://musicbrainz.org/ws/2/";
public async Task<IEnumerable<Artist>> SearchArtist(string artistQuery) public async Task<IEnumerable<Artist>> SearchArtist(string artistQuery)
{ {
var request = new Request("artist", _baseUrl, HttpMethod.Get); var artist = await Hqub.MusicBrainz.API.Entities.Artist.SearchAsync(artistQuery, 10);
return artist.Items.Where(x => !x.Type.Equals("Person", StringComparison.CurrentCultureIgnoreCase));
request.AddQueryString("query", artistQuery);
AddHeaders(request);
var albums = await _api.Request<MusicBrainzResult<Artist>>(request);
return albums.Data.Where(x => !x.type.Equals("Person", StringComparison.CurrentCultureIgnoreCase));
} }
public async Task<ArtistInformation> GetArtistInformation(string artistId) public async Task<Artist> GetArtistInformation(string artistId)
{ {
var request = new Request($"artist/{artistId}", _baseUrl, HttpMethod.Get); var artist = await Artist.GetAsync(artistId, "artist-rels", "url-rels", "releases", "release-groups");
AddHeaders(request); return artist;
return await _api.Request<ArtistInformation>(request);
} }
public async Task<IEnumerable<Release>> GetReleaseForArtist(string artistId) public async Task<IEnumerable<Release>> GetReleaseForArtist(string artistId)
{ {
var request = new Request("release", _baseUrl, HttpMethod.Get); // Build an advanced query to search for the release.
var query = new QueryParameters<Release>()
{
{ "arid", artistId },
{ "status", "official" }
};
request.AddQueryString("artist", artistId); // Search for a release by title.
request.AddQueryString("inc", "recordings"); var releases = await Release.SearchAsync(query);
AddHeaders(request);
var releases = await _api.Request<ReleaseResult>(request);
return releases.releases; return releases.Items;
} }
private void AddHeaders(Request req) private void AddHeaders(Request req)

View file

@ -4,6 +4,10 @@
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="MusicBrainzAPI" Version="2.0.1" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" /> <ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
</ItemGroup> </ItemGroup>

View file

@ -51,8 +51,8 @@ namespace Ombi.Core.Engine.V2
model.Add(new MultiSearchResult model.Add(new MultiSearchResult
{ {
MediaType = "Artist", MediaType = "Artist",
Title = artist.name, Title = artist.Name,
Id = artist.id Id = artist.Id
}); });
} }
} }

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Security.Principal; using System.Security.Principal;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Api.MusicBrainz; using Ombi.Api.MusicBrainz;
@ -30,16 +31,31 @@ namespace Ombi.Core.Engine.V2
{ {
var artist = await _musicBrainzApi.GetArtistInformation(artistId); var artist = await _musicBrainzApi.GetArtistInformation(artistId);
return new ArtistInformation{ var info = new ArtistInformation
{
Id = artistId, Id = artistId,
Name = artist.name, Name = artist.Name,
Country = artist.country, Country = artist.Country,
Region = artist.begin_area?.name, Region = artist.Area?.Name,
Type = artist.type, Type = artist.Type,
StartYear = artist.lifespan?.begin ?? "", StartYear = artist.LifeSpan?.Begin ?? "",
EndYear = artist.lifespan?.end?? "", EndYear = artist.LifeSpan?.End?? "",
Disambiguation = artist.Disambiguation,
ReleaseGroups = new List<ReleaseGroup>()
}; };
// TODO FINISH MAPPING
foreach (var g in artist.ReleaseGroups)
{
info.ReleaseGroups.Add(new ReleaseGroup
{
Type = g.PrimaryType,
Id = g.Id,
Title = g.Title,
ReleaseDate = g.FirstReleaseDate
});
}
return info;
} }
} }
} }

View file

@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace Ombi.Core.Models.Search.V2.Music namespace Ombi.Core.Models.Search.V2.Music
{ {
public class ArtistInformation public class ArtistInformation
@ -9,5 +11,30 @@ namespace Ombi.Core.Models.Search.V2.Music
public string Type { get; set; } public string Type { get; set; }
public string Country { get; set; } public string Country { get; set; }
public string Region { get; set; } public string Region { get; set; }
public string Disambiguation { get; set; }
public List<ReleaseGroup> ReleaseGroups { get; set; }
public List<ArtistLinks> Links { get; set; }
}
public class ArtistLinks
{
public string Image { get; set; }
public string Imdb { get; set; }
public string LastFm { get; set; }
public string Discogs { get; set; }
public string BandsInTown { get; set; }
public string Website { get; set; }
public string YouTube { get; set; }
public string Facebook { get; set; }
public string Twitter { get; set; }
}
public class ReleaseGroup
{
public string Id { get; set; }
public string Title { get; set; }
public string ReleaseDate { get; set; }
public string Type { get; set; }
} }
} }

View file

@ -14,6 +14,7 @@
<PackageReference Include="Hangfire" Version="1.7.0" /> <PackageReference Include="Hangfire" Version="1.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
<PackageReference Include="MusicBrainzAPI" Version="2.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" /> <PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
</ItemGroup> </ItemGroup>

View file

@ -0,0 +1,9 @@
export interface IArtistSearchResult {
name: string;
id: string;
startYear: string;
endYear: string;
type: string;
country: string;
region: string;
}

View file

@ -1,11 +1,10 @@
<div *ngIf="!movie" class="justify-content-md-center top-spacing loading-spinner"> <div *ngIf="!artist" class="justify-content-md-center top-spacing loading-spinner">
<mat-spinner [color]="'accent'"></mat-spinner> <mat-spinner [color]="'accent'"></mat-spinner>
</div> </div>
<div *ngIf="movie" class="dark-theme"> <div *ngIf="artist" class="dark-theme">
<top-banner [background]="movie.background" [available]="movie.available" [title]="movie.title" <top-banner [title]="artist.name"></top-banner>
[releaseDate]="movie.releaseDate" [tagline]="movie.tagline"></top-banner>
<section id="info-wrapper"> <section id="info-wrapper">
<div class="small-middle-container"> <div class="small-middle-container">

View file

@ -1,28 +1,25 @@
import { Component, ViewEncapsulation } from "@angular/core"; import { Component } from "@angular/core";
import { ImageService, SearchV2Service, RequestService, MessageService } from "../../../services"; import { ImageService, SearchV2Service, RequestService, MessageService } from "../../../services";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { DomSanitizer } from "@angular/platform-browser"; import { DomSanitizer } from "@angular/platform-browser";
import { ISearchMovieResultV2 } from "../../../interfaces/ISearchMovieResultV2";
import { MatDialog } from "@angular/material"; import { MatDialog } from "@angular/material";
import { YoutubeTrailerComponent } from "../shared/youtube-trailer.component"; import { YoutubeTrailerComponent } from "../shared/youtube-trailer.component";
import { AuthService } from "../../../auth/auth.service"; import { AuthService } from "../../../auth/auth.service";
import { IMovieRequests, RequestType, IAdvancedData } from "../../../interfaces";
import { DenyDialogComponent } from "../shared/deny-dialog/deny-dialog.component"; import { DenyDialogComponent } from "../shared/deny-dialog/deny-dialog.component";
import { NewIssueComponent } from "../shared/new-issue/new-issue.component"; import { NewIssueComponent } from "../shared/new-issue/new-issue.component";
import { IArtistSearchResult } from "../../../interfaces/IMusicSearchResultV2";
@Component({ @Component({
templateUrl: "./artist-details.component.html", templateUrl: "./artist-details.component.html",
styleUrls: ["../../media-details.component.scss"], styleUrls: ["../../media-details.component.scss"],
}) })
export class ArtistDetailsComponent { export class ArtistDetailsComponent {
public movie: ISearchMovieResultV2;
public hasRequest: boolean;
public movieRequest: IMovieRequests;
public isAdmin: boolean;
public advancedOptions: IAdvancedData;
private artistId: string; private artistId: string;
public artist: IArtistSearchResult;
public isAdmin: boolean;
constructor(private searchService: SearchV2Service, private route: ActivatedRoute, constructor(private searchService: SearchV2Service, private route: ActivatedRoute,
private sanitizer: DomSanitizer, private imageService: ImageService, private sanitizer: DomSanitizer, private imageService: ImageService,
public dialog: MatDialog, private requestService: RequestService, public dialog: MatDialog, private requestService: RequestService,
@ -34,22 +31,8 @@ export class ArtistDetailsComponent {
} }
public load() { public load() {
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser"); this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
this.searchService.getArtistInformation(this.artistId).subscribe(); this.searchService.getArtistInformation(this.artistId).subscribe(x => this.artist = x);
// this.searchService.getFullMovieDetails(this.theMovidDbId).subscribe(async x => {
// this.movie = x;
// if (this.movie.requestId > 0) {
// // Load up this request
// this.hasRequest = true;
// this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId);
// }
// this.imageService.getMovieBanner(this.theMovidDbId.toString()).subscribe(x => {
// this.movie.background = this.sanitizer.bypassSecurityTrustStyle
// ("url(" + x + ")");
// });
// });
} }
public async request() { public async request() {
@ -65,52 +48,52 @@ export class ArtistDetailsComponent {
public openDialog() { public openDialog() {
this.dialog.open(YoutubeTrailerComponent, { this.dialog.open(YoutubeTrailerComponent, {
width: '560px', width: '560px',
data: this.movie.videos.results[0].key // data: this.movie.videos.results[0].key
}); });
} }
public async deny() { public async deny() {
const dialogRef = this.dialog.open(DenyDialogComponent, { const dialogRef = this.dialog.open(DenyDialogComponent, {
width: '250px', width: '250px',
data: {requestId: this.movieRequest.id, requestType: RequestType.movie} // data: {requestId: this.movieRequest.id, requestType: RequestType.movie}
}); });
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
this.movieRequest.denied = result; // this.movieRequest.denied = result;
if(this.movieRequest.denied) { // if(this.movieRequest.denied) {
this.movie.approved = false; // this.movie.approved = false;
} // }
}); });
} }
public async issue() { public async issue() {
const dialogRef = this.dialog.open(NewIssueComponent, { const dialogRef = this.dialog.open(NewIssueComponent, {
width: '500px', width: '500px',
data: {requestId: this.movieRequest ? this.movieRequest.id : null, requestType: RequestType.movie, imdbid: this.movie.imdbId} // data: {requestId: this.movieRequest ? this.movieRequest.id : null, requestType: RequestType.movie, imdbid: this.movie.imdbId}
}); });
} }
public async approve() { public async approve() {
const result = await this.requestService.approveMovie({ id: this.movieRequest.id }).toPromise(); // const result = await this.requestService.approveMovie({ id: this.movieRequest.id }).toPromise();
if (result.result) { // if (result.result) {
this.movie.approved = false; // this.movie.approved = false;
this.messageService.send("Successfully Approved", "Ok"); // this.messageService.send("Successfully Approved", "Ok");
} else { // } else {
this.messageService.send(result.errorMessage, "Ok"); // this.messageService.send(result.errorMessage, "Ok");
} // }
} }
public async markAvailable() { public async markAvailable() {
const result = await this.requestService.markMovieAvailable({id: this.movieRequest.id}).toPromise(); // const result = await this.requestService.markMovieAvailable({id: this.movieRequest.id}).toPromise();
if (result.result) { // if (result.result) {
this.movie.available = true; // // this.movie.available = true;
this.messageService.send(result.message, "Ok"); // this.messageService.send(result.message, "Ok");
} else { // } else {
this.messageService.send(result.errorMessage, "Ok"); // this.messageService.send(result.errorMessage, "Ok");
} // }
} }
public setAdvancedOptions(data: any) { public setAdvancedOptions(data: any) {
this.advancedOptions = data; // this.advancedOptions = data;
} }
} }

View file

@ -9,6 +9,7 @@ import { ServiceHelpers } from "./service.helpers";
import { ISearchMovieResultV2 } from "../interfaces/ISearchMovieResultV2"; import { ISearchMovieResultV2 } from "../interfaces/ISearchMovieResultV2";
import { ISearchTvResultV2, IMovieCollectionsViewModel, IActorCredits } from "../interfaces/ISearchTvResultV2"; import { ISearchTvResultV2, IMovieCollectionsViewModel, IActorCredits } from "../interfaces/ISearchTvResultV2";
import { IArtistSearchResult } from "../interfaces/IMusicSearchResultV2";
@Injectable() @Injectable()
export class SearchV2Service extends ServiceHelpers { export class SearchV2Service extends ServiceHelpers {
@ -99,7 +100,7 @@ export class SearchV2Service extends ServiceHelpers {
return this.http.get<IActorCredits>(`${this.url}/actor/${actorId}/movie`, { headers: this.headers }); return this.http.get<IActorCredits>(`${this.url}/actor/${actorId}/movie`, { headers: this.headers });
} }
public getArtistInformation(artistId: string): Observable<any> { public getArtistInformation(artistId: string): Observable<IArtistSearchResult> {
return this.http.get<any>(`${this.url}/artist/${artistId}`); return this.http.get<IArtistSearchResult>(`${this.url}/artist/${artistId}`);
} }
} }

View file

@ -5,8 +5,6 @@ using Microsoft.AspNetCore.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using Ombi.Api.MusicBrainz;
using Ombi.Api.MusicBrainz.Models.Search;
using Ombi.Core; using Ombi.Core;
using Ombi.Api.TheMovieDb.Models; using Ombi.Api.TheMovieDb.Models;
using Ombi.Core.Engine.V2; using Ombi.Core.Engine.V2;