It works now when we request an album when we do not have the artist in Lidarr. Waiting on https://github.com/lidarr/Lidarr/issues/459 to do when we have the artist

pull/2478/head
Jamie 6 years ago
parent 0b7a7a6bbb
commit e02c8e4014

@ -113,7 +113,7 @@ namespace Ombi.Api.Lidarr
return Api.Request<ArtistResult>(request);
}
public Task<AlbumResponse> MontiorAlbum(int albumId, string apiKey, string baseUrl)
public async Task<AlbumResponse> MontiorAlbum(int albumId, string apiKey, string baseUrl)
{
var request = new Request($"{ApiVersion}/album/monitor", baseUrl, HttpMethod.Put);
request.AddJsonBody(new
@ -122,7 +122,7 @@ namespace Ombi.Api.Lidarr
monitored = true
});
AddHeaders(request, apiKey);
return Api.Request<AlbumResponse>(request);
return (await Api.Request<List<AlbumResponse>>(request)).FirstOrDefault();
}
public Task<List<AlbumResponse>> GetAllAlbumsByArtistId(int artistId, string apiKey, string baseUrl)

@ -44,5 +44,6 @@ namespace Ombi.Api.Lidarr.Models
public int selectedOption { get; set; }
public bool monitored { get; set; }
public bool searchForMissingAlbums { get; set; }
public string[] AlbumsToMonitor { get; set; } // Uses the MusicBrainzAlbumId!
}
}

@ -57,7 +57,8 @@ namespace Ombi.Core.Senders
{
monitored = true,
searchForMissingAlbums = false,
selectedOption = 6 // None
selectedOption = 6, // None
AlbumsToMonitor = new[] {model.ForeignAlbumId}
},
added = DateTime.Now,
monitored = true,
@ -76,7 +77,7 @@ namespace Ombi.Core.Senders
if (result != null && result.id > 0)
{
// Setup the albums
await SetupAlbum(model, result, settings);
return new SenderResult { Message = "Album has been requested!", Sent = true, Success = true };
}
}
else
@ -91,9 +92,24 @@ namespace Ombi.Core.Senders
{
// Get the album id
var albums = await _lidarrApi.GetAllAlbumsByArtistId(artist.id, settings.ApiKey, settings.FullUri);
// Get the album we want.
var album = albums.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
var maxRetryCount = 10; // 5 seconds
var currentRetry = 0;
while (!albums.Any() || album == null)
{
if (currentRetry >= maxRetryCount)
{
break;
}
currentRetry++;
await Task.Delay(500);
albums = await _lidarrApi.GetAllAlbumsByArtistId(artist.id, settings.ApiKey, settings.FullUri);
album = albums.FirstOrDefault(x =>
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
}
// Get the album we want.
if (album == null)
{
return new SenderResult { Message = "Could not find album in Lidarr", Sent = false, Success = false };

@ -88,9 +88,10 @@ export class MusicRequestsComponent implements OnInit {
}
public removeRequest(request: IAlbumRequest) {
this.requestService.removeAlbumRequest(request);
this.removeRequestFromUi(request);
this.loadRequests(this.amountToLoad, this.currentlyLoaded = 0);
this.requestService.removeAlbumRequest(request).subscribe(x => {
this.removeRequestFromUi(request);
this.loadRequests(this.amountToLoad, this.currentlyLoaded = 0);
});
}
public changeAvailability(request: IAlbumRequest, available: boolean) {

@ -167,7 +167,7 @@ export class RequestService extends ServiceHelpers {
return this.http.get<IAlbumRequest[]>(`${this.url}music/search/${search}`, {headers: this.headers});
}
public removeAlbumRequest(request: IAlbumRequest) {
public removeAlbumRequest(request: IAlbumRequest): any {
this.http.delete(`${this.url}music/${request.id}`, {headers: this.headers}).subscribe();
}

Loading…
Cancel
Save