Initial commit
This commit is contained in:
commit
ee3c2358ff
12 changed files with 622 additions and 0 deletions
20
lyrics_dl/config.py
Normal file
20
lyrics_dl/config.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from typing import Self
|
||||
import tomllib
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@dataclass
|
||||
class LyricsDlConfig:
|
||||
order: list[str] = field(default_factory=lambda: ["kugou", "youtube"])
|
||||
providers_configs: dict[str, dict] = field(default_factory=lambda: {})
|
||||
|
||||
@classmethod
|
||||
def from_file(cls, path: Path) -> Self:
|
||||
with open(path, "rb") as f:
|
||||
config = tomllib.load(f)
|
||||
|
||||
return cls(
|
||||
order=config["providers"].pop("order"),
|
||||
providers_configs=config["providers"],
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue