Don't fail import when cover fetch fails
This commit is contained in:
@@ -232,8 +232,12 @@ defmodule MusicLibrary.Records.MusicBrainz.APIImpl do
|
|||||||
{:ok, thumb} = Vix.Vips.Operation.thumbnail_buffer(cover_data, 400) do
|
{:ok, thumb} = Vix.Vips.Operation.thumbnail_buffer(cover_data, 400) do
|
||||||
Vix.Vips.Image.write_to_buffer(thumb, ".jpg")
|
Vix.Vips.Image.write_to_buffer(thumb, ".jpg")
|
||||||
else
|
else
|
||||||
{:error, :not_found} -> {:ok, @fallback_cover}
|
{:error, reason} ->
|
||||||
error -> error
|
Logger.error(
|
||||||
|
"Failed to fetch cover art for #{musicbrainz_id}, reason: #{inspect(reason)}"
|
||||||
|
)
|
||||||
|
|
||||||
|
{:ok, @fallback_cover}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -273,13 +277,12 @@ defmodule MusicLibrary.Records.MusicBrainz.APIImpl do
|
|||||||
Logger.debug("Following redirect to #{location}")
|
Logger.debug("Following redirect to #{location}")
|
||||||
blob_get(location)
|
blob_get(location)
|
||||||
|
|
||||||
{:ok, response} when response.status == 404 ->
|
# all non-success responses can be treated as errors
|
||||||
{:error, :not_found}
|
{:ok, response} ->
|
||||||
|
{:error, response}
|
||||||
|
|
||||||
other ->
|
error ->
|
||||||
msg = "Failed to fetch data from #{url}, reason: #{inspect(other)}"
|
error
|
||||||
Logger.error(msg)
|
|
||||||
{:error, msg}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user