def queue_add(track_id=None): track = tracks.get(track_id) if track is None: return json.dumps({ 'success': False, 'reason': Response.INVALID_OBJECT_ID }) if not track.status.imported: return json.dumps({ 'success': False, 'reason': Response.TRACK_UNAVAILABLE }) with persistance(): track.status.available = player.available(track.mrl, track.backend) if not track.status.available: return json.dumps({ 'success': False, 'reason': Response.TRACK_UNAVAILABLE }) queue.add(track_id, g.user_token) return json.dumps({ 'success': True })
def add(track_id: int, user_token: str) -> None: """ » Subscribed to queue_add Adds a track to the queue by it's id :param user_token: The user token of the user who added this track :param track_id: The track's id :return: None """ track = tracks.get(track_id) with remote() as r: r.add(track_id, track.mrl, track.backend)
def tracks_id(track_id): return TrackEncoder().encode(tracks.get(track_id))
def queue_current(): return TrackEncoder().encode(tracks.get(queue.current()))
def queue_items(): tracks_in_queue = [tracks.get(i) for i in queue.queue()] return TrackEncoder().encode(tracks_in_queue)