Closed catgoose closed 9 months ago
This is difficult to do because it takes time for Spotify API to show up the changed playback. In other words, calling current_playback
API after next
API can give you the previous track. I would suggest you use a separate command (e.g get key playback
to get the playback instead.
@catgoose This is how you can do it with get key playback
:
spotify_player get key playback \
| python3 -c 'import sys; import json; detail=json.loads(sys.stdin.read())["item"]; track=detail["name"]; album=detail["album"]["name"]; artists=", ".join([a["name"] for a in detail["artists"]]); link=detail["external_urls"]["spotify"]; print(f"\n{track} ∈ {album}\nby {artists}\n{link}")'
For future reference:
spotify-tui
implemented this here, I believe it does not avoid the issue @aome510 mentioned as there is a short lag (few ms) when using this:
https://github.com/Rigellute/spotify-tui/blob/master/src/cli/cli_app.rs#L393
It also shows if current playback is liked or not using current_user_saved_tracks_contains
, in which we used for add to library function:
or:
spotify_player get key playback | jq -r '.item | "\(.artists | map(.name) | join(", ")) - \(.name)"'
or:
spotify_player get key playback | jq -r '.item | "\(.artists | map(.name) | join(", ")) - \(.name)"'
Thanks this works for me. I can do:
spotify_player playback previous && spotify_player get key playback | jq -r '.item | "\(.artists | map(.name) | join(", ")) - \(.name)"'
Related to #279
When using
spotify_player playback next|previous
I would like it ifspotify_player
would output the song that was switched to. This should only print if there is no activespotify_player
instance.For example: