Changeset View
Changeset View
Standalone View
Standalone View
lib/lsg_irc/last_fm_plugin.ex
Context not available. | |||||
end | end | ||||
defp now_playing(user) do | defp now_playing(user) do | ||||
api = Application.get_env(:lsg, :lastfm)[:api_key] | api = Application.get_env(:nola, :lastfm)[:api_key] | ||||
url = "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&format=json&limit=1&extended=1" <> "&api_key=" <> api <> "&user="<> user | url = "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&format=json&limit=1&extended=1" <> "&api_key=" <> api <> "&user="<> user | ||||
case HTTPoison.get(url) do | case HTTPoison.get(url) do | ||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} -> Jason.decode(body) | {:ok, %HTTPoison.Response{status_code: 200, body: body}} -> Jason.decode(body) | ||||
Context not available. | |||||
end | end | ||||
end | end | ||||
defp fetch_track(user, %{"recenttracks" => %{"track" => [ t = %{"name" => name, "artist" => %{"name" => artist}} | _]}}) do | defp fetch_track(user, %{"recenttracks" => %{"track" => [ t = %{"name" => name, "artist" => %{"name" => artist}} | _]}}) do | ||||
api = Application.get_env(:lsg, :lastfm)[:api_key] | api = Application.get_env(:nola, :lastfm)[:api_key] | ||||
url = "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&format=json" <> "&api_key=" <> api <> "&username="<> user <> "&artist="<>URI.encode(artist)<>"&track="<>URI.encode(name) | url = "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&format=json" <> "&api_key=" <> api <> "&username="<> user <> "&artist="<>URI.encode(artist)<>"&track="<>URI.encode(name) | ||||
case HTTPoison.get(url) do | case HTTPoison.get(url) do | ||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} -> | {:ok, %HTTPoison.Response{status_code: 200, body: body}} -> | ||||
Context not available. |