Collector Module for Spotify National Trending Analysis
Project description
Spotichart
Collector Module for Spotify National Trending Analysis
Introduction
The Spotichart module makes it easy for data scientist and programmers get the features from the trending songs on Spotify. You can define period of time and a region and get the main characteristics of the top songs.
Documentation
The oficial documentations is available at: Read The Docs
Installation
$ pip install spotichart
Requirements
- Python >= 3.6
- Spotify Web API Access Token, you can request yours here and click on
GET TOKEN
. Then copy the token on theOAuth Token
field. - (Optional) Genius Web API Access Token. From the official docs page you can just select
Authenticate wih the Docs App To Try
, and copy theAuthorization Bearer
provided after logging in.
Synopsis
Usage
Just to get the audio features, given a date (or period) and a region
import spotichart
spotify_token = 'YOUR-ACCESS-TOKEN-FROM-THE-WEB-API'
chart = spotichart.generate_top_chart(spotify_token, start='2019-01-01', end='2019-10-13', region='mx')
To additionally retrieve each song's lyrics, Genius ID an auto-detect the language, you can do as well:
import spotichart
spotify_token = 'YOUR-SPOTIFY-ACCESS-TOKEN-FROM-THE-WEB-API'
genius_token = 'YOUR-GENIUS-ACCESS-TOKEN-FROM-THE-WEB-API'
chart = spotichart.generate_top_chart(spotify_token, start='2019-01-01',
end='2019-10-13', region='mx', sleep=0.5)
chart_with_lyrics = spotichart.get_lyrics_from_chart(genius_token, chart, sleep=0.1)
Note: Since these functions imply web requests to get the data, the sleep
parameter is meant to make the algorithm rest and avoid the server to refuse the requests. By default sleep
is set to 1 second.
The DataFrame
A pandas.DataFrame
will be generated with the data of interest:
>>> chart
Position Track Name Artist Streams ... speechiness tempo time_signature valence
0 1 Calma - Remix Pedro Capó 737894 ... 0.0524 126.899 4 0.761
1 2 Adan y Eva Paulo Londra 415066 ... 0.3360 171.993 4 0.720
2 3 Taki Taki (with Selena Gomez, Ozuna & Cardi B) DJ Snake 409061 ... 0.2290 95.948 4 0.591
3 4 MIA (feat. Drake) Bad Bunny 377855 ... 0.0621 97.062 4 0.158
4 5 A Través Del Vaso Grupo Arranke 346975 ... 0.0297 143.851 3 0.920
... ... ... ... ... ... ... ... ... ...
14295 46 Con Calma Daddy Yankee 141397 ... 0.0593 93.989 4 0.656
14296 47 La Escuela No Me Gustó Adriel Favela 139350 ... 0.0371 112.548 4 0.844
14297 48 De Los Besos Que Te Di Christian Nodal 139294 ... 0.0422 195.593 4 0.709
14298 49 Pa Mí - Remix Dalex 137812 ... 0.2200 170.018 4 0.727
14299 50 Circles Post Malone 131109 ... 0.0395 120.042 4 0.5
[14300 rows x 20 columns]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file spotichart-1.0.0.tar.gz
.
File metadata
- Download URL: spotichart-1.0.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33f49a2c3e5087d0ae8242ab92f2fe4724c10228249ed5e93b9f034a653bf22a |
|
MD5 | 2038b7ce0397f9d9166a20e4413f3fae |
|
BLAKE2b-256 | e2616a9fc88af96f2e48cb6c1fd2e961f56ccba77fe871f7fe52308d94a1679d |
File details
Details for the file spotichart-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: spotichart-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e344f2a365a3ab88c668853dce668fac738016586b831f3329ca6a9fed356d6c |
|
MD5 | b1eefe7651d0f986cd756b56a14f3a06 |
|
BLAKE2b-256 | cd6e660d424ce0de17650607f9428c84cc9a0eef6ebf42f665e9ce27e9cf4b2e |