Commit 4819fd78 authored by Cédric Marie's avatar Cédric Marie

myaudiotags: Group some metaflac/id3v2 commands

Group some id3v2 or metaflac commands, when called successively for
several tag settings.
Signed-off-by: default avatarCédric Marie <cedric@hjuvi.lautre.net>
parent 510f59d4
......@@ -144,7 +144,7 @@ if [ "$command" = "clean" ]; then
done
multi_disc=0
tags_filename=/tmp/tag-sieve-clean.tags
tags_filename=/tmp/myaudiotags-clean.tags
# FLAC files
if [ "$flac_files" != "" ]; then
......@@ -310,11 +310,7 @@ if [ "$command" = "clean" ]; then
fi
old_size=`stat -c %s "$file"`
id3v2 --delete-all "$file" > /dev/null
id3v2 --id3v2-only --artist "$tag_artist" "$file"
id3v2 --id3v2-only --song "$tag_title" "$file"
id3v2 --id3v2-only --album "$tag_album" "$file"
id3v2 --id3v2-only --year "$tag_date" "$file"
id3v2 --id3v2-only --track "$tag_tracknumber" "$file"
id3v2 --id3v2-only --artist "$tag_artist" --song "$tag_title" --album "$tag_album" --year "$tag_date" --track "$tag_tracknumber" "$file"
if [ "$multi_disc" = "1" ]; then
id3v2 --id3v2-only --TPOS "$tag_discnumber" "$file"
fi
......@@ -351,7 +347,7 @@ if [ "$command" = "clean-single" ]; then
shift $(($OPTIND - 1))
file=$1
tags_filename=/tmp/tag-sieve-clean.tags
tags_filename=/tmp/myaudiotags-clean.tags
# FLAC file
if [ "${file%.flac}" != "$file" ]; then
......@@ -413,25 +409,22 @@ if [ "$command" = "clean-single" ]; then
tag_date=${tag_date#*: }
tag_comment=`grep "^COMM " $tags_filename | tail -n 1`
tag_comment=${tag_comment#*: *: }
rm -f $tags_filename
print_header "Set tags in this file"
# Set read-write permission
chmod 644 "$file"
id3v2 --list "$file" > $tags_filename
old_size=`stat -c %s "$file"`
id3v2 --delete-all "$file" > /dev/null
id3v2 --id3v2-only --artist "$tag_artist" "$file"
id3v2 --id3v2-only --song "$tag_title" "$file"
id3v2 --id3v2-only --year "$tag_date" "$file"
id3v2 --id3v2-only --artist "$tag_artist" --song "$tag_title" --year "$tag_date" "$file"
if [ "$tag_comment" != "" ]; then
id3v2 --id3v2-only --comment "$tag_comment" "$file"
fi
new_size=`stat -c %s "$file"`
printf "(saved %d bytes) $file\n" $(($old_size - $new_size))
rm -f $tags_filename
# Set read-only permission
chmod 444 "$file"
......@@ -478,9 +471,7 @@ if [ "$command" = "seta" ]; then
file=`ls -1 *.flac | grep -m 1 flac`
# Set read-write permission
chmod 644 "$file"
metaflac --set-tag="ARTIST=$tag_artist" "$file"
metaflac --set-tag="ALBUM=$tag_album" "$file"
metaflac --set-tag="DATE=$tag_date" "$file"
metaflac --set-tag="ARTIST=$tag_artist" --set-tag="ALBUM=$tag_album" --set-tag="DATE=$tag_date" "$file"
# Set read-only permission
chmod 444 "$file"
......@@ -490,9 +481,7 @@ if [ "$command" = "seta" ]; then
file=`ls -1 *.mp3 | grep -m 1 mp3`
# Set read-write permission
chmod 644 "$file"
id3v2 --id3v2-only --artist "$tag_artist" "$file"
id3v2 --id3v2-only --album "$tag_album" "$file"
id3v2 --id3v2-only --year "$tag_date" "$file"
id3v2 --id3v2-only --artist "$tag_artist" --album "$tag_album" --year "$tag_date" "$file"
# Set read-only permission
chmod 444 "$file"
......@@ -584,9 +573,7 @@ if [ "$command" = "set-single" ]; then
# Set read-write permission
chmod 644 "$file"
metaflac --set-tag="ARTIST=$tag_artist" "$file"
metaflac --set-tag="TITLE=$tag_title" "$file"
metaflac --set-tag="DATE=$tag_date" "$file"
metaflac --set-tag="ARTIST=$tag_artist" --set-tag="TITLE=$tag_title" --set-tag="DATE=$tag_date" "$file"
# Set read-only permission
chmod 444 "$file"
......@@ -595,9 +582,7 @@ if [ "$command" = "set-single" ]; then
# Set read-write permission
chmod 644 "$file"
id3v2 --id3v2-only --artist "$tag_artist" "$file"
id3v2 --id3v2-only --song "$tag_title" "$file"
id3v2 --id3v2-only --year "$tag_date" "$file"
id3v2 --id3v2-only --artist "$tag_artist" --song "$tag_title" --year "$tag_date" "$file"
# Set read-only permission
chmod 444 "$file"
......@@ -653,15 +638,13 @@ if [ "$command" = "update" ]; then
current_disc=$tag_discnumber
tag_tracktotal=`ls -1 ${tag_discnumber}.*.flac | grep -c flac`
fi
metaflac --set-tag="DISCNUMBER=$tag_discnumber" "$file"
metaflac --set-tag="DISCTOTAL=$tag_disctotal" "$file"
metaflac --set-tag="DISCNUMBER=$tag_discnumber" --set-tag="DISCTOTAL=$tag_disctotal" "$file"
printf "track \033[7m$tag_tracknumber\033[0m/\033[7m$tag_tracktotal\033[0m, disc \033[7m$tag_discnumber\033[0m/\033[7m$tag_disctotal\033[0m: "
else
printf "track \033[7m$tag_tracknumber\033[0m/\033[7m$tag_tracktotal\033[0m: "
fi
metaflac -set-tag="TRACKNUMBER=$tag_tracknumber" --set-tag="TRACKTOTAL=$tag_tracktotal" "$file"
printf "\033[7m$tag_title\033[0m ($file)\n"
metaflac --set-tag="TRACKNUMBER=$tag_tracknumber" "$file"
metaflac --set-tag="TRACKTOTAL=$tag_tracktotal" "$file"
done
}
# Set read-only permission
......@@ -710,8 +693,8 @@ if [ "$command" = "update" ]; then
else
printf "track \033[7m$tag_tracknumber\033[0m/\033[7m$tag_tracktotal\033[0m: "
fi
printf "\033[7m$tag_title\033[0m ($file)\n"
id3v2 --id3v2-only --track "$tag_tracknumber/$tag_tracktotal" "$file"
printf "\033[7m$tag_title\033[0m ($file)\n"
done
}
# Set read-only permission
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment