mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-25 23:32:41 +00:00
Fixed: Embedding album art on import
On import the album release is adjusted, which triggers an AlbumEditedEvent which in turn coverts media cover urls to local urls. The addition of ?lastWrite=xxx broke the calculation of extenions from the URL. To fix, only set the extension and don't update the extension if url is changed.
This commit is contained in:
parent
c898a18d31
commit
1ab8c5a7bb
3 changed files with 44 additions and 2 deletions
|
@ -66,6 +66,30 @@ public void should_convert_cover_urls_to_local(string extension)
|
|||
covers.Single().Url.Should().Be("/MediaCover/12/banner" + extension + "?lastWrite=1234");
|
||||
}
|
||||
|
||||
[TestCase(".png")]
|
||||
[TestCase(".jpg")]
|
||||
public void convert_to_local_url_should_not_change_extension(string extension)
|
||||
{
|
||||
var covers = new List<MediaCover.MediaCover>
|
||||
{
|
||||
new MediaCover.MediaCover
|
||||
{
|
||||
Url = "http://dummy.com/test" + extension,
|
||||
CoverType = MediaCoverTypes.Banner
|
||||
}
|
||||
};
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileGetLastWrite(It.IsAny<string>()))
|
||||
.Returns(new DateTime(1234));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
Subject.ConvertToLocalUrls(12, MediaCoverEntity.Artist, covers);
|
||||
|
||||
covers.Single().Extension.Should().Be(extension);
|
||||
}
|
||||
|
||||
[TestCase(".png")]
|
||||
[TestCase(".jpg")]
|
||||
public void should_convert_album_cover_urls_to_local(string extension)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Core.MediaCover
|
||||
|
@ -25,9 +26,25 @@ public enum MediaCoverEntity
|
|||
|
||||
public class MediaCover : IEmbeddedDocument
|
||||
{
|
||||
private string _url;
|
||||
public string Url
|
||||
{
|
||||
get
|
||||
{
|
||||
return _url;
|
||||
}
|
||||
set
|
||||
{
|
||||
_url = value;
|
||||
if (Extension.IsNullOrWhiteSpace())
|
||||
{
|
||||
Extension = Path.GetExtension(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MediaCoverTypes CoverType { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string Extension => Path.GetExtension(Url);
|
||||
public string Extension { get; private set; }
|
||||
|
||||
public MediaCover()
|
||||
{
|
||||
|
|
|
@ -86,6 +86,7 @@ public AudioTag GetTrackMetadata(TrackFile trackfile)
|
|||
if (cover != null)
|
||||
{
|
||||
imageFile = _mediaCoverService.GetCoverPath(album.Id, MediaCoverEntity.Album, cover.CoverType, cover.Extension, null);
|
||||
_logger.Trace($"Embedding: {imageFile}");
|
||||
var fileInfo = _diskProvider.GetFileInfo(imageFile);
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue