diff --git a/lib/last_fm/artist.ex b/lib/last_fm/artist.ex index 7edd2a63..2f815209 100644 --- a/lib/last_fm/artist.ex +++ b/lib/last_fm/artist.ex @@ -13,7 +13,7 @@ defmodule LastFm.Artist do %__MODULE__{ musicbrainz_id: api_response["mbid"], name: api_response["name"], - bio: api_response["bio"]["content"], + bio: api_response["bio"]["content"] || "", image: get_image(api_response), play_count: get_play_count(api_response) } diff --git a/lib/music_library_web/live/artist_live/show.ex b/lib/music_library_web/live/artist_live/show.ex index 62390f97..8977c249 100644 --- a/lib/music_library_web/live/artist_live/show.ex +++ b/lib/music_library_web/live/artist_live/show.ex @@ -50,7 +50,14 @@ defmodule MusicLibraryWeb.ArtistLive.Show do } end - defp render_bio(nil), do: gettext("Biography not available") + defp bio_available?(artist_info_result) do + artist_info_result.ok? && artist_info_result.result && artist_info_result.result.bio !== "" + end + + defp played?(artist_info_result) do + artist_info_result.ok? && artist_info_result.result && + artist_info_result.result.play_count > 0 + end # Bios start with text, then a link to read more on Last.fm, followed by a license text. # We split the bio at the read more link in order to render the license separately. diff --git a/lib/music_library_web/live/artist_live/show.html.heex b/lib/music_library_web/live/artist_live/show.html.heex index a2029dc7..1d8d68ed 100644 --- a/lib/music_library_web/live/artist_live/show.html.heex +++ b/lib/music_library_web/live/artist_live/show.html.heex @@ -1,7 +1,7 @@