|
|
@ -79,7 +79,31 @@ namespace Ombi.Core.Senders
|
|
|
|
// Search for it
|
|
|
|
// Search for it
|
|
|
|
if (!settings.AddOnly)
|
|
|
|
if (!settings.AddOnly)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _lidarrApi.AlbumSearch(new[] { result.id }, settings.ApiKey, settings.FullUri);
|
|
|
|
// get the album
|
|
|
|
|
|
|
|
var album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var albumToSearch = album.FirstOrDefault(x =>
|
|
|
|
|
|
|
|
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
|
|
|
|
|
|
|
|
var maxRetryCount = 10; // 5 seconds
|
|
|
|
|
|
|
|
var currentRetry = 0;
|
|
|
|
|
|
|
|
while (albumToSearch != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (currentRetry >= maxRetryCount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
currentRetry++;
|
|
|
|
|
|
|
|
await Task.Delay(500);
|
|
|
|
|
|
|
|
album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri);
|
|
|
|
|
|
|
|
albumToSearch = album.FirstOrDefault(x =>
|
|
|
|
|
|
|
|
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (albumToSearch != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await _lidarrApi.AlbumSearch(new[] {albumToSearch.id}, settings.ApiKey, settings.FullUri);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new SenderResult { Message = "Album has been requested!", Sent = true, Success = true };
|
|
|
|
return new SenderResult { Message = "Album has been requested!", Sent = true, Success = true };
|
|
|
|
}
|
|
|
|
}
|
|
|
|