Try a second time to download the artwork if the first time failed.

This commit is contained in:
Damiano Galassi committed 2017-05-29 16:11:43 +02:00
1 parent aa7d9cdfbe
commit 5ce7a835e4
1 file changed
+7 -3
+7 -3
View File
@@ -421,16 +421,20 @@
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
NSData *artworkData = [SBMetadataHelper downloadDataFromURL:remoteImages[idx].URL cachePolicy:SBDefaultPolicy];
SBRemoteImage *remoteImage = remoteImages[idx];
NSData *artworkData = [SBMetadataHelper downloadDataFromURL:remoteImage.URL cachePolicy:SBDefaultPolicy];
// Hack, download smaller iTunes version if big iTunes version is not available
if (!artworkData) {
NSString *provider = remoteImages[idx].providerName;
if ([provider isEqualToString:@"iTunes"]) {
if ([remoteImage.providerName isEqualToString:@"iTunes"]) {
NSURL *url = remoteImages[idx].URL;
url = [url.URLByDeletingPathExtension URLByAppendingPathExtension:@"600x600bb.jpg"];
artworkData = [SBMetadataHelper downloadDataFromURL:url cachePolicy:SBDefaultPolicy];
}
else {
// Try again
artworkData = [SBMetadataHelper downloadDataFromURL:remoteImage.URL cachePolicy:SBDefaultPolicy];
}
}
// Add artwork to metadata object