diff options
author | makefu <github@syntax-fehler.de> | 2014-04-02 13:23:49 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2014-04-02 13:23:49 +0200 |
commit | 82d3258f5a316910bb844ba202748261ae27c5fc (patch) | |
tree | 2f40447acca41179a5c43701c40eb719129291ec /god/streams/bin/relaxxapi.py | |
parent | 10af0e082e36d6cda7d687362e7c7cf4c04b741c (diff) |
relaxxapi: fix broken code
Diffstat (limited to 'god/streams/bin/relaxxapi.py')
-rwxr-xr-x | god/streams/bin/relaxxapi.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/god/streams/bin/relaxxapi.py b/god/streams/bin/relaxxapi.py index 55e628b0..38650907 100755 --- a/god/streams/bin/relaxxapi.py +++ b/god/streams/bin/relaxxapi.py @@ -1,16 +1,14 @@ -#!/usr/bin/python2 +#!/usr/bin/python import json -from urllib import quote +from urllib.parse import quote class relaxx: - + r = "" def __init__(self,relaxxurl="http://lounge.mpd.shack/"): self.baseurl=relaxxurl + import requests - ret = requests.get(relaxxurl) # grab cookie - try: - self.r = requests.session(cookies=ret.cookies,headers={"Referer":relaxxurl}) - except: - print ("you are missing the `requests` dependency, please do a `pip install requests`") + self.r = requests.session() + ret = self.r.get(relaxxurl) # grab cookie def _status(self,value=0,data="json=null"): """ value is some weird current playlist value, 0 seems to work @@ -66,9 +64,9 @@ class relaxx: return self.r.get(url).text def add_radio(self,playlist=""): - print playlist - print self._radio(playlist) - print json.loads(self._radio(playlist)) #[1:-1])["url"] + print(playlist) + print(self._radio(playlist)) + print(json.loads(self._radio(playlist))) #[1:-1])["url"] resolved_url= json.loads(self._radio(playlist)[1:-1])["url"] self.add_song(resolved_url) @@ -130,9 +128,9 @@ class relaxx: if __name__ == "__main__": r = relaxx() - print r.state() - print r.playing() - print r.add_radio("http://deluxetelevision.com/livestreams/radio/DELUXE_RADIO.pls") + print(r.state()) + print(r.playing()) + print(r.add_radio("http://deluxetelevision.com/livestreams/radio/DELUXE_RADIO.pls")) #print r.clear() #print r.add_radio("http://somafm.com/lush.pls") #print r.get_first()["Id"] |