def track_change(self, videoPath): print( f"[{colored('#','yellow')}] Changing track to ", colored(path2title(videoPath), "green"), ) self.send("changeTrack", {self.tracks[videoPath][0]: self.tracks[videoPath][1]})
def track_change(self, videoPath, state): print(f"[{colored('#','yellow')}] Changing track to ", colored(path2title(videoPath), 'green')) self.send('changeTrack', { self.tracks[videoPath][0]: self.tracks[videoPath][1], "state": state })
def create_room(self, videoPath): self.send( "createRoom", { "title": path2title(videoPath), self.tracks[videoPath][0]: self.tracks[videoPath][1], }, )
def add_track(self, videoPath): self.send( "addTrack", { "title": path2title(videoPath), self.tracks[videoPath][0]: self.tracks[videoPath][1], }, )
def upload(self, videoPath, audioPath): """ Uploads audio file to the webserver """ print( f"[{colored('+','green')}] Uploading {colored(path2title(audioPath),'green')} to server ..." ) import requests url = f"http://{SERVER_ADDR}:5000/api/upload/" files = {"file": (path2title(videoPath), open( audioPath, "rb"), "audio/mp3")} r = requests.post(url=url, files=files, data={ "title": path2title(videoPath)}) self.tracks[videoPath] = ("trackId", r.json()["trackId"]) print( f"[{colored('+','green')}] Upload complete for file {colored(path2title(audioPath),'green')}" )
def on_start(match, state, server): file = match.groups()[0] fileFormatted = file.replace("%20", " ") server.track_change(videoPath=fileFormatted) state["path"] = file state["title"] = path2title(file) state["duration"] = get_duration(file) * 1000 state["is_playing"] = True state["position"] = 0.0 state["last_updated"] = time.time()
def on_start(match, state, server): from urllib.parse import unquote file = unquote(match.groups()[0]) state["path"] = file state["title"] = path2title(file) state["duration"] = get_duration(file) * 1000 state["is_playing"] = True state["position"] = 0.0 state["last_updated"] = time.time() server.track_change(videoPath=file, state=state)