Use relative path
Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import click
|
||||
import yaml
|
||||
import eyed3
|
||||
@@ -7,11 +8,12 @@ from eyed3.core import Date
|
||||
@click.command()
|
||||
@click.option("--config", prompt="Config path", help="A path to the yaml config")
|
||||
def run(config):
|
||||
config_dir = os.path.dirname(config)
|
||||
data = read_one_block_of_yaml_data(config)
|
||||
if isinstance(data, list):
|
||||
for idx, track in enumerate(data):
|
||||
print(track["title"])
|
||||
audiofile = eyed3.load(track["file"])
|
||||
audiofile = eyed3.load(f"{config_dir}/{track["file"]}")
|
||||
|
||||
audiofile.initTag()
|
||||
|
||||
@@ -24,11 +26,11 @@ def run(config):
|
||||
date_str = track["release_date"]
|
||||
date_obj = Date.parse(date_str)
|
||||
audiofile.tag.original_release_date = date_obj
|
||||
with open(track["cover"], "rb") as cover_art:
|
||||
with open(f"{config_dir}/{track["cover"]}", "rb") as cover_art:
|
||||
audiofile.tag.images.set(
|
||||
3, cover_art.read(), "image/png", "Cover (front)"
|
||||
)
|
||||
with open(track["lyrics"], "r", encoding="utf-8") as f:
|
||||
with open(f"{config_dir}/{track["lyrics"]}", "r", encoding="utf-8") as f:
|
||||
text = f.read()
|
||||
audiofile.tag.lyrics.set(text)
|
||||
audiofile.tag.save()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
- file: test/test.mp3
|
||||
- file: test.mp3
|
||||
title: test track
|
||||
album: test
|
||||
artist: allanger
|
||||
release_date: '2025-10-10'
|
||||
comment: test
|
||||
cover: ./test/cover.png
|
||||
lyrics: ./test/lyrics.txt
|
||||
cover: cover.png
|
||||
lyrics: lyrics.txt
|
||||
|
||||
Reference in New Issue
Block a user