mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 01:02:57 -07:00
Small work on the API !wip
This commit is contained in:
parent
432c7763ee
commit
26d620cf01
5 changed files with 165 additions and 9 deletions
|
@ -10,5 +10,8 @@ namespace Ombi.Api.Lidarr
|
||||||
Task<List<ArtistLookup>> ArtistLookup(string searchTerm, string apiKey, string baseUrl);
|
Task<List<ArtistLookup>> ArtistLookup(string searchTerm, string apiKey, string baseUrl);
|
||||||
Task<List<LidarrProfile>> GetProfiles(string apiKey, string baseUrl);
|
Task<List<LidarrProfile>> GetProfiles(string apiKey, string baseUrl);
|
||||||
Task<List<LidarrRootFolder>> GetRootFolders(string apiKey, string baseUrl);
|
Task<List<LidarrRootFolder>> GetRootFolders(string apiKey, string baseUrl);
|
||||||
|
Task<ArtistResult> GetArtist(int artistId, string apiKey, string baseUrl);
|
||||||
|
Task<ArtistResult> GetArtistByForignId(string foreignArtistId, string apiKey, string baseUrl);
|
||||||
|
Task<AlbumByArtistResponse> GetAlbumsByArtist(int artistId, string apiKey, string baseUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,20 +20,20 @@ namespace Ombi.Api.Lidarr
|
||||||
|
|
||||||
private const string ApiVersion = "/api/v1";
|
private const string ApiVersion = "/api/v1";
|
||||||
|
|
||||||
public async Task<List<LidarrProfile>> GetProfiles(string apiKey, string baseUrl)
|
public Task<List<LidarrProfile>> GetProfiles(string apiKey, string baseUrl)
|
||||||
{
|
{
|
||||||
var request = new Request($"{ApiVersion}/profile", baseUrl, HttpMethod.Get);
|
var request = new Request($"{ApiVersion}/profile", baseUrl, HttpMethod.Get);
|
||||||
|
|
||||||
AddHeaders(request, apiKey);
|
AddHeaders(request, apiKey);
|
||||||
return await Api.Request<List<LidarrProfile>>(request);
|
return Api.Request<List<LidarrProfile>>(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<LidarrRootFolder>> GetRootFolders(string apiKey, string baseUrl)
|
public Task<List<LidarrRootFolder>> GetRootFolders(string apiKey, string baseUrl)
|
||||||
{
|
{
|
||||||
var request = new Request($"{ApiVersion}/rootfolder", baseUrl, HttpMethod.Get);
|
var request = new Request($"{ApiVersion}/rootfolder", baseUrl, HttpMethod.Get);
|
||||||
|
|
||||||
AddHeaders(request, apiKey);
|
AddHeaders(request, apiKey);
|
||||||
return await Api.Request<List<LidarrRootFolder>>(request);
|
return Api.Request<List<LidarrRootFolder>>(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<ArtistLookup>> ArtistLookup(string searchTerm, string apiKey, string baseUrl)
|
public async Task<List<ArtistLookup>> ArtistLookup(string searchTerm, string apiKey, string baseUrl)
|
||||||
|
@ -45,13 +45,39 @@ namespace Ombi.Api.Lidarr
|
||||||
return await Api.Request<List<ArtistLookup>>(request);
|
return await Api.Request<List<ArtistLookup>>(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<AlbumLookup>> AlbumLookup(string searchTerm, string apiKey, string baseUrl)
|
public Task<List<AlbumLookup>> AlbumLookup(string searchTerm, string apiKey, string baseUrl)
|
||||||
{
|
{
|
||||||
var request = new Request($"{ApiVersion}/Album/lookup", baseUrl, HttpMethod.Get);
|
var request = new Request($"{ApiVersion}/Album/lookup", baseUrl, HttpMethod.Get);
|
||||||
request.AddQueryString("term", searchTerm);
|
request.AddQueryString("term", searchTerm);
|
||||||
|
|
||||||
AddHeaders(request, apiKey);
|
AddHeaders(request, apiKey);
|
||||||
return await Api.Request<List<AlbumLookup>>(request);
|
return Api.Request<List<AlbumLookup>>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<ArtistResult> GetArtist(int artistId, string apiKey, string baseUrl)
|
||||||
|
{
|
||||||
|
var request = new Request($"{ApiVersion}/artist/{artistId}", baseUrl, HttpMethod.Get);
|
||||||
|
|
||||||
|
AddHeaders(request, apiKey);
|
||||||
|
return Api.Request<ArtistResult>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<ArtistResult> GetArtistByForignId(string foreignArtistId, string apiKey, string baseUrl)
|
||||||
|
{
|
||||||
|
var request = new Request($"{ApiVersion}/artist/lookup", baseUrl, HttpMethod.Get);
|
||||||
|
|
||||||
|
request.AddQueryString("term", $"lidarr:{foreignArtistId}");
|
||||||
|
AddHeaders(request, apiKey);
|
||||||
|
return Api.Request<ArtistResult>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<AlbumByArtistResponse> GetAlbumsByArtist(int artistId, string apiKey, string baseUrl)
|
||||||
|
{
|
||||||
|
var request = new Request($"{ApiVersion}/album", baseUrl, HttpMethod.Get);
|
||||||
|
|
||||||
|
request.AddQueryString("artistId", artistId.ToString());
|
||||||
|
AddHeaders(request, apiKey);
|
||||||
|
return Api.Request<AlbumByArtistResponse>(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddHeaders(Request request, string key)
|
private void AddHeaders(Request request, string key)
|
||||||
|
|
27
src/Ombi.Api.Lidarr/Models/AlbumByArtistResponse.cs
Normal file
27
src/Ombi.Api.Lidarr/Models/AlbumByArtistResponse.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ombi.Api.Lidarr.Models
|
||||||
|
{
|
||||||
|
public class AlbumByArtistResponse
|
||||||
|
{
|
||||||
|
public string title { get; set; }
|
||||||
|
public string disambiguation { get; set; }
|
||||||
|
public int artistId { get; set; }
|
||||||
|
public string foreignAlbumId { get; set; }
|
||||||
|
public bool monitored { get; set; }
|
||||||
|
public int profileId { get; set; }
|
||||||
|
public int duration { get; set; }
|
||||||
|
public string albumType { get; set; }
|
||||||
|
public object[] secondaryTypes { get; set; }
|
||||||
|
public int mediumCount { get; set; }
|
||||||
|
public Ratings ratings { get; set; }
|
||||||
|
public DateTime releaseDate { get; set; }
|
||||||
|
public Currentrelease currentRelease { get; set; }
|
||||||
|
public Release[] releases { get; set; }
|
||||||
|
public object[] genres { get; set; }
|
||||||
|
public Medium[] media { get; set; }
|
||||||
|
public Image[] images { get; set; }
|
||||||
|
public Statistics statistics { get; set; }
|
||||||
|
public int id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
93
src/Ombi.Api.Lidarr/Models/ArtistResult.cs
Normal file
93
src/Ombi.Api.Lidarr/Models/ArtistResult.cs
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ombi.Api.Lidarr.Models
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ArtistResult
|
||||||
|
{
|
||||||
|
public string status { get; set; }
|
||||||
|
public bool ended { get; set; }
|
||||||
|
public DateTime lastInfoSync { get; set; }
|
||||||
|
public string artistName { get; set; }
|
||||||
|
public string foreignArtistId { get; set; }
|
||||||
|
public int tadbId { get; set; }
|
||||||
|
public int discogsId { get; set; }
|
||||||
|
public string overview { get; set; }
|
||||||
|
public string artistType { get; set; }
|
||||||
|
public string disambiguation { get; set; }
|
||||||
|
public Link[] links { get; set; }
|
||||||
|
public Nextalbum nextAlbum { get; set; }
|
||||||
|
public Image[] images { get; set; }
|
||||||
|
public string path { get; set; }
|
||||||
|
public int qualityProfileId { get; set; }
|
||||||
|
public int languageProfileId { get; set; }
|
||||||
|
public int metadataProfileId { get; set; }
|
||||||
|
public bool albumFolder { get; set; }
|
||||||
|
public bool monitored { get; set; }
|
||||||
|
public object[] genres { get; set; }
|
||||||
|
public string cleanName { get; set; }
|
||||||
|
public string sortName { get; set; }
|
||||||
|
public object[] tags { get; set; }
|
||||||
|
public DateTime added { get; set; }
|
||||||
|
public Ratings ratings { get; set; }
|
||||||
|
public Statistics statistics { get; set; }
|
||||||
|
public int id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Nextalbum
|
||||||
|
{
|
||||||
|
public string foreignAlbumId { get; set; }
|
||||||
|
public int artistId { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
public string disambiguation { get; set; }
|
||||||
|
public string cleanTitle { get; set; }
|
||||||
|
public DateTime releaseDate { get; set; }
|
||||||
|
public int profileId { get; set; }
|
||||||
|
public int duration { get; set; }
|
||||||
|
public bool monitored { get; set; }
|
||||||
|
public object[] images { get; set; }
|
||||||
|
public object[] genres { get; set; }
|
||||||
|
public Medium[] media { get; set; }
|
||||||
|
public DateTime lastInfoSync { get; set; }
|
||||||
|
public DateTime added { get; set; }
|
||||||
|
public string albumType { get; set; }
|
||||||
|
public object[] secondaryTypes { get; set; }
|
||||||
|
public Ratings ratings { get; set; }
|
||||||
|
public Release[] releases { get; set; }
|
||||||
|
public Currentrelease currentRelease { get; set; }
|
||||||
|
public int id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Currentrelease
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
public DateTime releaseDate { get; set; }
|
||||||
|
public int trackCount { get; set; }
|
||||||
|
public int mediaCount { get; set; }
|
||||||
|
public string disambiguation { get; set; }
|
||||||
|
public string[] country { get; set; }
|
||||||
|
public string format { get; set; }
|
||||||
|
public string[] label { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Medium
|
||||||
|
{
|
||||||
|
public int number { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string format { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Release
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
public DateTime releaseDate { get; set; }
|
||||||
|
public int trackCount { get; set; }
|
||||||
|
public int mediaCount { get; set; }
|
||||||
|
public string disambiguation { get; set; }
|
||||||
|
public string[] country { get; set; }
|
||||||
|
public string format { get; set; }
|
||||||
|
public string[] label { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,9 +73,10 @@ namespace Ombi.Core.Engine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="artistId"></param>
|
/// <param name="artistId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task GetArtistAlbums(int artistId)
|
public async Task GetArtistAlbums(string foreignArtistId)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var settings = await GetSettings();
|
||||||
|
return await _lidarrApi.GetArtistByForignId(foreignArtistId, settings.ApiKey, settings.FullUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -83,11 +84,17 @@ namespace Ombi.Core.Engine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="albumId"></param>
|
/// <param name="albumId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task GetAlbumArtist(int albumId)
|
public async Task GetAlbumArtist(string foreignArtistId)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ArtistResult> GetArtist(int artistId)
|
||||||
|
{
|
||||||
|
var settings = await GetSettings();
|
||||||
|
return await _lidarrApi.GetArtist(artistId, settings.ApiKey, settings.FullUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private LidarrSettings _settings;
|
private LidarrSettings _settings;
|
||||||
private async Task<LidarrSettings> GetSettings()
|
private async Task<LidarrSettings> GetSettings()
|
Loading…
Add table
Add a link
Reference in a new issue