mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Got most of the requesting stuff done! !wip #2313
This commit is contained in:
parent
cda7c0fe4c
commit
b72905ab4a
26 changed files with 1061 additions and 61 deletions
|
@ -16,5 +16,10 @@ namespace Ombi.Api.Lidarr
|
|||
Task<AlbumLookup> GetAlbumByForeignId(string foreignArtistId, string apiKey, string baseUrl);
|
||||
Task<List<ArtistResult>> GetArtists(string apiKey, string baseUrl);
|
||||
Task<List<AlbumResponse>> GetAllAlbums(string apiKey, string baseUrl);
|
||||
Task<ArtistResult> AddArtist(ArtistAdd artist, string apiKey, string baseUrl);
|
||||
Task<AlbumResponse> MontiorAlbum(int albumId, string apiKey, string baseUrl);
|
||||
Task<List<AlbumResponse>> GetAllAlbumsByArtistId(int artistId, string apiKey, string baseUrl);
|
||||
Task<List<MetadataProfile>> GetMetadataProfile(string apiKey, string baseUrl);
|
||||
Task<List<LanguageProfiles>> GetLanguageProfile(string apiKey, string baseUrl);
|
||||
}
|
||||
}
|
|
@ -63,13 +63,13 @@ namespace Ombi.Api.Lidarr
|
|||
return Api.Request<ArtistResult>(request);
|
||||
}
|
||||
|
||||
public Task<ArtistResult> GetArtistByForeignId(string foreignArtistId, string apiKey, string baseUrl)
|
||||
public async Task<ArtistResult> GetArtistByForeignId(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);
|
||||
return (await Api.Request<List<ArtistResult>>(request)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public async Task<AlbumLookup> GetAlbumByForeignId(string foreignArtistId, string apiKey, string baseUrl)
|
||||
|
@ -105,6 +105,48 @@ namespace Ombi.Api.Lidarr
|
|||
return Api.Request<List<AlbumResponse>>(request);
|
||||
}
|
||||
|
||||
public Task<ArtistResult> AddArtist(ArtistAdd artist, string apiKey, string baseUrl)
|
||||
{
|
||||
var request = new Request($"{ApiVersion}/artist", baseUrl, HttpMethod.Post);
|
||||
request.AddJsonBody(artist);
|
||||
AddHeaders(request, apiKey);
|
||||
return Api.Request<ArtistResult>(request);
|
||||
}
|
||||
|
||||
public Task<AlbumResponse> MontiorAlbum(int albumId, string apiKey, string baseUrl)
|
||||
{
|
||||
var request = new Request($"{ApiVersion}/album/monitor", baseUrl, HttpMethod.Put);
|
||||
request.AddJsonBody(new
|
||||
{
|
||||
albumIds = new[] { albumId },
|
||||
monitored = true
|
||||
});
|
||||
AddHeaders(request, apiKey);
|
||||
return Api.Request<AlbumResponse>(request);
|
||||
}
|
||||
|
||||
public Task<List<AlbumResponse>> GetAllAlbumsByArtistId(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<List<AlbumResponse>>(request);
|
||||
}
|
||||
|
||||
public Task<List<LanguageProfiles>> GetLanguageProfile(string apiKey, string baseUrl)
|
||||
{
|
||||
var request = new Request($"{ApiVersion}/languageprofile", baseUrl, HttpMethod.Get);
|
||||
AddHeaders(request, apiKey);
|
||||
return Api.Request<List<LanguageProfiles>>(request);
|
||||
}
|
||||
|
||||
public Task<List<MetadataProfile>> GetMetadataProfile(string apiKey, string baseUrl)
|
||||
{
|
||||
var request = new Request($"{ApiVersion}/metadataprofile", baseUrl, HttpMethod.Get);
|
||||
AddHeaders(request, apiKey);
|
||||
return Api.Request<List<MetadataProfile>>(request);
|
||||
}
|
||||
|
||||
private void AddHeaders(Request request, string key)
|
||||
{
|
||||
request.AddHeader("X-Api-Key", key);
|
||||
|
|
48
src/Ombi.Api.Lidarr/Models/ArtistAdd.cs
Normal file
48
src/Ombi.Api.Lidarr/Models/ArtistAdd.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Net.Mime;
|
||||
|
||||
namespace Ombi.Api.Lidarr.Models
|
||||
{
|
||||
public class ArtistAdd
|
||||
{
|
||||
public string status { get; set; }
|
||||
public bool ended { 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 disambiguation { get; set; }
|
||||
public Link[] links { get; set; }
|
||||
public Image[] images { get; set; }
|
||||
public string remotePoster { 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 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 Addoptions addOptions { get; set; }
|
||||
public string rootFolderPath { get; set; }
|
||||
}
|
||||
|
||||
public class Addoptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Future = 1
|
||||
/// Missing = 2
|
||||
/// Existing = 3
|
||||
/// First = 5
|
||||
/// Latest = 4
|
||||
/// None = 6
|
||||
/// </summary>
|
||||
public int selectedOption { get; set; }
|
||||
public bool monitored { get; set; }
|
||||
public bool searchForMissingAlbums { get; set; }
|
||||
}
|
||||
}
|
8
src/Ombi.Api.Lidarr/Models/LanguageProfiles.cs
Normal file
8
src/Ombi.Api.Lidarr/Models/LanguageProfiles.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace Ombi.Api.Lidarr.Models
|
||||
{
|
||||
public class LanguageProfiles
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int id { get; set; }
|
||||
}
|
||||
}
|
8
src/Ombi.Api.Lidarr/Models/MetadataProfile.cs
Normal file
8
src/Ombi.Api.Lidarr/Models/MetadataProfile.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace Ombi.Api.Lidarr.Models
|
||||
{
|
||||
public class MetadataProfile
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int id { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue