Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write currently playing track to file #1019

Closed
BenStigsen opened this issue Dec 26, 2022 · 4 comments
Closed

Write currently playing track to file #1019

BenStigsen opened this issue Dec 26, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@BenStigsen
Copy link

BenStigsen commented Dec 26, 2022

It would be cool if the currently playing track could be written to a file. This would make it possible to show the currently playing track in applications such as Open Broadcaster Software, and also make it easier to create applications that make use of this. Like updating the Discord status to say what track is currently being played.

Like artist - title to currently_playing.txt:

Fine-Sir-15846600650 - victorious
@BenStigsen BenStigsen added the enhancement New feature or request label Dec 26, 2022
@hrkfdn
Copy link
Owner

hrkfdn commented Dec 26, 2022

Would #1018 help with this?

@BenStigsen
Copy link
Author

It would definitely make it possible, but not easily.

Another alternative, might be to change the title of the ncspot window.
So ncspot - Rick Astley - Never Gonna Give You Up, this would allow one to just grab the title of the window.

hrkfdn added a commit that referenced this issue Dec 28, 2022
Whenever the playback mode (playing, paused, stopped) or the track changes, all
socket listeners will be notified.

Fixes #924, fixes #1019
@hrkfdn hrkfdn closed this as completed in ec4b7c2 Dec 28, 2022
@Salt-Factory
Copy link
Contributor

Salt-Factory commented Jan 15, 2023

Sorry to comment on a closed issue, but for future reference: I struggled with using netcat to show the ncspot status in Sway as it keeps the connection to the socket open, whereas I am only interested in getting the currently playing information. After fiddling around a bit, I discovered that the OpenBSD variant of netcat has a -W flag, which closes the connection after x packets. If you set it to 1, the connection closes right after receiving the currently playing song. E.g.:

$ nc -W 1 -U ~/.cache/ncspot/ncspot.sock
{"mode":{"Playing":{"secs_since_epoch":1673793184,"nanos_since_epoch":455175037}},"playable":{"type":"Track","id":"0LjTqBwFKfblqnuuDCH2Sw","uri":"spotify:track:0LjTqBwFKfblqnuuDCH2Sw","title":"Flat Beat - Radio Edit","track_number":4,"disc_number":1,"duration":237266,"artists":["Mr. Oizo"],"artist_ids":["0b9ukmbg0MO5eMlorcgOwz"],"album":"Flat Beat","album_id":"4rUN2CpOOBouCSnbi3MfYQ","album_artists":["Mr. Oizo"],"cover_url":"https://i.scdn.co/image/ab67616d0000b2733ba0a79c4ffdbc5d4ce3b165","url":"https://open.spotify.com/track/0LjTqBwFKfblqnuuDCH2Sw","added_at":"2023-01-04T18:30:03Z","list_index":0}}

You can then use jq to parse the json.

This should also work for the other use cases described in this issue. Maybe I could add this info to the readme?

@hrkfdn
Copy link
Owner

hrkfdn commented Jan 15, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants