Muzlib is a Python script that allows you to create your own music library.
Project description
Muzlib
Muzlib is a Python script that allows you to create your own music library. Music is downloaded from YouTube, and music tags are constructed using data from YouTube and Spotify.
Instalation
Ensure that you have installed FFmpeg.
Install muzlib using pip:
pip install muzlib
Install muzlib from source code:
git clone https://github.com/ezvezdov/muzlib
cd muzlib/
python -m venv .venv
source .venv/bin/activate
pip install yt_dlp ytmusicapi spotipy mutagen syncedlyrics
Usage
You can simply download discography of artist (YouTube API by default).
python muzlib.py
>>> Please enter the path for music library: ...
>>> Please enter artist name: ...
This script creates a simple database (.muzlib/db.json) to track downloaded tracks, allowing you to update an artist's discography without re-downloading existing tracks.
Available clases
There are two classes that can be used:
muzlib(library_path: str, skip_downloaded=False): library class that uses YouTube Music metadata (100% accuracy, but sometimes poor quality metadata).muzlibS(library_path: str, skip_downloaded=False): library class that uses Spotify metadata (qood quality metadata, but sometimes invalid audio).
skip_downloaded: If set to True, skip already downloaded file. By default (False).
Available methods
Downloading artist's discography
Muzlib.download_artist_discography(artist_name: str, download_top_result=False)
artist_name: Name of artist as a string.download_top_result: If set to True, choose the first matching artist automatically. By default (False), it will prompt you to confirm if the match is correct.
Downloading album
Muzlib.download_album_by_name(search_term: str, download_top_result=False)
search_term: The search query as a string. It is recommended to use the format: "artist1, artist2 - album_name".download_top_result: If set to True, downloads the first matching result automatically. By default (False), it will prompt you to confirm if the match is correct.
Download track
Muzlib.download_track_by_name(search_term: str, download_top_result=False)
search_term: The search query as a string. It is recommended to use the format: "artist1, artist2 - track_name".download_top_result: If set to True, downloads the first matching result automatically. By default (False), it will prompt you to confirm if the match is correct.
Backup library
Muzlib.backup_library() -> str
This function creates backup of library (even with user-changed tags).
Creates file .muzlib/muzlib_backup_***.json and returns path to it.
Restore library
This function downloads track and set metadata from bacup file.
Muzlib.backup_library(backup_filepath: str)
backup_filepath: path of the file created byMuzlib.backup_library().
Example of use
You can use Muzlib/MuzlibS class in source code this way
import muzlib
ml = muzlib.Muzlib("Music")
ml.download_track_by_name("Ludwig Göransson - Can You Hear The Music")
ml.download_track_by_name("Ludwig Göransson - Destroyer Of Worlds", download_top_result=True)
# ml.download_artist_discography("Ludwig Göransson")
backup_path = ml.backup_library()
ml2 = muzlib.MuzlibS("Music2")
ml2.restore_library(backup_path)
After running this code, the Music and Music2 folders will be identical, each containing two tracks by Ludwig Göransson.
Troubleshooting
[!WARNING] If you encounter issues with the Spotify API, you can provide your API key in the
api_key.pyfile.
- Generate client_id and client_secret at developer.spotify.com.
- Pass this data to the
api_key.pyfile.Alternatively you can use
Muzlibinstead ofMuzlibS.
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 muzlib-0.2.tar.gz.
File metadata
- Download URL: muzlib-0.2.tar.gz
- Upload date:
- Size: 24.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 |
79e4c612558c3b8cdeadb42959c714e65de14a34dbbd09ea373e376057b759f1
|
|
| MD5 |
3c48ba532ce17f2cac981991722631b1
|
|
| BLAKE2b-256 |
8d3b076b9bc9f3e53a3b91920b9aaed092f8c346bdde6e6387ff5c84c196eeb4
|
Provenance
The following attestation bundles were made for muzlib-0.2.tar.gz:
Publisher:
python-publish.yml on ezvezdov/muzlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muzlib-0.2.tar.gz -
Subject digest:
79e4c612558c3b8cdeadb42959c714e65de14a34dbbd09ea373e376057b759f1 - Sigstore transparency entry: 1102986525
- Sigstore integration time:
-
Permalink:
ezvezdov/muzlib@2577c8a06a126b8a1b365e43af22bcb739f16f7a -
Branch / Tag:
refs/tags/v0.2 - Owner: https://github.com/ezvezdov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2577c8a06a126b8a1b365e43af22bcb739f16f7a -
Trigger Event:
release
-
Statement type:
File details
Details for the file muzlib-0.2-py3-none-any.whl.
File metadata
- Download URL: muzlib-0.2-py3-none-any.whl
- Upload date:
- Size: 25.8 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 |
00b446339730e1ccdd211a97b19cdf9186f747f1757bd8be787b5513dd136bb0
|
|
| MD5 |
701f5e42fe95239f683c4bf7c8866b34
|
|
| BLAKE2b-256 |
b4b9acfe9608360531a6984a3db638cac2fbab89fc5dfbf5917b98e465844a82
|
Provenance
The following attestation bundles were made for muzlib-0.2-py3-none-any.whl:
Publisher:
python-publish.yml on ezvezdov/muzlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muzlib-0.2-py3-none-any.whl -
Subject digest:
00b446339730e1ccdd211a97b19cdf9186f747f1757bd8be787b5513dd136bb0 - Sigstore transparency entry: 1102986535
- Sigstore integration time:
-
Permalink:
ezvezdov/muzlib@2577c8a06a126b8a1b365e43af22bcb739f16f7a -
Branch / Tag:
refs/tags/v0.2 - Owner: https://github.com/ezvezdov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2577c8a06a126b8a1b365e43af22bcb739f16f7a -
Trigger Event:
release
-
Statement type: