From 7637606691d05817ffb7a245a8aa029b1b0a9747 Mon Sep 17 00:00:00 2001 From: Iamasink Date: Tue, 14 May 2024 01:15:50 +0100 Subject: [PATCH 1/2] fix crash with spotify local files --- lib/presence/spotify.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/presence/spotify.ex b/lib/presence/spotify.ex index de85bcf..192e428 100644 --- a/lib/presence/spotify.ex +++ b/lib/presence/spotify.ex @@ -1,8 +1,14 @@ defmodule Lanyard.Presence.Spotify do def build_pretty_spotify(activity) when is_map(activity) do + artist = + case Map.fetch(activity, :state) do + {:ok, state} -> state + :error -> nil + end + %{ track_id: get_track_id(activity), - artist: activity.state, + artist: artist, song: activity.details, album: get_album_title(activity), album_art_url: get_album_art_url(activity), From 6851a419e43e2f7784d371d1e85b80e7c8fcbfa0 Mon Sep 17 00:00:00 2001 From: Iamasink Date: Mon, 20 May 2024 18:34:09 +0100 Subject: [PATCH 2/2] simplify code - use Map.get --- lib/presence/spotify.ex | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/presence/spotify.ex b/lib/presence/spotify.ex index 192e428..3f4a105 100644 --- a/lib/presence/spotify.ex +++ b/lib/presence/spotify.ex @@ -1,14 +1,8 @@ defmodule Lanyard.Presence.Spotify do def build_pretty_spotify(activity) when is_map(activity) do - artist = - case Map.fetch(activity, :state) do - {:ok, state} -> state - :error -> nil - end - %{ track_id: get_track_id(activity), - artist: artist, + artist: Map.get(activity, :state), song: activity.details, album: get_album_title(activity), album_art_url: get_album_art_url(activity),