Skip to main content

A Python package that allows users to gather advanced artist statistics from Spotify

Project description

log github events log github events multiple versions

Python Package Exercise

An exercise to create a Python package, build it, test it, distribute it, and use it. See instructions for details.

Package Description

The package pytify_stats is a Python package that runs basic stats gathered from the Spotify API. It can currently get stats such as artist information, track information, and an artist's top ten tracks.

Function Documentation

def authenticate(self):

    Authenticates the Spotify user to be able to use this package.
    Return: access_token = Token that allows you to access the Spotify data.

def search(self, headers,name,keyword):

    Searches the Spotify database for the queried item 
    Inputs: headers = Headers for the HTTP response, name = the name of the item you want to search, keyword = the type of item.
    Return: artist_id = the id of the item you are looking for

def get_top_ten(self, artist):

    Retrieves the top ten songs of an artist.
    Input: artist = The artist you are searching for
    Return: retStr = the string that contains an enumerated list of the artist's top 10 songs.

def get_song(self, song):

    Retrives the song from the query.
    Input: song = The song to look for.
    Return: An array containing the name of the song and its length in milliseconds.

def analyze(self, song):

    Returns an analysis of a song and its key information.
    Input: song = The song to be analyzed.
    Return: feature_list = The list of features, such as key, tempo, etc. that the song contains.'

def search_for_artist(self, artist_name):

    Search for an artist by name.
    Input: artist_name = the name of the artist to search for.
    Return: dict = About the artist.

def get_artist_albums(self, artist):

    Retrieve the albums of a given artist.
    Input: artist = The artist to search for.
    Return: album_names = The list of albums the artist has released.

How to Use

Here is how to set it up:

  1. Run this code in the terminal:
pip install pytify-stats==0.0.9
  1. Import it in your python file:
from pytify_stats import client
  1. Create a new account or log in here. Go to the dashboard, create an app and retrieve your new ID and SECRET

  2. Authenicate using the Client class

The example below demonstrates how to do this:

from pytify_stats import client

spy = client.Client(CLIENT_ID, CLIENT_SECRET)

top_ten = spy.get_top_ten("J. Cole")

song = spy.get_song("She Knows")

album = spy.get_artist_albums("J. cole")

print(top_ten)
print(song)
print(album)

Put your client_id and client_secret you've recieved from Spotify in place of the parameters of the Client class

How to Contribute

  1. Download the source code and open it on a code editor

  2. Install pipenv and install the following:

pipenv install requests pipenv install python-dotenv pipenv install pytest

  1. Make changes and run unit test for it

  2. Push changes onto a new branch on GitHub

  3. Make a pull request and wait for a review. If accpeted, the branches will be merged and the new code will be uploaded to PyPi

Pypi Package Link

https://pypi.org/project/pytify-stats/0.0.9/

Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytify_stats-0.0.10.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytify_stats-0.0.10-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file pytify_stats-0.0.10.tar.gz.

File metadata

  • Download URL: pytify_stats-0.0.10.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pytify_stats-0.0.10.tar.gz
Algorithm Hash digest
SHA256 3db0ecd1f18d51138a6b2e407fa750930f3be0fc8efdea7dada21b224e9972f0
MD5 a5c76ab41a572d68981a98a7337d1e3c
BLAKE2b-256 07d99c04e4174b422c59f86be309c6bff6571115d25820daa37ce9f25769d514

See more details on using hashes here.

File details

Details for the file pytify_stats-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: pytify_stats-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pytify_stats-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 bc67b07b9401773bda44871202afd5a255af11e21ac783c5604ba4a574cfd8d8
MD5 c9ca0962d28efffbe2262a14639bcaa3
BLAKE2b-256 395c9ff01b8ed3bad873f7ac2366ac73b5076d8f7180f04ac2dd37d31ae9d84a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page