diff --git a/lib/last_fm/artist.ex b/lib/last_fm/artist.ex
index 1b768865..1ef6d389 100644
--- a/lib/last_fm/artist.ex
+++ b/lib/last_fm/artist.ex
@@ -1,6 +1,6 @@
defmodule LastFm.Artist do
@enforce_keys [:musicbrainz_id, :name]
- defstruct [:musicbrainz_id, :name, :summary, :bio, :image, :play_count, :on_tour]
+ defstruct [:musicbrainz_id, :name, :summary, :bio, :image, :play_count, :on_tour, :base_url]
@type t :: %__MODULE__{
musicbrainz_id: String.t(),
@@ -9,7 +9,8 @@ defmodule LastFm.Artist do
bio: String.t(),
image: String.t(),
play_count: non_neg_integer(),
- on_tour: boolean()
+ on_tour: boolean(),
+ base_url: String.t()
}
def from_api_response(api_response) do
@@ -20,10 +21,15 @@ defmodule LastFm.Artist do
bio: api_response["bio"]["content"] || "",
image: get_image(api_response),
play_count: get_play_count(api_response),
- on_tour: api_response["ontour"] == "1"
+ on_tour: api_response["ontour"] == "1",
+ base_url: api_response["url"]
}
end
+ def events_url(artist) do
+ artist.base_url <> "/+events"
+ end
+
defp get_image(api_response) do
api_response["image"]
|> Enum.find(%{"#text" => nil}, fn i -> i["size"] == "medium" end)
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 55df7f55..f5de427d 100644
--- a/lib/music_library_web/live/artist_live/show.html.heex
+++ b/lib/music_library_web/live/artist_live/show.html.heex
@@ -27,7 +27,9 @@
{gettext("Error loading play count")}
- <.round_badge :if={artist_info.on_tour} text={gettext("On Tour")} class="mr-2" />
+
+ <.round_badge text={gettext("On Tour")} class="mr-2" />
+
0}
class="text-xs font-medium text-zinc-700 dark:text-zinc-300 grow"
diff --git a/test/last_fm/artist_test.exs b/test/last_fm/artist_test.exs
index c75ca96f..447fcf1f 100644
--- a/test/last_fm/artist_test.exs
+++ b/test/last_fm/artist_test.exs
@@ -21,7 +21,8 @@ defmodule LastFm.ArtistTest do
image:
"https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png",
play_count: 123,
- on_tour: false
+ on_tour: false,
+ base_url: "https://www.last.fm/music/Steven+Wilson"
} ==
LastFm.Artist.from_api_response(api_response)
end