Пример #1
0
def search():
    query = request.args.get('q')
    if query.startswith('album:'):
        return jsonify(song.get_album(query[6:].lstrip()))
    elif query.startswith('artist:'):
        return jsonify(song.get_albums_for_artist(query[7:].lstrip()))
    elif query.startswith('play-history'):
        try:
            limit = int(query[13:])
            return jsonify(song.get_history(limit=limit))
        except ValueError:
            return jsonify(song.get_history())
    elif query.startswith('top-songs'):
        try:
            limit = int(query[10:])
            return jsonify(song.top_songs(limit=limit))
        except ValueError:
            return jsonify(song.top_songs())
    else:
        limit = request.args.get('limit')
        if limit and int(limit) != 0:
            return jsonify(song.search_songs(query, limit=int(limit)))
        return jsonify(song.search_songs(query))
Пример #2
0
def search():
    query = request.args.get('q')
    if query.startswith('album:'):
        return jsonify(song.get_album(query[6:].lstrip()))
    elif query.startswith('artist:'):
        return jsonify(song.get_albums_for_artist(query[7:].lstrip()))
    elif query.startswith('play-history'):
        try:
            limit = int(query[13:])
            return jsonify(song.get_history(limit=limit))
        except ValueError:
            return jsonify(song.get_history())
    elif query.startswith('top-songs'):
        try:
            limit = int(query[10:])
            return jsonify(song.top_songs(limit=limit))
        except ValueError:
            return jsonify(song.top_songs())
    else:
        limit = request.args.get('limit')
        if limit and int(limit) != 0:
            return jsonify(song.search_songs(query, limit=int(limit)))
        return jsonify(song.search_songs(query))
Пример #3
0
def top_songs():
    limit = request.args.get('limit')
    if limit and int(limit) != 0:
        return jsonify(song.top_songs(limit=int(limit)))
    return jsonify(song.top_songs())
Пример #4
0
def top_songs():
    limit = request.args.get('limit')
    if limit and int(limit) != 0:
        return jsonify(song.top_songs(limit=int(limit)))
    return jsonify(song.top_songs())