Name | melodic JSON |
Version |
2.2.0
JSON |
| download |
home_page | None |
Summary | A Python client for fetching artist lyrical discographies. |
upload_time | 2025-08-15 05:21:23 |
maintainer | None |
docs_url | None |
author | Filming |
requires_python | >=3.10 |
license | MIT License
Copyright (c) 2025 Filming
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
artist-data
async
azlyrics
database
discography
lyrics
music
python
web-scraping
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Melodic
<p align="center">
<a href="https://pypi.org/project/melodic/"><img alt="PyPI" src="https://img.shields.io/pypi/v/melodic?color=blue"></a>
<a href="https://pypi.org/project/melodic/"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/melodic"></a>
<a href="https://opensource.org/licenses/MIT"><img alt="License" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
</p>
Melodic is a Python client for fetching artist lyrical discographies. This library provides an asynchronous interface to retrieve complete artist discographies, including album metadata and song lyrics, with built-in database storage, proxy support, and robust error handling.
---
## Features
- **Complete Discography Fetching:** Retrieves full album and track listings for any given artist.
- **Asynchronous Interface:** Built with modern `async with` patterns for efficient, safe I/O operations.
- **Database Storage:** Optional built-in storage system for organizing artist, album, and track metadata.
- **Proxy Support:** Easily pass a list of proxies to route requests through.
- **Robust Error Handling:** Comprehensive error handling and logging for reliable operation.
- **Modern Development Tools:** Includes ruff, mypy, pre-commit, and commitizen for high-quality code.
---
## Installation
### From PyPI (Recommended)
```bash
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](https://github.com/astral-sh/uv) for dependency management.
#### Option 1: Clone and Build
1. Clone the repository:
```bash
git clone https://github.com/filming/melodic.git
cd melodic
```
2. Install the project and its dependencies:
```bash
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:
1. Go to the [GitHub releases page](https://github.com/filming/melodic/releases)
2. Download the `.whl` file from the latest release
3. Install using pip:
```bash
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:
```python
import asyncio
from melodic import Melodic, ClientConfig
async def main():
# Configure the client
config = ClientConfig(
storage_path="lyrics.db", # Optional: Path to save the database
max_concurrent_requests=20, # Optional: Max concurrent requests
request_delay=2.0, # Optional: Delay between requests for a proxy
)
# Use the client as an asynchronous context manager
async with Melodic(config) as melodic:
# Fetch the discography for an artist
await melodic.get_discography("Taylor Swift")
if __name__ == "__main__":
asyncio.run(main())
```
This script will fetch all albums and songs for Taylor Swift, retrieve the lyrics for each song, and store everything in a `lyrics.db` SQLite database if `storage_path` is provided.
<details>
<summary>Example Output</summary>
```
[2025-08-15 01:07:45] root INFO [setup_logging:42] Logging configured. File level: None, Console level: DEBUG
[2025-08-15 01:07:45] melodic.client INFO [__init__:52] Melodic instance has been initialized.
[2025-08-15 01:07:45] melodic.network.manager DEBUG [start_session:79] aiohttp.ClientSession started.
[2025-08-15 01:07:45] melodic.storage.sqlite DEBUG [initialize:39] SQLite database initialized at devarea/lyrics.db.
[2025-08-15 01:07:45] melodic.client DEBUG [__aenter__:65] Melodic context entered and resources initialized.
[2025-08-15 01:07:45] melodic.client INFO [get_discography:101] Fetching discography for artist: 'taYLor SwiFt'
[2025-08-15 01:07:45] melodic.network.manager DEBUG [get:142] Requesting URL: https://www.azlyrics.com/t/taylorswift.html via proxy: http://45.201.11.3:3129
[2025-08-15 01:07:45] melodic.client INFO [get_discography:125] Processing song batch 1-20 of 468...
...
...
[2025-08-15 01:08:22] melodic.storage.sqlite INFO [save_songs:74] Attempted to save 7 songs to the database.
[2025-08-15 01:08:22] melodic.client INFO [get_discography:144] Successfully fetched 396/468 song lyrics for 'taYLor SwiFt'.
[2025-08-15 01:08:22] melodic.network.manager DEBUG [close_session:86] aiohttp.ClientSession closed.
[2025-08-15 01:08:22] melodic.storage.sqlite DEBUG [close:46] SQLite database connection closed.
[2025-08-15 01:08:22] melodic.client DEBUG [__aexit__:79] Melodic context exited and resources closed.
```
</details>
---
## Configuration
Configuration is managed through the `ClientConfig` dataclass, which is passed to the `Melodic` client upon 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.
- **`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.
- **`max_concurrent_requests`**: `int` (Default: `10`)
- The maximum number of concurrent `aiohttp` requests to make at one time.
- **`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 default `aiohttp` User-Agent is used.
- **`batch_save_size`**: `int` (Default: `20`)
- The number of songs to accumulate in memory before saving them to the database in a single transaction.
---
## Development
This project uses modern Python development tools:
- **[uv](https://github.com/astral-sh/uv)** for dependency management
- **[ruff](https://github.com/astral-sh/ruff)** for linting and formatting
- **[mypy](https://mypy.readthedocs.io/)** for type checking
- **[pre-commit](https://pre-commit.com/)** for git hooks
- **[commitizen](https://commitizen-tools.github.io/commitizen/)** for conventional commits
### Setting up for development:
1. Clone the repository:
```bash
git clone https://github.com/filming/melodic.git
cd melodic
```
2. Install dependencies (including dev tools):
```bash
uv sync --extra dev
```
3. Set up pre-commit hooks:
```bash
uv run pre-commit install
```
4. Start developing!
---
## Dependencies
All project dependencies are managed via [`pyproject.toml`](pyproject.toml) and use Python 3.10+.
---
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
## Contributing
Contributions, bug reports, and feature requests are welcome!
Please open an issue or submit a pull request on [GitHub](https://github.com/filming/melodic).
Raw data
{
"_id": null,
"home_page": null,
"name": "melodic",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "artist-data, async, azlyrics, database, discography, lyrics, music, python, web-scraping",
"author": "Filming",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/77/e0/810d5e3d145f82e34066b7199bd8e3f138a1f4446e24a637d8d536505d49/melodic-2.2.0.tar.gz",
"platform": null,
"description": "# Melodic\n\n<p align=\"center\">\n <a href=\"https://pypi.org/project/melodic/\"><img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/melodic?color=blue\"></a>\n <a href=\"https://pypi.org/project/melodic/\"><img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/melodic\"></a>\n <a href=\"https://opensource.org/licenses/MIT\"><img alt=\"License\" src=\"https://img.shields.io/badge/License-MIT-yellow.svg\"></a>\n</p>\n\nMelodic is a Python client for fetching artist lyrical discographies. This library provides an asynchronous interface to retrieve complete artist discographies, including album metadata and song lyrics, with built-in database storage, proxy support, and robust error handling.\n\n---\n\n## Features\n\n- **Complete Discography Fetching:** Retrieves full album and track listings for any given artist.\n- **Asynchronous Interface:** Built with modern `async with` patterns for efficient, safe I/O operations.\n- **Database Storage:** Optional built-in storage system for organizing artist, album, and track metadata.\n- **Proxy Support:** Easily pass a list of proxies to route requests through.\n- **Robust Error Handling:** Comprehensive error handling and logging for reliable operation.\n- **Modern Development Tools:** Includes ruff, mypy, pre-commit, and commitizen for high-quality code.\n\n---\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\npip install melodic\n```\n\n### From Source\n\nYou can install melodic by cloning the repository directly or using pre-built wheel files.\n\n**Prerequisites:** This project requires [uv](https://github.com/astral-sh/uv) for dependency management.\n\n#### Option 1: Clone and Build\n\n1. Clone the repository:\n ```bash\n git clone https://github.com/filming/melodic.git\n cd melodic\n ```\n\n2. Install the project and its dependencies:\n ```bash\n uv sync\n ```\n\n#### Option 2: Install from Pre-built Wheels\n\nPre-built wheel files are automatically generated and attached to each GitHub release. You can download and install them directly:\n\n1. Go to the [GitHub releases page](https://github.com/filming/melodic/releases)\n2. Download the `.whl` file from the latest release\n3. Install using pip:\n ```bash\n pip install path/to/downloaded/melodic-*.whl\n ```\n\n---\n\n## Usage\n\nHere's a basic example of how to use `melodic` to fetch the discography of an artist:\n\n```python\nimport asyncio\nfrom melodic import Melodic, ClientConfig\n\nasync def main():\n # Configure the client\n config = ClientConfig(\n storage_path=\"lyrics.db\", # Optional: Path to save the database\n max_concurrent_requests=20, # Optional: Max concurrent requests\n request_delay=2.0, # Optional: Delay between requests for a proxy\n )\n\n # Use the client as an asynchronous context manager\n async with Melodic(config) as melodic:\n # Fetch the discography for an artist\n await melodic.get_discography(\"Taylor Swift\")\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n```\n\nThis script will fetch all albums and songs for Taylor Swift, retrieve the lyrics for each song, and store everything in a `lyrics.db` SQLite database if `storage_path` is provided.\n\n<details>\n<summary>Example Output</summary>\n\n```\n[2025-08-15 01:07:45] root INFO [setup_logging:42] Logging configured. File level: None, Console level: DEBUG\n[2025-08-15 01:07:45] melodic.client INFO [__init__:52] Melodic instance has been initialized.\n[2025-08-15 01:07:45] melodic.network.manager DEBUG [start_session:79] aiohttp.ClientSession started.\n[2025-08-15 01:07:45] melodic.storage.sqlite DEBUG [initialize:39] SQLite database initialized at devarea/lyrics.db.\n[2025-08-15 01:07:45] melodic.client DEBUG [__aenter__:65] Melodic context entered and resources initialized.\n[2025-08-15 01:07:45] melodic.client INFO [get_discography:101] Fetching discography for artist: 'taYLor SwiFt'\n[2025-08-15 01:07:45] melodic.network.manager DEBUG [get:142] Requesting URL: https://www.azlyrics.com/t/taylorswift.html via proxy: http://45.201.11.3:3129\n[2025-08-15 01:07:45] melodic.client INFO [get_discography:125] Processing song batch 1-20 of 468...\n...\n...\n[2025-08-15 01:08:22] melodic.storage.sqlite INFO [save_songs:74] Attempted to save 7 songs to the database.\n[2025-08-15 01:08:22] melodic.client INFO [get_discography:144] Successfully fetched 396/468 song lyrics for 'taYLor SwiFt'.\n[2025-08-15 01:08:22] melodic.network.manager DEBUG [close_session:86] aiohttp.ClientSession closed.\n[2025-08-15 01:08:22] melodic.storage.sqlite DEBUG [close:46] SQLite database connection closed.\n[2025-08-15 01:08:22] melodic.client DEBUG [__aexit__:79] Melodic context exited and resources closed.\n```\n\n</details>\n\n---\n\n## Configuration\n\nConfiguration is managed through the `ClientConfig` dataclass, which is passed to the `Melodic` client upon initialization.\n\n- **`storage_path`**: `str | Path | None` (Default: `None`)\n - 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.\n\n- **`proxies`**: `list[str] | None` (Default: `None`)\n - A list of proxy strings (e.g., `[\"http://user:pass@host:port\"]`). If provided, all network requests will be rotated through these proxies.\n\n- **`max_concurrent_requests`**: `int` (Default: `10`)\n - The maximum number of concurrent `aiohttp` requests to make at one time.\n\n- **`request_delay`**: `float` (Default: `3.5`)\n - The cooldown period (in seconds) for a proxy after it has been used. This helps prevent rate-limiting.\n\n- **`user_agent`**: `str | None` (Default: `None`)\n - A custom User-Agent string for network requests. If `None`, a default `aiohttp` User-Agent is used.\n\n- **`batch_save_size`**: `int` (Default: `20`)\n - The number of songs to accumulate in memory before saving them to the database in a single transaction.\n\n\n---\n\n## Development\n\nThis project uses modern Python development tools:\n\n- **[uv](https://github.com/astral-sh/uv)** for dependency management\n- **[ruff](https://github.com/astral-sh/ruff)** for linting and formatting\n- **[mypy](https://mypy.readthedocs.io/)** for type checking\n- **[pre-commit](https://pre-commit.com/)** for git hooks\n- **[commitizen](https://commitizen-tools.github.io/commitizen/)** for conventional commits\n\n### Setting up for development:\n\n1. Clone the repository:\n ```bash\n git clone https://github.com/filming/melodic.git\n cd melodic\n ```\n\n2. Install dependencies (including dev tools):\n ```bash\n uv sync --extra dev\n ```\n\n3. Set up pre-commit hooks:\n ```bash\n uv run pre-commit install\n ```\n\n4. Start developing!\n\n---\n\n## Dependencies\n\nAll project dependencies are managed via [`pyproject.toml`](pyproject.toml) and use Python 3.10+.\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\n## Contributing\n\nContributions, bug reports, and feature requests are welcome!\nPlease open an issue or submit a pull request on [GitHub](https://github.com/filming/melodic).\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 Filming\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "A Python client for fetching artist lyrical discographies.",
"version": "2.2.0",
"project_urls": {
"Changelog": "https://github.com/filming/melodic/blob/master/CHANGELOG.md",
"Homepage": "https://github.com/filming/melodic",
"Issues": "https://github.com/filming/melodic/issues",
"Repository": "https://github.com/filming/melodic"
},
"split_keywords": [
"artist-data",
" async",
" azlyrics",
" database",
" discography",
" lyrics",
" music",
" python",
" web-scraping"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cbc834080c611a6785c1225498db440c5f1ebdc6e339d6973409906040696d9a",
"md5": "7103d297c5dfc69cd673346b437f99f0",
"sha256": "a7b2688b9a16c9ea7f1499614579252ed7fdab1046a56a766ea26bb7355835df"
},
"downloads": -1,
"filename": "melodic-2.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7103d297c5dfc69cd673346b437f99f0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 15673,
"upload_time": "2025-08-15T05:21:22",
"upload_time_iso_8601": "2025-08-15T05:21:22.443948Z",
"url": "https://files.pythonhosted.org/packages/cb/c8/34080c611a6785c1225498db440c5f1ebdc6e339d6973409906040696d9a/melodic-2.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "77e0810d5e3d145f82e34066b7199bd8e3f138a1f4446e24a637d8d536505d49",
"md5": "6cdf1dcef9244a412c5ad09f47ff4ca1",
"sha256": "c27f4e43cec2b590f54f50bd09d8ae7295576ff0fc15997954282056ec06a6bd"
},
"downloads": -1,
"filename": "melodic-2.2.0.tar.gz",
"has_sig": false,
"md5_digest": "6cdf1dcef9244a412c5ad09f47ff4ca1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 109549,
"upload_time": "2025-08-15T05:21:23",
"upload_time_iso_8601": "2025-08-15T05:21:23.976691Z",
"url": "https://files.pythonhosted.org/packages/77/e0/810d5e3d145f82e34066b7199bd8e3f138a1f4446e24a637d8d536505d49/melodic-2.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-15 05:21:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "filming",
"github_project": "melodic",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "melodic"
}