Skip to content

Commit

Permalink
New: Option to disable cover art embed in files
Browse files Browse the repository at this point in the history
Fixes #2488
  • Loading branch information
Qstick committed Feb 4, 2024
1 parent aecf5bb commit 885d990
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ function MetadataProvider(props) {
/>
</FormGroup>

{
settings.writeAudioTags.value !== 'no' &&
<FormGroup>
<FormLabel>
{translate('EmbedCoverArtInAudioFiles')}
</FormLabel>

<FormInputGroup
type={inputTypes.CHECK}
name="embedCoverArt"
helpText={translate('EmbedCoverArtHelpText')}
onChange={onInputChange}
{...settings.embedCoverArt}
/>
</FormGroup>
}

<FormGroup>
<FormLabel>
{translate('ScrubExistingTags')}
Expand Down
2 changes: 2 additions & 0 deletions src/Lidarr.Api.V1/Config/MetadataProviderConfigResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class MetadataProviderConfigResource : RestResource
public string MetadataSource { get; set; }
public WriteAudioTagsType WriteAudioTags { get; set; }
public bool ScrubAudioTags { get; set; }
public bool EmbedCoverArt { get; set; }
}

public static class MetadataProviderConfigResourceMapper
Expand All @@ -19,6 +20,7 @@ public static MetadataProviderConfigResource ToResource(IConfigService model)
MetadataSource = model.MetadataSource,
WriteAudioTags = model.WriteAudioTags,
ScrubAudioTags = model.ScrubAudioTags,
EmbedCoverArt = model.EmbedCoverArt,
};
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public void Setup()
.Setup(x => x.WriteAudioTags)
.Returns(WriteAudioTagsType.Sync);

Mocker.GetMock<IConfigService>()
.Setup(x => x.EmbedCoverArt)
.Returns(true);

var imageFile = Path.Combine(_testdir, "nin.png");
var imageSize = _diskProvider.GetFileSize(imageFile);

Expand Down
7 changes: 7 additions & 0 deletions src/NzbDrone.Core/Configuration/ConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ public bool ScrubAudioTags
set { SetValue("ScrubAudioTags", value); }
}

public bool EmbedCoverArt
{
get { return GetValueBoolean("EmbedCoverArt", true); }

set { SetValue("EmbedCoverArt", value); }
}

public int FirstDayOfWeek
{
get { return GetValueInt("FirstDayOfWeek", (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek); }
Expand Down
1 change: 1 addition & 0 deletions src/NzbDrone.Core/Configuration/IConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public interface IConfigService
string MetadataSource { get; set; }
WriteAudioTagsType WriteAudioTags { get; set; }
bool ScrubAudioTags { get; set; }
bool EmbedCoverArt { get; set; }

// Forms Auth
string RijndaelPassphrase { get; }
Expand Down
2 changes: 2 additions & 0 deletions src/NzbDrone.Core/Localization/Core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@
"EditSelectedDownloadClients": "Edit Selected Download Clients",
"EditSelectedImportLists": "Edit Selected Import Lists",
"EditSelectedIndexers": "Edit Selected Indexers",
"EmbedCoverArtInAudioFiles": "Embed Cover Art In Audio Files",
"EmbedCoverArtHelpText": "Embed Lidarr album art into audio files when writing tags",
"Enable": "Enable",
"EnableAutomaticAdd": "Enable Automatic Add",
"EnableAutomaticAddHelpText": "Add artist/albums to {appName} when syncs are performed via the UI or by {appName}",
Expand Down
26 changes: 15 additions & 11 deletions src/NzbDrone.Core/MediaFiles/AudioTagService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,25 @@ public AudioTag GetTrackMetadata(TrackFile trackfile)
var albumartist = album.Artist.Value;
var artist = track.ArtistMetadata.Value;

var cover = album.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Cover);
string imageFile = null;
long imageSize = 0;
if (cover != null)

if (_configService.EmbedCoverArt)
{
imageFile = _mediaCoverService.GetCoverPath(album.Id, MediaCoverEntity.Album, cover.CoverType, cover.Extension, null);
_logger.Trace($"Embedding: {imageFile}");
var fileInfo = _diskProvider.GetFileInfo(imageFile);
if (fileInfo.Exists)
{
imageSize = fileInfo.Length;
}
else
var cover = album.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Cover);
if (cover != null)
{
imageFile = 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)
{
imageSize = fileInfo.Length;
}
else
{
imageFile = null;
}
}
}

Expand Down

0 comments on commit 885d990

Please sign in to comment.