Python API for vgmusic.com.
Project description
vgmusic.py
(unofficial) Python API for VGMusic. This project is in no way affiliated with or sponsered by Mike Newman or any of the staff at VGMusic.
Usage
Thoughout these examples, we will be using the API
object as the api:
import vgmusic
api = vgmusic.API()
It is recommended to close it once you are done:
# do something here...
api.close()
The best way is to use a context manager, a.k.a with
statement:
with vgmusic.API() as api:
# do something here
Note that the API is lazy: It will only retrieve data for a console/system the first time it is queried for it.
To override this behaviour, use force_cache
(see Module Documentation).
Backends
The API has two backends: dictionary-like (access from Python code) and a REST-based web interface (through Flask, from elsewhere). You can also use it from the command-line (WIP).
Dictionary/Key
To query songs, you have to provide the name of the system/catagory and the game title:
songs = api["Sony PlayStation 4"]["titles"]["Persona 5"]
You can manipulate the API using standard dictionary methods:
# list all titles for a system
titles = list(api["Nintendo Switch"].keys()) # ['Sonic Mania'], as of 5/1/2021
# count how many songs in total
total = sum(len(songs) for songs in api["Nintendo Switch"]["titles"].values()) # 12, as of 5/1/2021
Anything you can do with a dictionary, it's basically possible with this API.
REST/Flask
NOTE: This is WIP, it has not been finished yet. Make sure you have installed the Flask extension:
pip install vgmusic[REST]
License
MIT.
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
Hashes for vgmusic-0.1.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bdfea99637fb6a9c702b0e8d51552370d49ec0479617b218e7dbd2a6aae8ca8 |
|
MD5 | 6dcdfb33b74ab2395005d18d768cb25a |
|
BLAKE2b-256 | d20661e7f74701e78d62737d0a66ec661d95bfef1288b677b0be77807a973338 |