Skip now playing tracks when pulling from Last.fm
This commit is contained in:
@@ -36,7 +36,9 @@ defmodule LastFm.Track do
|
||||
end
|
||||
|
||||
def from_api_response(raw_tracks) do
|
||||
Enum.map(raw_tracks, fn t ->
|
||||
raw_tracks
|
||||
|> Enum.reject(&now_playing?/1)
|
||||
|> Enum.map(fn t ->
|
||||
album = %Album{
|
||||
musicbrainz_id: t["album"]["mbid"],
|
||||
title: t["album"]["#text"]
|
||||
@@ -60,6 +62,10 @@ defmodule LastFm.Track do
|
||||
end)
|
||||
end
|
||||
|
||||
defp now_playing?(raw_track) do
|
||||
get_in(raw_track, ["@attr", "nowplaying"]) == "true"
|
||||
end
|
||||
|
||||
defp parse_cover_url(track) do
|
||||
track["image"]
|
||||
|> Enum.find(%{"#text" => nil}, fn i -> i["size"] == "medium" end)
|
||||
|
||||
Reference in New Issue
Block a user