Rename module from lyrics-dl
to lrc-dl
This commit is contained in:
parent
4bfcbf17bd
commit
658e1bef77
16 changed files with 52 additions and 52 deletions
22
README.md
22
README.md
|
@ -1,4 +1,4 @@
|
|||
# :musical_note: lyrics-dl
|
||||
# :musical_note: lrc-dl
|
||||
|
||||
An ultimate CLI tool for downloading lyrics for songs, inspired by other awesome *-dl projects.
|
||||
|
||||
|
@ -9,11 +9,11 @@ Before you begin, make sure you have `python3` and `pip` installed.
|
|||
0. If you wish to use the `youtube` provider, install `ffmpeg` and add it to your `PATH`.
|
||||
1. Clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/mrsobakin/lyrics-dl.git
|
||||
git clone https://github.com/mrsobakin/lrc-dl.git
|
||||
```
|
||||
2. Navigate to the project directory:
|
||||
```bash
|
||||
cd lyrics-dl
|
||||
cd lrc-dl
|
||||
```
|
||||
3. Install the package:
|
||||
```bash
|
||||
|
@ -22,12 +22,12 @@ Before you begin, make sure you have `python3` and `pip` installed.
|
|||
|
||||
## Usage
|
||||
|
||||
You can use `lyrics-dl` both as a CLI tool and as a Python module.
|
||||
You can use `lrc-dl` both as a CLI tool and as a Python module.
|
||||
|
||||
### CLI Usage
|
||||
|
||||
```bash
|
||||
lyrics-dl [-h] [-c CONFIG] [-e EXTENSIONS] [-f] path
|
||||
lrc-dl [-h] [-c CONFIG] [-e EXTENSIONS] [-f] path
|
||||
```
|
||||
|
||||
#### Positional Arguments:
|
||||
|
@ -37,18 +37,18 @@ lyrics-dl [-h] [-c CONFIG] [-e EXTENSIONS] [-f] path
|
|||
#### Options:
|
||||
|
||||
- `-h, --help`: Display help message and exit.
|
||||
- `-c CONFIG, --config CONFIG`: Specify a custom config file (in TOML format) for `lyrics-dl`.
|
||||
- `-c CONFIG, --config CONFIG`: Specify a custom config file (in TOML format) for `lrc-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.
|
||||
You can also use `lrc-dl` as a Python module, allowing you to integrate its functionality directly into your own scripts or applications.
|
||||
|
||||
#### Initializing `LyricsDl`
|
||||
|
||||
```python
|
||||
from lyrics_dl import LyricsDl, LyricsDlConfig
|
||||
from lrc_dl import LyricsDl, LyricsDlConfig
|
||||
|
||||
# Create a LyricsDl instance with default configuration
|
||||
ldl = LyricsDl()
|
||||
|
@ -61,7 +61,7 @@ ldl = LyricsDl(config=config)
|
|||
#### Fetching Lyrics for a Song
|
||||
|
||||
```python
|
||||
from lyrics_dl import Song
|
||||
from lrc_dl import Song
|
||||
|
||||
# Create a Song object
|
||||
song = Song(title="Where'd All The Time Go?", artist="Dr. Dog")
|
||||
|
@ -106,7 +106,7 @@ For more detailed information on the usage of the `LyricsDl` class, `Song` class
|
|||
|
||||
## Configuration
|
||||
|
||||
By default, lyrics-dl searches for the configuration file at `$XDG_CONFIG_HOME/lyrics-dl/config.toml`. You can specify custom config location using `-c` flag.
|
||||
By default, lrc-dl searches for the configuration file at `$XDG_CONFIG_HOME/lrc-dl/config.toml`. You can specify custom config location using `-c` flag.
|
||||
|
||||
The configuration is using the TOML format.
|
||||
Global provider parameters (for example, services order) are defined under the `[providers]` section.
|
||||
|
@ -118,7 +118,7 @@ As an example, to enable the `musixmatch` provider, you'll need to [acquire a Mu
|
|||
[providers]
|
||||
order = ["musixmatch", "kugou"]
|
||||
delay = 10 # Seconds to wait between searches
|
||||
prepend_header = true # Prepend lyrics-dl's & provider's header to keep track of lyrics source
|
||||
prepend_header = true # Prepend lrc-dl's & provider's header to keep track of lyrics source
|
||||
|
||||
[providers.musixmatch]
|
||||
token = "YOUR_TOKEN"
|
||||
|
|
|
@ -3,12 +3,12 @@ from typing import Optional
|
|||
from pathlib import Path
|
||||
import traceback
|
||||
|
||||
# Initialize classes from lyrics_dl/providers
|
||||
import lyrics_dl.providers
|
||||
from lyrics_dl.core import Song
|
||||
from lyrics_dl.registry import Registry
|
||||
from lyrics_dl.config import LyricsDlConfig
|
||||
from lyrics_dl.logger import DefaultLogger, AbstractLogger
|
||||
# Initialize classes from lrc_dl/providers
|
||||
import lrc_dl.providers
|
||||
from lrc_dl.core import Song
|
||||
from lrc_dl.registry import Registry
|
||||
from lrc_dl.config import LyricsDlConfig
|
||||
from lrc_dl.logger import DefaultLogger, AbstractLogger
|
||||
|
||||
|
||||
class LyricsDl:
|
||||
|
@ -32,13 +32,13 @@ class LyricsDl:
|
|||
try:
|
||||
provider = Provider(**provider_config)
|
||||
except TypeError as e:
|
||||
self.logger.error(f"[lyrics-dl] {e}")
|
||||
self.logger.error(f"[lrc-dl] {e}")
|
||||
continue
|
||||
|
||||
self.providers.append(provider)
|
||||
|
||||
def fetch_lyrics(self, song: Song) -> Optional[str]:
|
||||
self.logger.info(f"[lyrics-dl] Fetching lyrics for \"{song.artist} - {song.title}\"")
|
||||
self.logger.info(f"[lrc-dl] Fetching lyrics for \"{song.artist} - {song.title}\"")
|
||||
for provider in self.providers:
|
||||
self.logger.info(f"[{provider.name}] Fetching lyrics...")
|
||||
|
||||
|
@ -53,7 +53,7 @@ class LyricsDl:
|
|||
self.logger.info(f"[{provider.name}] Found lyrics!")
|
||||
|
||||
if self.config.prepend_header:
|
||||
lyrics = f"[re:lyrics-dl:{provider.name}]\n\n{lyrics}"
|
||||
lyrics = f"[re:lrc-dl:{provider.name}]\n\n{lyrics}"
|
||||
|
||||
return lyrics
|
||||
|
||||
|
@ -65,20 +65,20 @@ class LyricsDl:
|
|||
lyrics_path = path.with_suffix(".lrc")
|
||||
|
||||
if lyrics_path.exists() and not force:
|
||||
self.logger.error("[lyrics-dl] Lyrics file already exists!")
|
||||
self.logger.error("[lrc-dl] Lyrics file already exists!")
|
||||
return False
|
||||
|
||||
# TODO handle errors
|
||||
try:
|
||||
song = Song.from_file(path)
|
||||
except Exception as e:
|
||||
self.logger.error(f"[lyrics-dl] {path}: {e}")
|
||||
self.logger.error(f"[lrc-dl] {path}: {e}")
|
||||
return False
|
||||
|
||||
lyrics = self.fetch_lyrics(song)
|
||||
|
||||
if not lyrics:
|
||||
self.logger.error("[lyrics-dl] No lyrics was found!")
|
||||
self.logger.error("[lrc-dl] No lyrics was found!")
|
||||
return True
|
||||
|
||||
with open(lyrics_path, "w") as f:
|
||||
|
@ -91,7 +91,7 @@ class LyricsDl:
|
|||
|
||||
for file_path in path.rglob("*"):
|
||||
if delay_next and self.config.delay is not None:
|
||||
self.logger.info(f"[lyrics-dl] Sleeping for {self.config.delay:.2f}s...")
|
||||
self.logger.info(f"[lrc-dl] Sleeping for {self.config.delay:.2f}s...")
|
||||
time.sleep(self.config.delay)
|
||||
|
||||
if file_path.suffix[1:] not in extensions:
|
3
lrc_dl/__main__.py
Normal file
3
lrc_dl/__main__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from lrc_dl.main import main
|
||||
|
||||
main()
|
|
@ -4,7 +4,7 @@ from typing import Self
|
|||
import os
|
||||
import tomllib
|
||||
|
||||
from lyrics_dl.logger import DefaultLogger
|
||||
from lrc_dl.logger import DefaultLogger
|
||||
|
||||
|
||||
def _get_config_file() -> Path | None:
|
||||
|
@ -13,7 +13,7 @@ def _get_config_file() -> Path | None:
|
|||
if config_dir is None:
|
||||
return None
|
||||
|
||||
return Path(config_dir) / "lyrics-dl" / "config.toml"
|
||||
return Path(config_dir) / "lrc-dl" / "config.toml"
|
||||
|
||||
|
||||
CONFIG_PATH = _get_config_file()
|
|
@ -35,7 +35,7 @@ class DefaultLogger(AbstractLogger):
|
|||
return
|
||||
self.__initialized = True
|
||||
|
||||
self.logger = logging.getLogger("lyrics-dl")
|
||||
self.logger = logging.getLogger("lrc-dl")
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
|
||||
console_handler = logging.StreamHandler()
|
|
@ -1,9 +1,9 @@
|
|||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from lyrics_dl.config import LyricsDlConfig
|
||||
from lyrics_dl.logger import DefaultLogger
|
||||
from lyrics_dl import LyricsDl
|
||||
from lrc_dl.config import LyricsDlConfig
|
||||
from lrc_dl.logger import DefaultLogger
|
||||
from lrc_dl import LyricsDl
|
||||
|
||||
|
||||
DEFAULT_EXTENSIONS = ["flac", "alac", "mp3", "m4a", "mp4", "aac", "wav", "opus", "ogg"]
|
||||
|
@ -12,7 +12,7 @@ DEFAULT_EXTENSIONS = ["flac", "alac", "mp3", "m4a", "mp4", "aac", "wav", "opus",
|
|||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("path", type=Path, help="Path to the song file or directory")
|
||||
parser.add_argument("-c", "--config", type=Path, help="Config file for lyrics-dl")
|
||||
parser.add_argument("-c", "--config", type=Path, help="Config file for lrc-dl")
|
||||
parser.add_argument("-e", "--extensions", type=str, help="Music files extensions, separated by a comma. For example: wav,flac,mp3")
|
||||
parser.add_argument("-f", "--force-override", action="store_true", help="Force override .lrc file, if it already exists")
|
||||
return parser.parse_args()
|
||||
|
@ -27,7 +27,7 @@ def main():
|
|||
else:
|
||||
config = LyricsDlConfig.default()
|
||||
|
||||
lyrics_dl = LyricsDl(config=config, logger=logger)
|
||||
lrc_dl = LyricsDl(config=config, logger=logger)
|
||||
|
||||
if args.path.is_dir():
|
||||
if not args.extensions:
|
||||
|
@ -35,6 +35,6 @@ def main():
|
|||
else:
|
||||
extensions = args.extensions.split(",")
|
||||
|
||||
lyrics_dl.process_directory(args.path, extensions, args.force_override)
|
||||
lrc_dl.process_directory(args.path, extensions, args.force_override)
|
||||
else:
|
||||
lyrics_dl.process_file(args.path, args.force_override)
|
||||
lrc_dl.process_file(args.path, args.force_override)
|
3
lrc_dl/providers/__init__.py
Normal file
3
lrc_dl/providers/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from lrc_dl.providers import musixmatch
|
||||
from lrc_dl.providers import kugou
|
||||
from lrc_dl.providers import youtube
|
|
@ -7,8 +7,8 @@ from datetime import datetime
|
|||
|
||||
import httpx
|
||||
|
||||
from lyrics_dl.core import Song, AbstractProvider
|
||||
from lyrics_dl.registry import lyrics_provider
|
||||
from lrc_dl.core import Song, AbstractProvider
|
||||
from lrc_dl.registry import lyrics_provider
|
||||
|
||||
|
||||
KRC_ENCODE_KEY = [64, 71, 97, 119, 94, 50, 116, 71, 81, 54, 49, 45, 206, 210, 110, 105]
|
|
@ -1,8 +1,8 @@
|
|||
from typing import Optional
|
||||
import httpx
|
||||
|
||||
from lyrics_dl.core import Song, AbstractProvider
|
||||
from lyrics_dl.registry import lyrics_provider
|
||||
from lrc_dl.core import Song, AbstractProvider
|
||||
from lrc_dl.registry import lyrics_provider
|
||||
|
||||
|
||||
@lyrics_provider
|
|
@ -7,9 +7,9 @@ import unittest.mock
|
|||
|
||||
from yt_dlp import YoutubeDL
|
||||
|
||||
from lyrics_dl.core import Song, AbstractProvider
|
||||
from lyrics_dl.registry import lyrics_provider
|
||||
from lyrics_dl import utils
|
||||
from lrc_dl.core import Song, AbstractProvider
|
||||
from lrc_dl.registry import lyrics_provider
|
||||
from lrc_dl import utils
|
||||
|
||||
|
||||
@lyrics_provider
|
|
@ -1,4 +1,4 @@
|
|||
from lyrics_dl.core import AbstractProvider
|
||||
from lrc_dl.core import AbstractProvider
|
||||
|
||||
|
||||
class Registry:
|
|
@ -1,3 +0,0 @@
|
|||
from lyrics_dl.main import main
|
||||
|
||||
main()
|
|
@ -1,3 +0,0 @@
|
|||
from lyrics_dl.providers import musixmatch
|
||||
from lyrics_dl.providers import kugou
|
||||
from lyrics_dl.providers import youtube
|
8
setup.py
8
setup.py
|
@ -1,15 +1,15 @@
|
|||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='lyrics_dl',
|
||||
name='lrc_dl',
|
||||
version='0.0.3',
|
||||
description='An ultimate cli tool for downloading song lyrics, inspired by other awesome *-dl programs.',
|
||||
packages=[
|
||||
"lyrics_dl",
|
||||
"lyrics_dl.providers",
|
||||
"lrc_dl",
|
||||
"lrc_dl.providers",
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': ['lyrics-dl=lyrics_dl.main:main'],
|
||||
'console_scripts': ['lrc-dl=lrc_dl.main:main'],
|
||||
},
|
||||
install_requires=[
|
||||
"httpx>=0.24.1",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue