def mobile(self, c=None): if c is None: songData = pidora.getSongData(self.data) return template.mobile(songData) else: json = libjson.dumps(dict(method="Control", id=0, command=c)) pidora.api(self.data, json) raise cherrypy.HTTPRedirect('/mobile')
def start(self): if self.data['pianobar'] is None: pidora.api(self.data, '{"method":"Pianobar.Start", "id":1}') return "<html><head><title>Pianobar has started</title></head><meta http-equiv=\"refresh\" content=\"3;URL=/mobile\"><body><p>Pianobar is starting</p></body></html>" else: return "<html><head><title>Pianobar is already running</title><meta http-equiv=\"refresh\" content=\"3;URL=/mobile\"></head><body><p>Pianobar is already running</p></body></html>"
def quit(self): if self.data['pianobar']: pidora.api(self.data, '{"method":"Pianobar.Quit", "id":1}') return "<html><head><title>Pianobar has quit</title></head><body><p>Pianobar has quit</p></body></html>" else: return "<html><head><title>Pianobar is not running</title></head><body><p>Pianobar is not running</p></body></html>"
def api(self, json=None): cherrypy.response.headers['Content-Type'] = 'application/json' reply = pidora.api(self.data, json) return reply["json"]