def __init__(self): self.mpc = MPCPlayer()
class MPCRequestHandler: def __init__(self): self.mpc = MPCPlayer() def __call__(self, params): if "forward" in params: self.mpc.jumpFForward() elif "play" in params: qs = env.get('QUERY_STRING') query = urllib.parse.parse_qs(qs) url = query['url'][0] spawnPlayer(url) start_resp('200 OK', [('Content-Type', 'text/plain')]) return "" elif "backward" in params: self.mpc.jumpBBack() elif "pplay" in params: self.mpc.pplay() elif "audio" in params: self.mpc.nextAudio() elif "fullscreen" in params: self.mpc.fullscreen() elif "playerinfo" in params: try: data = json.dumps(self.mpc.getInfo()) start_resp('200 OK', [('Content-Type', 'text/plain')]) return data except Exception as e: return str(e) return "Ok"