spotipy

Can't get new token in Spotipy

倖福魔咒の 提交于 2021-02-11 12:41:56
问题 About a month ago I was playing with the library and all of this worked as planned. Now I wanted to play with it again but I get the following error when trying to request the top tracks: spotipy.exceptions.SpotifyException: http status: 400, code:-1 - Couldn't refresh token: code:400 reason:Bad Request, reason: {'Authorization': 'Basic Y2Y2NGFiNDY2ZDI0NDIyMzgzMjRhMjI0NTQxZDkzOGQ6MmJmMTQ5MTgxYmIxNDczZDg5MTAwOTEwYzkzOWRkZjU='} I tried revoking the permission on my account in the hope it would

Having trouble using cached tokens with Spotipy for Spotify?

好久不见. 提交于 2021-02-07 04:18:08
问题 I'm trying to use Spotipy to access a user's Spotify library but am running into a bit of trouble. For background, I'm using Flask, SQLAlchemy, and Flask-Login. I looked off of this tutorial on github to get started, but this one doesn't quite work for me because if you use a cache, all users can access the playlist of the user whose token is cached, and since there is a cached token, any user after the first user can't login to Spotify. Here is some initial setup: sp_oauth = oauth2

Having trouble using cached tokens with Spotipy for Spotify?

拥有回忆 提交于 2021-02-07 04:17:11
问题 I'm trying to use Spotipy to access a user's Spotify library but am running into a bit of trouble. For background, I'm using Flask, SQLAlchemy, and Flask-Login. I looked off of this tutorial on github to get started, but this one doesn't quite work for me because if you use a cache, all users can access the playlist of the user whose token is cached, and since there is a cached token, any user after the first user can't login to Spotify. Here is some initial setup: sp_oauth = oauth2

Efficiently batching Spark dataframes to call an API

谁说胖子不能爱 提交于 2021-01-28 10:52:55
问题 I am fairly new to Spark and I'm trying to call the Spotify API using Spotipy. I have a list of artist ids which can be used to fetch artist info. The Spotify API allows for batch calls up to 50 ids at once. I load the artist ids from a MySQL database and store them in a dataframe. My problem now is that I do not know how to efficiently batch that dataframe into pieces of 50 or less rows. In the example below I'm turning the dataframe into a regular Python list from which I can call the API

Spotipy on Django authorization without copy-paste to console

我与影子孤独终老i 提交于 2021-01-28 09:00:00
问题 I have a Django site in which I want to use spotipy to look for statistics of the song like popularity and views. I have this code right now: import spotipy import spotipy.util as util #luxury import json import webbrowser username = 'dgrqnco2rx8hdu58kv9if9eho' scope = 'user-read-private user-read-playback-state user-modify-playback-state' token = util.prompt_for_user_token(username, scope, client_id='08bb526962574a46b359bffc56048147', client_secret='bf6d4184c8ae40aca207714e02153bad',

Storing Spotify token in flask session using spotipy?

佐手、 提交于 2020-06-10 05:13:52
问题 I may have a bad understanding of how the flask session works, but I am trying to generate a Spotify API access token using SpotiPY with the Authorization Code Flow, and store it in Flask's session storage. The program doesn't seem to be able to store it, and therefore later runs in to an error when trying to call it. Here is a visual explanation with images and captions: https://imgur.com/a/KiYZFiQ Here is the main server script: from flask import Flask, render_template, redirect, request,

Spotify API authorization + token key error - python3

僤鯓⒐⒋嵵緔 提交于 2020-04-18 05:35:16
问题 I'm running into this issue where with my script and I'm a bit stumped. I've been running this script with no problems for the past few weeks and now I'm getting a KeyError for the token. Here's my code: # IMPORTS import os import re import requests import json import numpy as np import pandas as pd import time from pprint import pprint as pp import datetime as dt import sys import spotipy from spotipy.oauth2 import SpotifyClientCredentials acc_path = "../../access/" sys.path.append(acc_path)

Spotipy Refreshing a token with authorization code flow

∥☆過路亽.° 提交于 2019-12-21 17:32:05
问题 I have a long-running script using spotipy. After an hour (per the Spotify API), my access token expires. I am catching this successfully, but I don't know where to go from there in regards to actually refreshing the token. I am using the authorization code flow, not client credentials. Here's how I authorize: token = util.prompt_for_user_token(username,scope=scopes,client_id=client_id,client_secret=client_secret, redirect_uri=redirect_uri) sp = spotipy.Spotify(auth=token) All refresh

Spotipy: How to read more than 100 tracks from a playlist

做~自己de王妃 提交于 2019-12-21 05:35:40
问题 I'm trying to pull all tracks in a certain playlist using the Spotipy library for python. The user_playlist_tracks function is limited to 100 tracks, regardless of the parameter limit. The Spotipy documentation describes it as: user_playlist_tracks(user, playlist_id=None, fields=None, limit=100, offset=0, market=None) Get full details of the tracks of a playlist owned by a user. Parameters: user the id of the user playlist_id the id of the playlist fields which fields to return limit the

Spotipy - get track ids from track names

房东的猫 提交于 2019-12-10 22:38:47
问题 Usually, spotipy requires track IDs as parameters to be passed, in order to return track names. Say I have two lists, not obtained from the Spotify API: artists [u'Moses Sumney', u'Cherry Glazerr', u'Danny Brown', u'NxWorries'] and their respective songs: tracks [u'Lonely World', u"Told You I'd Be With the Guys", u'Really Doe [ft. Kendrick Lamar, Ab-Soul, and Earl Sweatshirt]', u'Lyk Dis'] Is it possible to do it the other way around and get track IDs? 回答1: Spotipy.search() is what you are