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

Possible to see current song? #171

Closed
thecompix opened this issue Dec 28, 2018 · 6 comments
Closed

Possible to see current song? #171

thecompix opened this issue Dec 28, 2018 · 6 comments

Comments

@thecompix
Copy link

Hey Guys,

is it possible to see via command the current playing song with artist, title and track time?
because i want to put this output to a webview with js variables.

thaaanks guys
the compix.

@janek
Copy link

janek commented Jan 5, 2019

hey @thecompix,

you might want to check out Spotify's Web API. It's well done and opens up a whole world of possibilities if you're hacking around. I'm using it with raspotify and I'm very happy. Start here:
https://developer.spotify.com/documentation/web-api/quick-start/

The endpoint that will return the current song playing is documented here:
https://developer.spotify.com/documentation/web-api/reference/player/get-the-users-currently-playing-track/

And you can try it out here:
https://developer.spotify.com/console/get-users-currently-playing-track/

If you run into problems let me know here and I'll try to help out.

@fixmycode
Copy link

I work on a lab and we have a RPi with raspotify connected to some old speakers. The device is shared among all the lab workers, with many different spotify accounts, and the web API depends on a single account to show the information. Being able to read the current track using a frontend program would be nice, something like raspotify --now-playing, that way I could show what's playing in the lab screens...

I'd label this issue as a feature request.

@l3d00m
Copy link

l3d00m commented Apr 2, 2019

Related? librespot-org/librespot#185

Btw great idea @fixmycode. I used the web API too in the past with multiple accounts, but this way it sounds a lot easier.

@Ich-Eben
Copy link

Ich-Eben commented Jul 1, 2019

Hey,
the --onevent option from librespot works great btw. So we don’t really need to implement this in raspotify. Just add:
OPTIONS="--onevent 'node /usr/local/bin/myEventGateway/main.js'"
To your raspotify config file and put this script in /usr/local/bin/myEventGateway/main.js (for example):

var mqtt = require('mqtt');
var client  = mqtt.connect('mqtt://localhost');

client.on('connect', function() {
        client.publish('raspotify/playEvent', process.env.PLAYER_EVENT);
        client.publish('raspotify/trackId', process.env.TRACK_ID);
        client.publish('raspotify/oldTrackId', process.env.OLD_TRACK_ID);
        client.end();
});

This will publish the events send from librespot to an mqtt server. Than you can grab it from there from pretty everywhere. Of course you'll still have to use the WebAPI to get the song name from the track id, but you don’t need an account for this as far as I know.
Don’t forget to install mosquito and nodejs on your pi to use this. You’ll also require the node module mqtt (npm install mqtt).
hf

@besi besi mentioned this issue Feb 19, 2020
3 tasks
@github-actions
Copy link

This issue is over a year old and has been marked as stale. It will closed in 7 days if there is no activity.

@github-actions
Copy link

This issue has been closed due to lack of activity.

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

No branches or pull requests

5 participants