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

Play on other devices #132

Closed
wants to merge 7 commits into from
Closed

Play on other devices #132

wants to merge 7 commits into from

Conversation

davidem
Copy link

@davidem davidem commented Jun 8, 2020

I've made options to list and play on other devices, like phones, computers, spotify connect devices, the like. It's using the authorisation part also used for listing one's playlists. Please note that i've added a few extra 'scopes', which means a possible existing 'refresh-token' needs to be removed.

Use list devices to list possible devices. Devices must be active, there's currently no history. It poops out the device id, name, type, used and volume level.

Use connect <device_id> to select and play on a device. To connect by 'name' does not work (yet)

What do you think? :)

@davidem
Copy link
Author

davidem commented Jun 8, 2020

(forgot to mention this is still a beta feature of the spotify web-api)

@hnarayanan
Copy link
Owner

Closing this PR because I've already merged a larger one that includes these changes.

@hnarayanan hnarayanan closed this Sep 27, 2020
@davidem davidem deleted the connect branch September 28, 2020 18:51
@moshed
Copy link

moshed commented Oct 7, 2020

was this ever merged into the main branch I cant seem to get it to work?

@davidem
Copy link
Author

davidem commented Oct 7, 2020

No, not yet. Harish has created a separate branch: 3.0-pre

If you use that branch, it works like this:

List possible devices for playback:
./spotify list devices
40charidofdevice0123456789abcdefghijklmn Mac Computer true 53
40charidofotherdevice0123456789abcdefghi Soundbar Speaker false 16`

To connect and play from another device:
./spotify connect 40charidofotherdevice0123456789abcdefghi`

true/false indicates if a device is active or not. The numbers show the spotify volume settings.

@moshed
Copy link

moshed commented Oct 8, 2020

ahhh got it.
it seems this requires user authentication and the redirect uri to http://localhost:8082/ isnt working. just freezes on the authentication page

@davidem
Copy link
Author

davidem commented Oct 8, 2020

Ah, yes... good of you to mention that. Completely forgot I had to whitelist that URL. Here's how:

  • Did you create an 'app' at the Spotify developers-site?
  • Within the 'app' settings, there's an option to provide a 'Redirect-URI'. Add "http://localhost:8082/" and after that it should work.
  • See screenshot
    The auth-token is written to /var/tmp/shpotify_refresh_token. Somethimes it helps to remove that file and re-authenticate.

Screenshot 2020-10-08 at 22 53 52

@davidem
Copy link
Author

davidem commented Oct 8, 2020

I'll add that info to the 'help' part

@moshed
Copy link

moshed commented Oct 9, 2020

hmm I had added it but I just removed the app from my dashboard and readded it and now it works! thanks for your help!

@moshed
Copy link

moshed commented Oct 9, 2020

did you include the removal of jq in this branch? seems it still requires it

@davidem
Copy link
Author

davidem commented Oct 9, 2020

Indeed, jq is still required. The relative ease of use of jq vs trying to parse json output with commands like grep/awk/tr/cut makes it 1:0 for jq in my opinion.

@moshed
Copy link

moshed commented Oct 9, 2020

ahh got it, im trying to put a device list into my menubar so I can choose my devices easily without opening Spotify but both apps that can achieve this (bettertouchtool and bitbar) dont seem to be compatible with jq unfortunately.

@davidem
Copy link
Author

davidem commented Oct 9, 2020

I don't get it, sorry ;) I assume with bitbar/bettertouchtool you call shpotify to list your available devices / select your playback devices, right? The output you get from shpotify does not require jq, it's only used to parse the json feedback from spotify.

@moshed
Copy link

moshed commented Oct 12, 2020

im not sure tbh. when I use Shpotify from the command line it works with no problems but when I attempt to create the script to select device playback form the menubar I get an error saying I need jq.

image

@davidem
Copy link
Author

davidem commented Oct 12, 2020

ah, thanks, now I think I get it :) My guess is that jq is not in $PATH of the 'user' running the script.

Best way is to add the full path to shpotify. It's fixed in my latest 3.0 version (#144) or found here: https://github.com/davidem/shpotify/tree/3.0

@davidem
Copy link
Author

davidem commented Oct 14, 2020

I've updated the JQ check. It first checks $PATH, then it checks if jq is in /usr/local/bin. @moshed: does it now work for you?

@moshed
Copy link

moshed commented Nov 13, 2020

hmm still not. my script is this with the full Spotify path

#!/bin/bash
echo spotify
usr/local/bin/spotify list devices

but I still get the same jq error as before?
im sure im doing something wrong as opposed to it not functioning properly because im not too savvy at this but I cant figure out what it is

@davidem
Copy link
Author

davidem commented Nov 13, 2020

Can you show me where jq is located?

Mine:

➜  ~ which jq
/usr/local/bin/jq

I'll add an option to hardlink to jq later today

@moshed
Copy link

moshed commented Nov 13, 2020

same as you

moshe@Moshes-MacBook-Pro ~ % which jq
/usr/local/bin/jq

@moshed
Copy link

moshed commented Nov 24, 2020

hey @davidem sorry to be a pain. do you have an idea why jq is not functioning properly when called from bitbar or better touch tool? should I be changing one of these settings?
image

@davidem
Copy link
Author

davidem commented Nov 24, 2020

Hi Moshed,

I've just installed bettertouchtool. I'll try to figure this out once and for all ;)

@davidem
Copy link
Author

davidem commented Nov 24, 2020

Hi Moshed, do you use my latest version? I've added a 'find' command a few weeks back to search for jq in /usr/local/bin, just in case it's not in PATH. It can be found here: https://github.com/davidem/shpotify/tree/3.0. Its changes have not yet been merged.

When I use bettertouchtool + my version of shpotify, it works like a charm. Note that 'list devices' also requires jq. If I disable 'find' in the script, it fails with the same error you get.

image

@moshed
Copy link

moshed commented Nov 30, 2020

it works! great news!

thanks so much!

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

Successfully merging this pull request may close these issues.

3 participants