From 17aadcf0d412bff43f70b7a181ecce0a23748ff5 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Wed, 1 Jul 2026 15:52:27 +0900 Subject: feat(qndl-artist): add apply subcommand (relocate + album_artist tag) --- ar/.local/bin/qndl-artist | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'ar/.local/bin/qndl-artist') diff --git a/ar/.local/bin/qndl-artist b/ar/.local/bin/qndl-artist index d442c56..c79a966 100755 --- a/ar/.local/bin/qndl-artist +++ b/ar/.local/bin/qndl-artist @@ -20,9 +20,44 @@ cmd_normalize() { printf '%s\n' "$_name" } +# mp3 1개를 표준 폴더로 이동(필요시) + album_artist 설정. +cmd_apply() { + _fp="$1"; _canon="$2" + [ -f "$_fp" ] || { printf 'apply: no such file: %s\n' "$_fp" >&2; return 1; } + case "$_fp" in + "$MUSIC"/*) : ;; + *) printf 'apply: not under %s: %s\n' "$MUSIC" "$_fp" >&2; return 1 ;; + esac + _rel="${_fp#"$MUSIC"/}" + _artist_seg="${_rel%%/*}" + _subpath="${_rel#*/}" # album/.../title.mp3 + if [ "$_artist_seg" != "$_canon" ]; then + _destdir="$MUSIC/$_canon/$(dirname "$_subpath")" + _dest="$_destdir/$(basename "$_fp")" + if [ -e "$_dest" ]; then + printf 'apply: skip (exists): %s\n' "$_dest" >&2 + return 0 + fi + mkdir -p "$_destdir" + mv "$_fp" "$_dest" || return 1 + # 빈 원본 앨범/아티스트 폴더 정리 + rmdir -p "$MUSIC/$_artist_seg/$(dirname "$_subpath")" 2>/dev/null || true + _fp="$_dest" + fi + _tmp="$(dirname "$_fp")/.qndl-tag-$$.mp3" + if ffmpeg -v error -y -i "$_fp" -map 0 -c copy -metadata album_artist="$_canon" "$_tmp" 2>/dev/null; then + mv "$_tmp" "$_fp" + else + rm -f "$_tmp" + printf 'apply: tag failed: %s\n' "$_fp" >&2 + return 1 + fi +} + _sub="${1:-}" [ $# -gt 0 ] && shift case "$_sub" in normalize) cmd_normalize "$@" ;; +apply) cmd_apply "$@" ;; *) printf 'usage: qndl-artist {normalize|apply|apply-download|merge} ...\n' >&2; exit 2 ;; esac -- cgit v1.2.3