-
-
Save l4p4/d10e108a539a526237e7 to your computer and use it in GitHub Desktop.
22tracks for Sonos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from soco import SoCo | |
import requests | |
from pprint import pprint | |
pl = requests.get("http://22tracks.com/api/tracks/20") | |
playlist = pl.json() | |
file = playlist[0]['filename'] | |
t = requests.get("http://app01.22tracks.com/token.php?desktop=true&u=/128/%s" % file) | |
token = t.json() | |
url = "http://audio.22tracks.com/128/%s?st=%s&e=%s" % (file, token['st'], token['e']) | |
if __name__ == '__main__': | |
sonos = SoCo('192.168.123.23') # Pass in the IP of your Sonos speaker | |
# You could use the discover function instead, if you don't know the IP | |
# Pass in a URI to a media file to have it streamed through the Sonos | |
# speaker | |
sonos.play_uri(url) | |
track = sonos.get_current_track_info() | |
print track['title'] | |
sonos.pause() | |
# Play a stopped or paused track | |
sonos.play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment