plietar / librespot

Open Source Spotify client library
MIT License
1.13k stars 187 forks source link

Volume control #275

Open tatoosh opened 6 years ago

tatoosh commented 6 years ago

Is there a solution to control music Volumen by command line ?

thekr1s commented 6 years ago

I don't think librespot is the place for this. You might have a look at spotipy (https://github.com/plamere/spotipy) to create a python scrip to control the volume..

ComlOnline commented 6 years ago

Just to add for reference spotcontrol.

tatoosh commented 6 years ago

@thekr1s thx for the link, but i can't find volume control for spotipy @ComlOnline: great, but it's not python just 'go' - any other suggestions?

tatoosh commented 6 years ago

@thekr1s got it working :)

python volume.py 80 -> sets volume to 80%

here my working python code_

import pprint
import sys

import spotipy
import spotipy.util as util

scope = 'user-modify-playback-state'
username = 'YOURUSER'
token = util.prompt_for_user_token(username,scope,client_id='mine!',client_secret='mine!',redirect_uri='http://localhost:8888/callback/')
volume  = int(sys.argv[1])

if token:
    sp = spotipy.Spotify(auth=token)
    sp.trace = False
    results = sp.volume(volume)
    print results
else:
    print "Can't get token for", username
thekr1s commented 6 years ago

@tatoosh, Great that you got it working.