Skip to content

Latest commit

History

History
123 lines (84 loc) 路 3.3 KB

README.md

File metadata and controls

123 lines (84 loc) 路 3.3 KB

馃幍 lyrics-dl

An ultimate CLI tool for downloading lyrics for songs, inspired by other awesome *-dl projects.

Installation

Before you begin, make sure you have python3 and pip installed.

  1. If you wish to use the youtube provider, install ffmpeg and add it to your PATH.
  2. Clone the repository:
    git clone https://github.com/mrsobakin/lyrics-dl.git
  3. Navigate to the project directory:
    cd lyrics-dl
  4. Install the package:
    pip install .

Usage

You can use lyrics-dl both as a CLI tool and as a Python module.

CLI Usage

python3 -m lyrics_dl [-h] [-c CONFIG] [-e EXTENSIONS] [-f] path

Positional Arguments:

  • path: Path to the song file or directory

Options:

  • -h, --help: Display help message and exit.
  • -c CONFIG, --config CONFIG: Specify a custom config file (in TOML format) for lyrics-dl.
  • -e EXTENSIONS, --extensions EXTENSIONS: Define music file extensions, separated by commas (e.g., wav,flac,mp3).
  • -f, --force-override: Force override .lrc file, if it already exists.

Usage as a Python Module

You can also use lyrics-dl as a Python module, allowing you to integrate its functionality directly into your own scripts or applications.

Initializing LyricsDl

from lyrics_dl import LyricsDl, LyricsDlConfig

# Create a LyricsDl instance with default configuration
ldl = LyricsDl()

# Create a LyricsDl instance with a custom configuration
config = LyricsDlConfig(order=["kugou"])
ldl = LyricsDl(config=config)

Fetching Lyrics for a Song

from lyrics_dl import Song

# Create a Song object
song = Song(title="Where'd All The Time Go?", artist="Dr. Dog")

# Fetch lyrics for the song
lyrics = ldl.fetch_lyrics(song)

if lyrics:
    print(lyrics)
else:
    print("Lyrics not found")

Processing a File

from pathlib import Path

# Define the path to the song file
file_path = Path("/path/to/song.mp3")

# Process the file
ldl.process_file(file_path)

Processing a Directory

from pathlib import Path

# Define the path to the directory
dir_path = Path("/path/to/songs/directory")

# Define the extensions of music files
extensions = ["mp3", "wav"]

# Process the directory
ldl.process_directory(dir_path, extensions)

For more detailed information on the usage of the LyricsDl class, Song class, and LyricsDlConfig class, you can explore the source code. The code is written with Python typing, making it easy to understand.

Configuration

The configuration file is in TOML format and can be specified using the -c flag when running lyrics-dl. To create a custom configuration, follow these steps:

  1. Create the configuration file (config.toml).
  2. Define the global provider parameters (for example, order) under [providers] section.
  3. To change provider-specific configuration, add a [providers.provider_name] section and set the required parameters under it.

As an example, to enable the musixmatch provider, you'll need to acquire a Musixmatch token and create a config like this:

[providers]
order = ["musixmatch", "kugou"]

[providers.musixmatch]
token = "YOUR_TOKEN"