Use LastFm.Config where needed

This commit is contained in:
Claudio Ortolina
2024-12-03 09:18:55 +00:00
parent b49434b789
commit 2094c1cf7b
6 changed files with 36 additions and 34 deletions
+1 -6
View File
@@ -15,7 +15,7 @@ defmodule MusicLibrary.Application do
{DNSCluster, query: Application.get_env(:music_library, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: MusicLibrary.PubSub},
MusicBrainz.Supervisor,
{LastFm.Supervisor, last_fm_config()},
{LastFm.Supervisor, LastFm.Config.resolve(:music_library)},
# Start a worker by calling: MusicLibrary.Worker.start_link(arg)
# {MusicLibrary.Worker, arg},
# Start to serve requests, typically the last entry
@@ -40,9 +40,4 @@ defmodule MusicLibrary.Application do
# By default, sqlite migrations are run when using a release
System.get_env("RELEASE_NAME") != nil
end
defp last_fm_config do
Application.get_env(:music_library, LastFm)
|> LastFm.Config.new()
end
end
+2 -5
View File
@@ -111,7 +111,7 @@ defmodule MusicLibrary.Records do
end
def get_artist_info(musicbrainz_id) do
last_fm().get_artist_info(musicbrainz_id, last_fm_api_key())
last_fm().get_artist_info(musicbrainz_id, last_fm_config())
end
def get_cover(id) do
@@ -224,8 +224,5 @@ defmodule MusicLibrary.Records do
Application.get_env(:music_library, :last_fm, LastFm.APIImpl)
end
defp last_fm_api_key do
Application.get_env(:music_library, LastFm)
|> Keyword.fetch!(:api_key)
end
defp last_fm_config, do: LastFm.Config.resolve(:music_library)
end