Always render cover hash for top albums if available
This commit is contained in:
@@ -76,11 +76,5 @@ defmodule LastFm do
|
|||||||
"https://www.last.fm/api/auth/?api_key=" <> last_fm_config.api_key
|
"https://www.last.fm/api/auth/?api_key=" <> last_fm_config.api_key
|
||||||
end
|
end
|
||||||
|
|
||||||
@last_fm_fallback_cover_url "https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png"
|
|
||||||
|
|
||||||
def fallback_cover?(cover_url) do
|
|
||||||
cover_url == @last_fm_fallback_cover_url
|
|
||||||
end
|
|
||||||
|
|
||||||
defp last_fm_config, do: LastFm.Config.resolve(:music_library)
|
defp last_fm_config, do: LastFm.Config.resolve(:music_library)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -196,14 +196,6 @@ defmodule MusicLibraryWeb.StatsLive.TopAlbums do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp cover_url(album) do
|
defp cover_url(album) do
|
||||||
if LastFm.fallback_cover?(album.cover_url) do
|
~p"/assets/#{Transform.new(hash: album.cover_hash, width: 96)}"
|
||||||
payload =
|
|
||||||
Transform.new(hash: album.cover_hash, width: 96)
|
|
||||||
|> Transform.encode!()
|
|
||||||
|
|
||||||
~p"/assets/#{payload}"
|
|
||||||
else
|
|
||||||
album.cover_url
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user