Ejemplo n.º 1
0
def test():
    sp = sa.SpotifyAdapter()
    a = sp.get_all_playlists_from_user(sp.get_token(sp.get_username()),
                                       sp.get_username())
    html = ''
    for pl in a['items']:
        html += pl['name'] + '<br>'
    return a['name']
Ejemplo n.º 2
0
    def root():
        sp = sa.SpotifyAdapter()
        playlists = sp.get_all_playlists_from_user(session["access_token_spotify"], sp.get_username())
        update_user_songs()
        #current_song = sp.get_current_playing()
        #t = Timer((current_song['item']['duration_ms'] - current_song['progress_ms'])/1000, test_timer)
        #t.start()

        return render_template("home.html", playlists=playlists['items'])
Ejemplo n.º 3
0
def hola():
    sp = sa.SpotifyAdapter()
    a = sp.get_random_tracks_from_user_playlist(
        'Esto es muy facil', 5, sp.get_token(sp.get_username()),
        sp.get_username())
    html = ''
    for tema in a:
        html += tema['track']['name'] + '<br>'
    return html
Ejemplo n.º 4
0
def tracks():
    sp = sa.SpotifyAdapter()
    b = sp.get_all_playlists_from_user(sp.get_token(sp.get_username()),
                                       sp.get_username())
    a = sp.get_all_tracks_from_playlist(sp.get_token(sp.get_username()),
                                        sp.get_username(), b)
    html = ''
    for pl in a['items']:
        html += pl['track']['name'] + '<br>'
    return html
Ejemplo n.º 5
0
 def searchSongService():
     sp = sa.SpotifyAdapter()
     if request.form['operation'] == "searchSong":
         listToReturn = sp.adapt_to_autocomplete(sp.search(request.form['term']))
         prepared = jsonify(results =[result.serialize() for result in listToReturn])
         return prepared
     elif request.form['operation'] == "getUserTracks":
         offset = request.form['offset']
         return jsonify(sp.get_user_saved_tracks(sp.get_token(),offset))
     elif "addSongToMyMusic" == request.form['operation']:
         id = request.form['id']
         sp.current_user_saved_tracks_add(sp.get_token(), [id])
         return ''
     elif "getAllPlaylists" == request.form['operation']:
         return jsonify(sp.get_all_playlists_from_user(sp.get_token(), sp.get_username()))
     elif "createPlaylist" == request.form['operation']:
         return jsonify(sp.create_playlist(sp.get_username(), request.form['plname'] , sp.get_token()))
     elif "addTracksToPlaylist" == request.form['operation']:
         return jsonify(sp.user_playlist_add_tracks(sp.get_token(), sp.get_username(), request.form['plid'], request.form['ids']))