mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-07 17:25:00 +00:00
Fixed: Album Metadata Images don't always save in correct folder
This commit is contained in:
@@ -331,7 +331,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
|
||||
return new List<ImageFileResult>();
|
||||
}
|
||||
|
||||
return ProcessAlbumImages(artist, album).ToList();
|
||||
return ProcessAlbumImages(album).ToList();
|
||||
}
|
||||
|
||||
public override List<ImageFileResult> TrackImages(Artist artist, TrackFile trackFile)
|
||||
@@ -351,14 +351,13 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<ImageFileResult> ProcessAlbumImages(Artist artist, Album album)
|
||||
private IEnumerable<ImageFileResult> ProcessAlbumImages(Album album)
|
||||
{
|
||||
foreach (var image in album.Images)
|
||||
{
|
||||
var destination = Path.GetFileName(album.Path);
|
||||
var filename = string.Format("{0}\\{1}{2}", destination, image.CoverType.ToString().ToLower(), Path.GetExtension(image.Url));
|
||||
var destination = image.CoverType.ToString().ToLowerInvariant() + Path.GetExtension(image.Url);
|
||||
|
||||
yield return new ImageFileResult(filename, image.Url);
|
||||
yield return new ImageFileResult(destination, image.Url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
Extension = Path.GetExtension(fullPath)
|
||||
};
|
||||
|
||||
DownloadImage(artist, image);
|
||||
DownloadImage(album, image);
|
||||
|
||||
result.Add(metadata);
|
||||
}
|
||||
@@ -476,6 +476,32 @@ namespace NzbDrone.Core.Extras.Metadata
|
||||
}
|
||||
}
|
||||
|
||||
private void DownloadImage(Album album, ImageFileResult image)
|
||||
{
|
||||
var fullPath = Path.Combine(album.Path, image.RelativePath);
|
||||
|
||||
try
|
||||
{
|
||||
if (image.Url.StartsWith("http"))
|
||||
{
|
||||
_httpClient.DownloadFile(image.Url, fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_diskProvider.CopyFile(image.Url, fullPath);
|
||||
}
|
||||
_mediaFileAttributeService.SetFilePermissions(fullPath);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
_logger.Warn(ex, "Couldn't download image {0} for {1}. {2}", image.Url, album, ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Couldn't download image {0} for {1}. {2}", image.Url, album, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveMetadataFile(string path, string contents)
|
||||
{
|
||||
_diskProvider.WriteAllText(path, contents);
|
||||
|
||||
Reference in New Issue
Block a user