Open jramosdc opened 6 years ago
@JaviGago Create a user in Spotify Developer and get your SECRETS
import spotipy
import spotipy.oauth2 as oauth2
credentials = oauth2.SpotifyClientCredentials(
client_id="xxxxxxxxx",
client_secret= "42xxxxxx")
token = credentials.get_access_token()
birdy_uri = 'spotify:artist:2WX2uTcsvV5OnS0inACecP'
spotify = spotipy.Spotify(auth=token)
results = spotify.artist_albums(birdy_uri, album_type='album')
albums = results['items']
while results['next']:
results = spotify.next(results)
albums.extend(results['items'])
for album in albums:
print(album['name'])
Con esto ya podeis empezar a trastear, pero usas vuestras credenciales
import requests
headers = {
'Authorization': 'Bearer BQD14NPBhoYseCefL6OzuBNTCr05wKRdoswnwMj7eYIq1hzqloOdQ4dnr1PxCgAccobf7LouLz2Zy_sc-3BLpICA5JkmiaqU9suhet7Rv2OJCmrPCH412PqGW96peEmTHEfbJgJL9A'
}
params = {
'q': 'La Llamada',
'type': 'track',
'market': 'es',
'limit': '1',
}
response = requests.get('https://api.spotify.com/v1/search', headers=headers, params=params)
results=response.json()
r=results['tracks']['items']
print(r[0]['id'])
print(r[0]['name'])
print(r[0]['popularity'])
Mejor aún
import requests
import spotipy
import spotipy.oauth2 as oauth2
import pandas as pd
credentials = oauth2.SpotifyClientCredentials(
client_id="YOUR API ID",
client_secret= "YOUR SECRET")
token = credentials.get_access_token()
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer '+ token
}
df = pd.read_csv("hoja.csv")
for index, row in df.iterrows():
q = row['q']
params = {'q': q, 'type': 'track', 'market': 'es', 'limit': '1'}
response = requests.get('https://api.spotify.com/v1/search', headers=headers, params=params)
results=response.json()
r=results['tracks']['items']
print(r[0]['artists'][0]['name'])
print(r[0]['name'])
print(r[0]['id'])
print(r[0]['popularity'])
##params3 = {'id':'4aWmUDTfIPGksMNLV2rQP2' }
@Aitorbp @delrio27 Este código os puede ayudar mucho. Id probando y trabajad la manera de escribirlo en un csv con python
Check this out! https://plot.ly/~jairobbva/12/ @delrio27
@jllopc cual es tu email?
@jramosdc mi correo es joanllc94@gmail.com
https://github.com/plamere/spotipy