mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-25 09:12:17 +00:00
Fixed: Album Metadata Images don't always save in correct folder
This commit is contained in:
parent
8219a8014b
commit
2afa6c02de
2 changed files with 31 additions and 6 deletions
|
@ -331,7 +331,7 @@ public override List<ImageFileResult> AlbumImages(Artist artist, Album album)
|
|||
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 @@ private IEnumerable<ImageFileResult> ProcessArtistImages(Artist artist)
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ private List<MetadataFile> ProcessAlbumImages(IMetadata consumer, Artist artist,
|
|||
Extension = Path.GetExtension(fullPath)
|
||||
};
|
||||
|
||||
DownloadImage(artist, image);
|
||||
DownloadImage(album, image);
|
||||
|
||||
result.Add(metadata);
|
||||
}
|
||||
|
@ -476,6 +476,32 @@ private void DownloadImage(Artist artist, ImageFileResult image)
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue