Ejemplo n.º 1
0
def init():
    ### INPUT
    user_list = [
        'spotify', 'spotifyusa', 'topsify', 'spotify_uk_', 'spotify_germany',
        'spotify_espa%C3%B1a', 'spotify_france', 'kexp_official', 'hot97.1',
        'chillhopmusic', 'bbc_playlister', 'npr_music', 'nme.com',
        'mergerecordsofficial', 'subpoprecords', 'burgerrecords4life',
        'warnerbros.records', 'matadorrecords'
    ]
    #user_list = ['spotifycharts']
    ### INPUT

    ### date settings
    time = datetime.now()
    day = time.day
    month = time.month
    ### date settings

    for user in user_list:

        ### directory for the new date
        global path
        path = r'user_PL/' + user + '/' + str(month) + "_" + str(day) + "/"

        if not os.path.exists(path):
            os.makedirs(path)
        ### directory for the new date

        access_token = access.get_token()

        user_pl(user, access_token)
Ejemplo n.º 2
0
def image_classify(image_path):
    # 二进制方式打开图片文件
    f = open(image_path, 'rb')
    img = base64.b64encode(f.read())

    params = {"image": img}
    params = urllib.urlencode(params)

    access_token = access.get_token()

    request_url = base_url + "?access_token=" + access_token
    request = urllib2.Request(url=request_url, data=params)
    request.add_header('Content-Type', 'application/x-www-form-urlencoded')
    response = urllib2.urlopen(request)
    content = response.read()
    if content:
        return content
    else:
        print("conten is empty or none.")
        return content
Ejemplo n.º 3
0
def debugger():
    access_token = access.get_token()
    main_req_playlist('spotify_france', '37i9dQZF1DWU4xkXueiKGW', 'Fresh Rap',
                      access_token)
Ejemplo n.º 4
0
        'danceability', 'energy', 'key', 'loudness', 'mode', 'speechiness',
        'acousticness', 'instrumentalness', 'liveness', 'valence', 'tempo',
        'duration_ms', 'time_signature', 'Song_ID'
    ]
    print(dict_)
    #features_df = pd.DataFrame.from_dict(dict_)

    ##change key = 'id' to 'Song_ID' + make it the first element
    del dict_[0]['type']
    del dict_[0]['uri']
    del dict_[0]['analysis_url']
    del dict_[0]['track_href']
    song_id = dict_[0].get('id')
    del dict_[0]['id']

    d = dict_[0]
    d['Song_ID'] = song_id
    print(d)

    df = pd.DataFrame.from_dict([d])

    res = df

    #print("... A POSTERIORI:")
    #print(res)

    return res


access_token = access.get_token()
init2()