feat: add metaflac splitting test
This commit is contained in:
parent
6d67a22cfd
commit
5539013342
2 changed files with 61 additions and 0 deletions
60
.zsh_functions/music.zsh
Normal file
60
.zsh_functions/music.zsh
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
splitartist() {
|
||||||
|
local flac_file="$1"
|
||||||
|
local sep="${2:-,}" # Default separator is ','
|
||||||
|
|
||||||
|
if [[ ! -f "$flac_file" ]]; then
|
||||||
|
echo "File not found: $flac_file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v metaflac >/dev/null 2>&1; then
|
||||||
|
echo "Error: metaflac not found"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Reading tags from: $flac_file"
|
||||||
|
|
||||||
|
local artist_tag albumartist_tag
|
||||||
|
artist_tag=$(metaflac --show-tag=ARTIST "$flac_file" | sed 's/^ARTIST=//')
|
||||||
|
albumartist_tag=$(metaflac --show-tag=ALBUMARTIST "$flac_file" | sed 's/^ALBUMARTIST=//')
|
||||||
|
|
||||||
|
IFS="$sep" read -ra artist_array <<< "$artist_tag"
|
||||||
|
IFS="$sep" read -ra albumartist_array <<< "$albumartist_tag"
|
||||||
|
|
||||||
|
echo -e "\nCurrent ARTIST tag: $artist_tag"
|
||||||
|
echo "Split ARTIST into:"
|
||||||
|
for a in "${artist_array[@]}"; do echo " - ${a#" "}"; done
|
||||||
|
|
||||||
|
echo -e "\nCurrent ALBUMARTIST tag: $albumartist_tag"
|
||||||
|
echo "Split ALBUMARTIST into:"
|
||||||
|
for a in "${albumartist_array[@]}"; do echo " - ${a#" "}"; done
|
||||||
|
|
||||||
|
echo -e "\nThe following actions will be performed on: $flac_file"
|
||||||
|
echo "1. Remove all ARTIST and ALBUMARTIST tags"
|
||||||
|
echo "2. Add split ARTIST tags:"
|
||||||
|
for a in "${artist_array[@]}"; do echo " --set-tag=ARTIST='${a#" "}"; done
|
||||||
|
echo "3. Add split ALBUMARTIST tags:"
|
||||||
|
for a in "${albumartist_array[@]}"; do echo " --set-tag=ALBUMARTIST='${a#" "}"; done
|
||||||
|
|
||||||
|
read -p $'\nProceed with these changes? [y/N]: ' confirm
|
||||||
|
if [[ "$confirm" != [yY] ]]; then
|
||||||
|
echo "Aborted."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clear old tags
|
||||||
|
metaflac --remove-tag=ARTIST --remove-tag=ALBUMARTIST "$flac_file"
|
||||||
|
|
||||||
|
# Add split artist tags
|
||||||
|
for a in "${artist_array[@]}"; do
|
||||||
|
metaflac --set-tag="ARTIST=${a#" "}" "$flac_file"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Add split albumartist tags
|
||||||
|
for a in "${albumartist_array[@]}"; do
|
||||||
|
metaflac --set-tag="ALBUMARTIST=${a#" "}" "$flac_file"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Tags updated successfully."
|
||||||
|
}
|
||||||
|
|
|
@ -7,3 +7,4 @@ alias tf="tofu"
|
||||||
alias terraform="tofu"
|
alias terraform="tofu"
|
||||||
alias dotfiles="git --work-tree=$HOME --git-dir=$HOME/.dotgit "
|
alias dotfiles="git --work-tree=$HOME --git-dir=$HOME/.dotgit "
|
||||||
alias instaloader="uvx --with browser_cookie3 instaloader"
|
alias instaloader="uvx --with browser_cookie3 instaloader"
|
||||||
|
alias beet="uvx --with requests,langdetect,pylast,bs4,pillow --from beets beet"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue