mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Fixed #2549
This commit is contained in:
parent
bb4d59e355
commit
3ab45eb6fd
1 changed files with 25 additions and 1 deletions
|
@ -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 };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue