Display badge when an artist is touring

This commit is contained in:
Claudio Ortolina
2025-01-25 08:50:46 +00:00
parent 916a934da6
commit 0d77fdc031
4 changed files with 18 additions and 9 deletions
+5 -3
View File
@@ -1,13 +1,14 @@
defmodule LastFm.Artist do defmodule LastFm.Artist do
@enforce_keys [:musicbrainz_id, :name] @enforce_keys [:musicbrainz_id, :name]
defstruct [:musicbrainz_id, :name, :bio, :image, :play_count] defstruct [:musicbrainz_id, :name, :bio, :image, :play_count, :on_tour]
@type t :: %__MODULE__{ @type t :: %__MODULE__{
musicbrainz_id: String.t(), musicbrainz_id: String.t(),
name: String.t(), name: String.t(),
bio: String.t(), bio: String.t(),
image: String.t(), image: String.t(),
play_count: non_neg_integer() play_count: non_neg_integer(),
on_tour: boolean()
} }
def from_api_response(api_response) do def from_api_response(api_response) do
@@ -16,7 +17,8 @@ defmodule LastFm.Artist do
name: api_response["name"], name: api_response["name"],
bio: api_response["bio"]["content"] || "", bio: api_response["bio"]["content"] || "",
image: get_image(api_response), image: get_image(api_response),
play_count: get_play_count(api_response) play_count: get_play_count(api_response),
on_tour: api_response["ontour"] == "1"
} }
end end
@@ -28,6 +28,7 @@
<span class="sr-only"> <span class="sr-only">
{gettext("Number of scrobbles")} {gettext("Number of scrobbles")}
</span> </span>
<.round_badge :if={artist_info.on_tour} text={gettext("On Tour")} />
<.round_badge text={artist_info.play_count} /> <.round_badge text={artist_info.play_count} />
</span> </span>
</.async_result> </.async_result>
+10 -5
View File
@@ -30,7 +30,7 @@ msgid "Choose a value"
msgstr "" msgstr ""
#: lib/music_library_web/components/layouts/app.html.heex:14 #: lib/music_library_web/components/layouts/app.html.heex:14
#: lib/music_library_web/live/artist_live/show.html.heex:64 #: lib/music_library_web/live/artist_live/show.html.heex:65
#: lib/music_library_web/live/collection_live/index.ex:143 #: lib/music_library_web/live/collection_live/index.ex:143
#: lib/music_library_web/live/collection_live/show.ex:115 #: lib/music_library_web/live/collection_live/show.ex:115
#: lib/music_library_web/live/collection_live/show.ex:132 #: lib/music_library_web/live/collection_live/show.ex:132
@@ -306,7 +306,7 @@ msgid "Welcome to your Music Library"
msgstr "" msgstr ""
#: lib/music_library_web/components/layouts/app.html.heex:20 #: lib/music_library_web/components/layouts/app.html.heex:20
#: lib/music_library_web/live/artist_live/show.html.heex:73 #: lib/music_library_web/live/artist_live/show.html.heex:74
#: lib/music_library_web/live/wishlist_live/index.ex:154 #: lib/music_library_web/live/wishlist_live/index.ex:154
#: lib/music_library_web/live/wishlist_live/show.ex:130 #: lib/music_library_web/live/wishlist_live/show.ex:130
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
@@ -443,12 +443,12 @@ msgstr ""
msgid "Number of scrobbles" msgid "Number of scrobbles"
msgstr "" msgstr ""
#: lib/music_library_web/live/artist_live/show.html.heex:57 #: lib/music_library_web/live/artist_live/show.html.heex:58
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Biography" msgid "Biography"
msgstr "" msgstr ""
#: lib/music_library_web/live/artist_live/show.html.heex:39 #: lib/music_library_web/live/artist_live/show.html.heex:40
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Loading biography" msgid "Loading biography"
msgstr "" msgstr ""
@@ -493,7 +493,7 @@ msgstr ""
msgid "Records" msgid "Records"
msgstr "" msgstr ""
#: lib/music_library_web/live/artist_live/show.html.heex:50 #: lib/music_library_web/live/artist_live/show.html.heex:51
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Error loading biography" msgid "Error loading biography"
msgstr "" msgstr ""
@@ -517,3 +517,8 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Number of records" msgid "Number of records"
msgstr "" msgstr ""
#: lib/music_library_web/live/artist_live/show.html.heex:31
#, elixir-autogen, elixir-format
msgid "On Tour"
msgstr ""
+2 -1
View File
@@ -18,7 +18,8 @@ defmodule LastFm.ArtistTest do
"Steven Wilson (born Steven John Wilson on November 3, 1967, in Hemel Hempstead, Hertfordshire, England) is an English musician, singer, songwriter and record producer, most closely associated with the progressive rock genre. Currently a solo artist, he became known as the founder, lead guitarist, lead vocalist and songwriter of the British rock band Porcupine Tree, as well as being a member of several other bands.\n\nWilson is self-taught as a producer, audio engineer, multi-instrumentalist and singer-songwriter. Under his own name, he has released the albums Insurgentes (2008), Grace for Drowning (2011), The Raven That Refused to Sing (and Other Stories) (2013), Hand. Cannot. Erase. (2015), To the Bone (2017), and The Future Bites (2021). He also released a EP, 4 ½ (2016), as well as a series of singles titled Cover Version (released online between 2003 and 2010; released worldwide as a compilation in 2014). His other solo projects can also be found attributed to monikers of his, such as Bass Communion and Incredible Expanding Mindfuck.\n\nHe is perhaps best known as the frontman for progressive rock band, Porcupine Tree, for whom he was the sole member during the 1980s and early 1990s. His projects are numerous however, including collaboration with Aviv Geffen as Blackfield; a long-running partnership with Tim Bowness, known as No-Man; teaming up with Dirk Serries in Continuum; as well as a joint album with Opeth's frontman, Mikael Åkerfeldt in Storm Corrosion.\n\n\nWilson employs synthesizers and programmed music along with live instruments to create a unique atmosphere for each song he works on, including otherwise-simple pop tunes. In addition to his prolific musical output, Steven has crafted a reputation for the high production quality of his music, and has undertaken production duties with such high-profile artists as Opeth, Dream Theater, Jim Matheos of Fates Warning, Anathema, Orphaned Land, Marillion, Fish, Pendulum, Yoko Ono, and friend Robert Fripp. He is also part way through remixing the albums of King Crimson and other classic artists' back catalogues into surround sound and new stereo mixes. <a href=\"https://www.last.fm/music/Steven+Wilson\">Read more on Last.fm</a>. User-contributed text is available under the Creative Commons By-SA License; additional terms may apply.", "Steven Wilson (born Steven John Wilson on November 3, 1967, in Hemel Hempstead, Hertfordshire, England) is an English musician, singer, songwriter and record producer, most closely associated with the progressive rock genre. Currently a solo artist, he became known as the founder, lead guitarist, lead vocalist and songwriter of the British rock band Porcupine Tree, as well as being a member of several other bands.\n\nWilson is self-taught as a producer, audio engineer, multi-instrumentalist and singer-songwriter. Under his own name, he has released the albums Insurgentes (2008), Grace for Drowning (2011), The Raven That Refused to Sing (and Other Stories) (2013), Hand. Cannot. Erase. (2015), To the Bone (2017), and The Future Bites (2021). He also released a EP, 4 ½ (2016), as well as a series of singles titled Cover Version (released online between 2003 and 2010; released worldwide as a compilation in 2014). His other solo projects can also be found attributed to monikers of his, such as Bass Communion and Incredible Expanding Mindfuck.\n\nHe is perhaps best known as the frontman for progressive rock band, Porcupine Tree, for whom he was the sole member during the 1980s and early 1990s. His projects are numerous however, including collaboration with Aviv Geffen as Blackfield; a long-running partnership with Tim Bowness, known as No-Man; teaming up with Dirk Serries in Continuum; as well as a joint album with Opeth's frontman, Mikael Åkerfeldt in Storm Corrosion.\n\n\nWilson employs synthesizers and programmed music along with live instruments to create a unique atmosphere for each song he works on, including otherwise-simple pop tunes. In addition to his prolific musical output, Steven has crafted a reputation for the high production quality of his music, and has undertaken production duties with such high-profile artists as Opeth, Dream Theater, Jim Matheos of Fates Warning, Anathema, Orphaned Land, Marillion, Fish, Pendulum, Yoko Ono, and friend Robert Fripp. He is also part way through remixing the albums of King Crimson and other classic artists' back catalogues into surround sound and new stereo mixes. <a href=\"https://www.last.fm/music/Steven+Wilson\">Read more on Last.fm</a>. User-contributed text is available under the Creative Commons By-SA License; additional terms may apply.",
image: image:
"https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png", "https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png",
play_count: 123 play_count: 123,
on_tour: false
} == } ==
LastFm.Artist.from_api_response(api_response) LastFm.Artist.from_api_response(api_response)
end end