Ejemplo n.º 1
0
def profile():
    user=session['user']
    playlist_id = db_edit.findInfo('users', user, 'Username')[0][1]
    print ('playlist_id')
    print (playlist_id)
    songs = db_edit.findInfo('songs',playlist_id,'PlaylistID')
    return render_template('profile.html',
                            songs=songs,
                            playlist_id=playlist_id,
                            user=session['user'],
    )
Ejemplo n.º 2
0
def user_profile():
    user = request.form['user']
    playlist_id = db_edit.findInfo('users', user, 'Username')[0][1]
    songs = db_edit.findInfo('songs',playlist_id,'PlaylistID')

    # print ('--user profile--')
    # print (user)

    return render_template('user_profile.html',
                            username=user,
                            songs=songs,
                            playlist_id=playlist_id,
    )
Ejemplo n.º 3
0
def users():
    user = session['user']
    users = db_edit.findInfo('users',user,'Username', notEqual = True)
    print ('our users')
    print (users)
    return render_template('users.html',
                            users=users
        )
Ejemplo n.º 4
0
def login():
    '''logs the user in by checking if their login info matches with registered user'''
    username = request.form['usr'].strip()
    password = request.form['pwd'].strip()
    user_exists = db_edit.findInfo('users', db_edit.checkApos(username), 'username', fetchOne = True)
    '''find password for username'''
    if user_exists:
        # print (user_exists)
        # print (password)
        # print (sha256_crypt.verify(password, user_exists[2]))
        if sha256_crypt.verify(password, user_exists[2]):
            session['user'] = username
            return redirect(url_for('home'))
        else:
            flash("Wrong password!")
            return render_template('home.html')
    else:
        flash("Wrong username!")
    return redirect(url_for('home'))
Ejemplo n.º 5
0
def play():
    '''runs the song algorithm'''

    tags = request.form.get('tags')
    s_tags = tags
    tags = tags.split(',')
    artist = request.form.get('artist')

    transit_length = request.form.get('transit_length')
    route_length = request.form.get('route_length')

    if transit_length:
        time = int(transit_length)
    else:
        time = int(route_length)

    print ('---PLAY IS CALLED---')
    print (type(time))
    print (time)

    # playlist = music.get_tracks_tagged(time, tags)

    # if len(tags) == 0:
    #
    #     playlist = music.get_tracks_tagged("None", "None", "None", time)
    # elif len(tags) == 1:
    #     playlist = music.get_tracks_tagged(tags[0], "None", "None", time)
    # elif len(tags) == 2:
    #     playlist = music.get_tracks_tagged(tags[0], tags[1], "None", time)
    # else:
    #     playlist = music.get_tracks_tagged(tags[0], tags[1], tags[2], time)

    if len(tags) == 0:
        playlist = music.gen_playlist(time, "None", "None", "None")
    elif len(tags) == 1:
        playlist = music.gen_playlist(time, tags[0], "None", "None")
    elif len(tags) == 2:
        playlist = music.gen_playlist(time, tags[0], tags[1], "None")
    else:
        playlist = music.gen_playlist(time, tags[0], tags[1], tags[2])

    # if len(tags) == 0:
    #     playlist = music.gen_playlist(time, "None", "None", "None")
    # elif len(tags) == 1:
    #     playlist = music.gen_playlist(time, tags[0], "None", "None")
    # elif len(tags) == 2:
    #     playlist = music.gen_playlist(time, tags[0], tags[1], "None")
    # else:
    #     playlist = music.gen_playlist(time, tags[0], tags[1], tags[2])

    length = len(playlist)
    time = music.get_total_time(playlist)

    print (playlist)

    db_edit.insert('playlists', [time])
    playlist_id = db_edit.findInfo('playlists', time, 'Songs')[0][0]
    print ('play here')
    print (playlist_id)
    # print('---HERE---')
    # print (playlists)
    # print (transit_time)

    # playlist = music.gen_playlist(time, tags)

    for song in playlist:
        songstuff = [playlist_id, song[2], song[1], song[0]]
        print (songstuff)
        db_edit.insert('songs', songstuff)

    return render_template('play.html',
                           tags=s_tags,
                           playlist = playlist,
                           playlist_id = playlist_id,
                           time = time,
                           length = length
    )