Browse Source

fix: safer metadata

master
Inhji Y. 9 months ago
parent
commit
20e6cc42fe
  1. 11
      apps/listens/lib/listens/workers/listenbrainz/handler.ex

11
apps/listens/lib/listens/workers/listenbrainz/handler.ex

@ -75,7 +75,7 @@ defmodule Listens.Workers.Listenbrainz.Handler do
artist_name: artist_name,
release_name: release_name,
track_name: track_name
} = listen.track_metadata
} = get_track_metadata(listen)
with {:ok, artist, new: new_artist} <- maybe_create_artist(artist_name, info.artist_msid),
{:ok, album, new: new_album} <-
@ -106,6 +106,15 @@ defmodule Listens.Workers.Listenbrainz.Handler do
end
end
def get_track_metadata(listen) do
%{
additional_info: Map.get(listen.track_metadata, :additional_info, nil),
artist_name: Map.get(listen.artist_name, :artist_name, nil),
release_name: Map.get(listen.release_name, :release_name, nil),
track_name: Map.get(listen.track_name, :track_name, nil)
}
end
def bool_to_int(true), do: 1
def bool_to_int(false), do: 0

Loading…
Cancel
Save