Exemplo n.º 1
0
def page_index():
    login = get_login_info()

    q = request.args.get('q', type=str, default='')  # search query
    sort = request.args.get('sort', type=str, default='new')  # page number
    page = request.args.get('page', type=int, default=1)  # page number

    pls = playlist_finder.Playlist_Finder(client, playlist_details_db_name,
                                          playlist_details_collection_name)
    pls_data, results_count = pls.get_playlists(query=q,
                                                sort=sort,
                                                user=None,
                                                empty=False)
    pls_data = pls_data[((page - 1) * playlists_per_page):(page *
                                                           playlists_per_page)]

    pages = results_count // playlists_per_page + 1

    if page > pages or page <= 0:
        abort(404)

    return render_template("index_template.html",
                           banner_text="search: " +
                           q if q != "" else "Welcome to osulist!",
                           q=q,
                           data=pls_data,
                           no_results=True if pls_data == [] else False,
                           playlists_count=len(pls_data),
                           results_count=results_count,
                           page=page,
                           pages=pages,
                           login=login)
Exemplo n.º 2
0
def page_search():
    login = get_login_info()

    search_string = request.args.get('search_string')
    pls = playlist_finder.Playlist_Finder(client, playlist_details_db_name,
                                          playlist_details_collection_name)
    pls_rows = pls.get_search_playlists(search_string)

    return render_template("index_template.html",
                           banner_text="search: " + search_string,
                           search_string=search_string,
                           data=pls_rows,
                           no_results=True if pls_rows == [] else False,
                           login=login)
Exemplo n.º 3
0
def page_profile(u_id):
    login = get_login_info()

    pls = playlist_finder.Playlist_Finder(client, playlist_details_db_name,
                                          playlist_details_collection_name)
    api = osuapi.Osuapi(OSU_TOKEN)

    try:
        pl_data = pls.get_user_playlists(u_id)
        num_playlists = len(pl_data)
        display_name = api.get_user(u_id)['username']
    except IndexError:
        return abort(404)

    return render_template("profile_template.html",
                           data=pl_data,
                           display_name=display_name,
                           user_id=u_id,
                           num_playlists=num_playlists,
                           login=login)
Exemplo n.º 4
0
def new_playlist():
    pls = playlist_finder.Playlist_Finder(client, playlist_details_db_name,
                                          playlist_details_collection_name)
    playlist_id = pls.new_playlist(session['user_id'])

    return redirect(f'/p/{ playlist_id }/edit/')