def get(id: int) -> typing.Dict: """ Get the name of the player :param id: The ID of the player :return: A dictionary containing the name of the player """ return {'name': library.LivePlayer(id).name}
def get(self, id) -> str: """ Get the state of the player :param id: The ID of the player to get the state of :return: The current state of the player """ player = library.LivePlayer(id) return player.state.name
def get(self, id) -> int: """ Get the number of songs played since the last jingle for a player :param id: The ID of the player to get the count for :return: The number of songs played since the last jingle """ player = library.LivePlayer(id) return player.jingle_plays
def get(self, id) -> int: """ Get the number of songs between jingles for a player :param id: The ID of the player to get the count for :return: The number of songs between jingles """ player = library.LivePlayer(id) return player.jingle_count
def get(self, id) -> str: """ Get the ID of the current jingle playlist :param id: The ID of the player to get the state of :return: The ID of the current jingle playlist """ player = library.LivePlayer(id) playlist = player.jingle_playlist return '' if playlist is None else str(playlist.id)
def delete(id: int) -> bool: """ Delete the player :param id: The ID of the player :return: Always true """ library.LivePlayer(id).delete() socketio = flask.current_app.extensions['socketio'] socketio.emit('player_remove', {'id': id}) return True
def put(self, id) -> bool: """ Set the playlist containing the jingles :param id: The ID of the play to set the state of :return: Always true """ args = self._parser.parse_args(strict=True) player = library.LivePlayer(id) player.jingle_playlist = args.id return True
def put(self, id) -> bool: """ Set the state of the player :param id: The ID of the player to set the state of :return: Always true """ args = self._parser.parse_args(strict=True) player = library.LivePlayer(id) player.state = library.database.LivePlayerState[args.state] return True
def put(self, id: int) -> int: """ Set the name of the player :param id: The ID of the player :return: Always true """ args = self._parser.parse_args(strict=True) library.LivePlayer(id).name = args.name socketio = flask.current_app.extensions['socketio'] socketio.emit('player_update', {'id': id, 'name': args.name}) return True
def get(self, id) -> typing.List[typing.Dict]: """ Get the tracks for a player :param id: The ID of the player :return: A list of the tracks in the player """ player = library.LivePlayer(id) return [{ 'id': track, 'type': type_.name } for track, type_ in player.tracks]
def put(self, id) -> bool: """ Get the number of songs between jingles for a player :param id: he ID of the player to set the count for :return: Always true """ args = self._parser.parse_args(strict=True) player = library.LivePlayer(id) player.jingle_count = args.count socketio = flask.current_app.extensions['socketio'] socketio.emit('player_jinglecount_' + str(id), args.count) return True
def put(self, id) -> bool: """ Add tracks to the player :param id: The ID of the player :return: Always true """ args = self._parser.parse_args(strict=True) if len(args.tracks) != len(args.types): flask_restful.abort(400, message='Each track must have a type') player = library.LivePlayer(id) player.tracks = [(track, library.database.LivePlayerType[type_]) for track, type_ in zip(args.tracks, args.types)] return True