An asynchronous client for fetching lyrical discographies of music artists.
Project description
Melodic
Melodic is a Python client for fetching artist lyrical discographies. This library provides an asynchronous interface to retrieve complete artist discographies, including album and track metadata including lyrics, with built-in database storage, proxy support, and great error handling.
Features
- Complete Discography Fetching: Retrieves full discography metadata and lyrics for any given artist.
- Asynchronous Interface: Built with modern
async withpatterns for efficient, safe I/O operations. - Database Storage: Optional built-in storage system for organizing artist, album, and track data.
- Proxy Support: Easily pass a list of
HTTPorSOCKSproxies to route requests through. - Robust Error Handling: Comprehensive error handling and logging for reliable operations.
- Modern Development Tools: Includes ruff, mypy, pre-commit, and commitizen for high-quality code.
Installation
From PyPI (Recommended)
pip install melodic
From Source
You can install melodic by cloning the repository directly or using pre-built wheel files.
Prerequisites: This project requires uv for dependency management.
Option 1: Clone and Build
-
Clone the repository:
git clone https://github.com/filming/melodic.git cd melodic
-
Install the project and its dependencies:
uv sync
Option 2: Install from Pre-built Wheels
Pre-built wheel files are automatically generated and attached to each GitHub release. You can download and install them directly:
- Go to the GitHub releases page
- Download the
.whlfile from the latest release - Install using pip:
pip install path/to/downloaded/melodic-*.whl
Usage
Here's a basic example of how to use melodic to fetch the discography of an artist:
import asyncio
from melodic import Melodic
async def main():
async with Melodic(storage_path="lyrics.db") as melodic:
discography = await melodic.get_discography("Taylor Swift")
if __name__ == "__main__":
asyncio.run(main())
This script will fetch the entire lyrical discography for Taylor Swift and will return it directly to the calling line in the form of a list of Track objects. It will also store the discography into a lyrics.db SQLite database if storage_path is provided.
Configuration
Configuration is managed through the Melodic client during initialization.
-
storage_path:str | Path | None(Default:None)- The file path where the SQLite database will be stored. If
None, the database will be created in memory and will not be saved to disk.
- The file path where the SQLite database will be stored. If
-
proxies:list[str] | None(Default:None)- A list of proxy strings (e.g.,
["http://user:pass@host:port"]). If provided, all network requests will be rotated through these proxies.
- A list of proxy strings (e.g.,
-
max_concurrent_requests:int(Default:10)- The maximum number of concurrent
aiohttprequests to make at one time.
- The maximum number of concurrent
-
max_retry_attempts:int(Default: 10)- The maximum amount of times to retry a failed fetch.
-
request_delay:float(Default:3.5)- The cooldown period (in seconds) for a proxy after it has been used. This helps prevent rate-limiting.
-
user_agent:str | None(Default:None)- A custom User-Agent string for network requests. If
None, a defaultaiohttpUser-Agent is used.
- A custom User-Agent string for network requests. If
-
batch_save_size:int(Default:20)- The number of tracks to accumulate in memory before saving them to the database in a single transaction.
Development
This project uses modern Python development tools:
- uv for dependency management
- ruff for linting and formatting
- mypy for type checking
- pre-commit for git hooks
- commitizen for conventional commits
Setting up for development:
-
Clone the repository:
git clone https://github.com/filming/melodic.git cd melodic
-
Install dependencies (including dev tools):
uv sync --extra dev
-
Set up pre-commit hooks:
uv run pre-commit install
-
Start developing!
Dependencies
All project dependencies are managed via pyproject.toml and use Python 3.10+.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions, bug reports, and feature requests are welcome! Please open an issue or submit a pull request on GitHub.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file melodic-3.0.0.tar.gz.
File metadata
- Download URL: melodic-3.0.0.tar.gz
- Upload date:
- Size: 110.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9335939ce5868ad9efaaba3df23bd4a68aea9af7bc71458a380a6a0729a5fabf
|
|
| MD5 |
297bfe271bdcac29533cfb6d4115e49e
|
|
| BLAKE2b-256 |
979444411937d5c54e54b28eadc8e3be09758ca6b9ba504f5971318dcacebb3e
|
Provenance
The following attestation bundles were made for melodic-3.0.0.tar.gz:
Publisher:
release.yml on filming/melodic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
melodic-3.0.0.tar.gz -
Subject digest:
9335939ce5868ad9efaaba3df23bd4a68aea9af7bc71458a380a6a0729a5fabf - Sigstore transparency entry: 520240851
- Sigstore integration time:
-
Permalink:
filming/melodic@82625c8010850fbef4f85fe108c9179dfe171c01 -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/filming
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@82625c8010850fbef4f85fe108c9179dfe171c01 -
Trigger Event:
push
-
Statement type:
File details
Details for the file melodic-3.0.0-py3-none-any.whl.
File metadata
- Download URL: melodic-3.0.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4425dab14283dbad44c50a40eddc6cc90c3cf1e6c49ae1ef1d4f3dc60703367c
|
|
| MD5 |
b916ed45f3fce7be15cb9f4de11a0c23
|
|
| BLAKE2b-256 |
982f22d13e7c939e5cb675fb5a25f6643dd7f710812e1f3122209e9de64d6498
|
Provenance
The following attestation bundles were made for melodic-3.0.0-py3-none-any.whl:
Publisher:
release.yml on filming/melodic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
melodic-3.0.0-py3-none-any.whl -
Subject digest:
4425dab14283dbad44c50a40eddc6cc90c3cf1e6c49ae1ef1d4f3dc60703367c - Sigstore transparency entry: 520240924
- Sigstore integration time:
-
Permalink:
filming/melodic@82625c8010850fbef4f85fe108c9179dfe171c01 -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/filming
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@82625c8010850fbef4f85fe108c9179dfe171c01 -
Trigger Event:
push
-
Statement type: