Beispiel #1
0
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
    })
Beispiel #2
0
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)
Beispiel #3
0
def tracks_id(track_id):
    return TrackEncoder().encode(tracks.get(track_id))
Beispiel #4
0
def queue_current():
    return TrackEncoder().encode(tracks.get(queue.current()))
Beispiel #5
0
def queue_items():
    tracks_in_queue = [tracks.get(i) for i in queue.queue()]
    return TrackEncoder().encode(tracks_in_queue)