按流派获取前 100 名艺术家 Spotify API
Get top 100 artists by genre Spotify API
我正在做一个关于数据分析的大学项目,特别是我正在尝试分析大流行之前和期间 Spotify 上听众的行为。
到目前为止,我每周下载前 200 名,并使用一个简单的脚本按州分组,您可以在此处找到数据:https://spotifycharts.com/regional
我还使用 Spotify API.
设法使用前 200 名检索每首歌曲并提取特征、发布日期等...
我读了这篇文章:Spotify genre trends during pandemic 这很有趣。我想效仿他们在文章中所做的事情。例如,他们能够按流派检索排名前 100 位的艺术家。
我一直在查看 Spotify API 和 Spotify 可用数据集,但找不到实现我目标的解决方案。
有没有办法检索给定时期内按流派排名前 100 的艺术家?
这是我用来每周下载前 200 名的代码,但它对我的目标没有用:
import requests
import os
import time
path = os.getcwd()
states = ['br','it','gb','de','us','fr','es']
for state in states:
dir_path = os.path.join(path, state)
os.mkdir(dir_path)
for week in weeks:
csv_url = 'https://spotifycharts.com/regional/'+state+'/weekly/'+week+'/download'
req = requests.get(csv_url)
#print(req.status_code)
time.sleep(0.5)
if req.status_code == 200:
url_content = req.content
csv = ''+state+'_'+week+'.csv'
csv_path = os.path.join(dir_path, csv)
csv_file = open(csv_path, 'wb')
csv_file.write(url_content)
csv_file.close()
else:
print('error with the following file:'+str(csv_url))
其中weeks
是一个字符串列表,其中包含请求中要下载的文件的文件名(之前用其他代码生成的,为清楚起见省略),例如:
2016-12-23--2016-12-30
2016-12-30--2017-01-06
2017-01-06--2017-01-13
2017-01-13--2017-01-20
2017-01-20--2017-01-27
2017-01-27--2017-02-03
2017-02-03--2017-02-10
2017-02-10--2017-02-17
博客指出
we collected MLs data for the Top 100 artists of each genre, ranked by
Spotify Follower count.
无法直接从官方获取图表 Spotify Web API。 Chartmetric,撰写博客的公司可能有一个他们不会透露的抓取算法,因为这是他们出售这些统计数据的商业模式。
Spotify Web API Artists endpoint 为您提供了艺术家的 genres
(以及他们的粉丝数量),因此如果您从其他来源(带有他们的 Spotify ID)获得艺术家排行榜,您可能会提取每个艺术家流派和 re-rank 每个流派中的艺术家。这些类型可能需要 re-classified 根据您的需要。
此 repo uses the Search endpoint 仅将一个数据范围作为主要查询参数(此处:year:2000-2014
),并创建一个包含最受关注艺术家及其相应 Spotify ID 的数据库。这个 hack 似乎不再有效,因为当我尝试使用自己的 auth Token 时不一定会获得排名结果。
然后要获取每月听众 (ML),博客中提到 the Spotify for Artist page。其中指出:
Monthly listeners are unique listeners who play your music during a
28-day period. This stat updates every day, and appears on both your
artist profile on Spotify
同样,Spotify API 上没有这个数字,因此您要么需要创建一个艺术家页面并使用比较选项为其他艺术家获取它,要么每天在常规 Spotify 平台。
我正在做一个关于数据分析的大学项目,特别是我正在尝试分析大流行之前和期间 Spotify 上听众的行为。
到目前为止,我每周下载前 200 名,并使用一个简单的脚本按州分组,您可以在此处找到数据:https://spotifycharts.com/regional
我还使用 Spotify API.
设法使用前 200 名检索每首歌曲并提取特征、发布日期等...我读了这篇文章:Spotify genre trends during pandemic 这很有趣。我想效仿他们在文章中所做的事情。例如,他们能够按流派检索排名前 100 位的艺术家。
我一直在查看 Spotify API 和 Spotify 可用数据集,但找不到实现我目标的解决方案。
有没有办法检索给定时期内按流派排名前 100 的艺术家?
这是我用来每周下载前 200 名的代码,但它对我的目标没有用:
import requests
import os
import time
path = os.getcwd()
states = ['br','it','gb','de','us','fr','es']
for state in states:
dir_path = os.path.join(path, state)
os.mkdir(dir_path)
for week in weeks:
csv_url = 'https://spotifycharts.com/regional/'+state+'/weekly/'+week+'/download'
req = requests.get(csv_url)
#print(req.status_code)
time.sleep(0.5)
if req.status_code == 200:
url_content = req.content
csv = ''+state+'_'+week+'.csv'
csv_path = os.path.join(dir_path, csv)
csv_file = open(csv_path, 'wb')
csv_file.write(url_content)
csv_file.close()
else:
print('error with the following file:'+str(csv_url))
其中weeks
是一个字符串列表,其中包含请求中要下载的文件的文件名(之前用其他代码生成的,为清楚起见省略),例如:
2016-12-23--2016-12-30
2016-12-30--2017-01-06
2017-01-06--2017-01-13
2017-01-13--2017-01-20
2017-01-20--2017-01-27
2017-01-27--2017-02-03
2017-02-03--2017-02-10
2017-02-10--2017-02-17
博客指出
we collected MLs data for the Top 100 artists of each genre, ranked by Spotify Follower count.
无法直接从官方获取图表 Spotify Web API。 Chartmetric,撰写博客的公司可能有一个他们不会透露的抓取算法,因为这是他们出售这些统计数据的商业模式。
Spotify Web API Artists endpoint 为您提供了艺术家的 genres
(以及他们的粉丝数量),因此如果您从其他来源(带有他们的 Spotify ID)获得艺术家排行榜,您可能会提取每个艺术家流派和 re-rank 每个流派中的艺术家。这些类型可能需要 re-classified 根据您的需要。
此 repo uses the Search endpoint 仅将一个数据范围作为主要查询参数(此处:year:2000-2014
),并创建一个包含最受关注艺术家及其相应 Spotify ID 的数据库。这个 hack 似乎不再有效,因为当我尝试使用自己的 auth Token 时不一定会获得排名结果。
然后要获取每月听众 (ML),博客中提到 the Spotify for Artist page。其中指出:
Monthly listeners are unique listeners who play your music during a 28-day period. This stat updates every day, and appears on both your artist profile on Spotify
同样,Spotify API 上没有这个数字,因此您要么需要创建一个艺术家页面并使用比较选项为其他艺术家获取它,要么每天在常规 Spotify 平台。