dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 3ac031bfa9242224491358dc419a174a5a1c66eb
parent c69840f1a877ba3a296a00131475b6be7e3e34b6
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Sun, 18 Aug 2024 23:47:33 +0200

libspotify: give me an overview of a playlist

Diffstat:
Mscripts/libspotify.rb | 17+++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/scripts/libspotify.rb b/scripts/libspotify.rb @@ -175,6 +175,23 @@ class SpotifyClient end end +def playlist_overview playlist_id + # to download: + # playlist_id = '52qgFnbZwV36ogaGUquBDt' + client = SpotifyClient.new + playlist_tracks = api_call_get_unpaginate("playlists/#{playlist_id}/tracks", { limit: 50 }) + by_artist = playlist_tracks.group_by { _1.track.artists.first.name } + by_artist_album = by_artist.reduce({}) { |h, (artist, tracks)| h[artist] = tracks.group_by { |t| t.track.album.name }; h } + res = by_artist_album.reduce({}) do |h, (artist, albums)| + h[artist] = albums.reduce({}) do |h2, (album, tracks)| + h2[album] = tracks.map { |track| track.track.name }.uniq + h2 + end + h + end + puts JSON.dump res +end + # Process new releases since the date in ~/.local/share/spot-last-checked, add # them to a tracks or albums playlist. def process_new_releases