Don't apply fallback cover when refreshing it

So that we don't accidentally override a user-uploaded cover with the
fallback one.
This commit is contained in:
Claudio Ortolina
2024-11-21 17:57:49 +00:00
parent d09212dabb
commit 4581666282
6 changed files with 27 additions and 10 deletions
+8 -1
View File
@@ -111,7 +111,7 @@ defmodule MusicLibrary.Records do
with format = Keyword.get(opts, :format, "cd"),
purchased_at = Keyword.get(opts, :purchased_at),
{:ok, release_group} <- musicbrainz().get_release_group(musicbrainz_id),
{:ok, cover_data} <- musicbrainz().get_cover_art({:musicbrainz_id, musicbrainz_id}),
{:ok, cover_data} <- get_cover_art_or_default(musicbrainz_id),
record_attrs =
build_record_attrs(release_group, %{
"cover_data" => cover_data,
@@ -124,6 +124,13 @@ defmodule MusicLibrary.Records do
end
end
defp get_cover_art_or_default(musicbrainz_id) do
case musicbrainz().get_cover_art({:musicbrainz_id, musicbrainz_id}) do
{:error, :cover_not_available} -> {:ok, Record.fallback_cover_data()}
success -> success
end
end
def refresh_cover(record) do
with {:ok, cover_data} <- musicbrainz().get_cover_art({:url, record.cover_url}) do
{:ok, thumb} = Vix.Vips.Operation.thumbnail_buffer(cover_data, 600)