@@ -260,16 +260,12 @@ defmodule MusicLibrary.Artists do
|
||||
artist_info = get_artist_info!(artist_id)
|
||||
name = get_in(artist_info.musicbrainz_data, ["name"]) || ""
|
||||
|
||||
case LastFm.get_artist_tags(artist_id, name) do
|
||||
{:ok, tags} ->
|
||||
tag_names = Enum.map(tags, fn {tag_name, _count} -> tag_name end)
|
||||
with {:ok, tags} <- LastFm.get_artist_tags(artist_id, name) do
|
||||
tag_names = Enum.map(tags, fn {tag_name, _count} -> tag_name end)
|
||||
|
||||
artist_info
|
||||
|> ArtistInfo.changeset(%{lastfm_data: %{"tags" => tag_names}})
|
||||
|> Repo.update()
|
||||
|
||||
{:error, _reason} ->
|
||||
{:ok, artist_info}
|
||||
artist_info
|
||||
|> ArtistInfo.changeset(%{lastfm_data: %{"tags" => tag_names}})
|
||||
|> Repo.update()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@ defmodule MusicLibrary.Worker.FetchArtistInfo do
|
||||
def perform(%Oban.Job{args: %{"id" => artist_id}}) do
|
||||
with {:ok, _artist_info} <- MusicLibrary.Artists.refresh_artist_info(artist_id),
|
||||
{:ok, _artist_info} <- MusicLibrary.Artists.refresh_wikipedia_data(artist_id),
|
||||
{:ok, _artist_info} <- MusicLibrary.Artists.refresh_image(artist_id) do
|
||||
# refresh_lastfm_data returns {:ok, _} even on API errors, so it won't block embeddings
|
||||
MusicLibrary.Artists.refresh_lastfm_data(artist_id)
|
||||
{:ok, _artist_info} <- MusicLibrary.Artists.refresh_image(artist_id),
|
||||
{:ok, _artist_info} <- MusicLibrary.Artists.refresh_lastfm_data(artist_id) do
|
||||
MusicLibrary.Records.regenerate_artist_embeddings(artist_id)
|
||||
else
|
||||
{:error, :no_english_wikipedia} -> {:cancel, :no_english_wikipedia}
|
||||
|
||||
Reference in New Issue
Block a user