Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
Last active January 11, 2021 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ongaeshi/c23b669c7dd2fcb3668c800f15128f23 to your computer and use it in GitHub Desktop.
Save ongaeshi/c23b669c7dd2fcb3668c800f15128f23 to your computer and use it in GitHub Desktop.
def get_recent_tracks(token)
URI.open("https://api.spotify.com/v1/me/player/recently-played", "Authorization" => "Bearer #{token}") do |f|
JSON.load(f.read)["items"].map do |e|
e = e["track"]
"#{e["name"]} - #{e["artists"][0]["name"]}"
end
end
end
TOKEN = 'XXXXXXXXXX'
puts get_recent_tracks(TOKEN)
@ongaeshi
Copy link
Author

ongaeshi commented Jan 11, 2021

$ ruby get_recent_tracks.rb
日曜日よりの使者 - Creepy Nuts
きらきら武士 - Rekishi
ハニーメモリー - aiko
やさしいままで - never young beach
ばらばら - Gen Hoshino
不革命前夜 - NEE
群青 - YOASOBI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment