Commit be2fd785 authored by Cédric Marie's avatar Cédric Marie

myaudiotags: Remove -y option for 'clean' command

In 'clean' command, -y option was used to keep only the year in the
date tag (YYYY-MM-DD was changed into YYYY).

This option could be useful when the CDs were ripped by sound-juicer
for example, in particular when the date was YYYY-01-01 (which meant
that the exact date was unknown).

Now I use mycdrip (based on cdparanoia) to rip the CDs, and the date is
set manually with 'seta' command. So I don't need this option anymore.
Signed-off-by: default avatarCédric Marie <cedric@hjuvi.lautre.net>
parent 1453a5bf
......@@ -36,7 +36,6 @@ print_usage()
printf " - LICENSE (from first track, if present)\n"
printf " (remove seek table, picture, cue sheet, and padding blocks)\n"
printf " Options for \"clean\" command:\n"
printf " -d keep full date (default: keep only the year)\n"
printf " -a multi-artist (read artist in each track)\n"
printf " seta ARTIST ALBUM DATE\n"
printf " set artist, album, and date tags in the first track\n"
......@@ -97,8 +96,8 @@ command=$1
if [ "$command" = "show" ]; then
# FLAC files
if [ "$flac_files" != "" ]; then
# FLAC files
ls -1 *.flac |
{
while read file
......@@ -109,8 +108,8 @@ if [ "$command" = "show" ]; then
printf "\033[0m\n"
done
}
# MP3 files
elif [ "$mp3_files" != "" ]; then
# MP3 files
ls -1 *.mp3 |
{
while read file
......@@ -131,13 +130,11 @@ fi
if [ "$command" = "clean" ]; then
year_only=0
multi_artist=0
shift 1
while getopts ya OPT
do
case $OPT in
y) year_only=1;;
a) multi_artist=1;;
*) print_usage; exit 1;;
esac
......@@ -146,9 +143,9 @@ if [ "$command" = "clean" ]; then
tags_filename=/tmp/myaudiotags-clean.tags
# FLAC files
if [ "$flac_files" != "" ]; then
# FLAC files
# Get album information from the first track
file=`ls -1 *.flac | grep -m 1 flac`
print_header "Get album information from the first track ($file)"
......@@ -159,9 +156,6 @@ if [ "$command" = "clean" ]; then
tag_album=${tag_album#ALBUM=}
tag_date=`grep "^DATE=" $tags_filename | tail -n 1`
tag_date=${tag_date#DATE=}
if [ "$year_only" = "1" ]; then
tag_date=${tag_date%%-*}
fi
tag_tracktotal=`grep "^TRACKTOTAL=" $tags_filename | tail -n 1`
tag_tracktotal=${tag_tracktotal#TRACKTOTAL=}
if [ "${file%%.*}" = "1" ]; then
......@@ -214,6 +208,7 @@ if [ "$command" = "clean" ]; then
{
while read file
do
# Get track information
metaflac --export-tags-to=$tags_filename "$file"
if [ "$multi_artist" = "1" ]; then
tag_artist=`grep "^ARTIST=" $tags_filename | tail -n 1`
......@@ -229,6 +224,7 @@ if [ "$command" = "clean" ]; then
tag_discnumber=`grep "^DISCNUMBER=" $tags_filename | tail -n 1`
tag_discnumber=${tag_discnumber#DISCNUMBER=}
fi
# Clean and set tags
printf "ARTIST=$tag_artist\n" > $tags_filename
printf "TITLE=$tag_title\n" >> $tags_filename
printf "ALBUM=$tag_album\n" >> $tags_filename
......@@ -258,9 +254,9 @@ if [ "$command" = "clean" ]; then
# Set read-only permission
chmod 444 *.flac
# MP3 files
elif [ "$mp3_files" != "" ]; then
# MP3 files
# Get album information from the first track
file=`ls -1 *.mp3 | grep -m 1 mp3`
print_header "Get album information from the first track ($file)"
......@@ -299,6 +295,7 @@ if [ "$command" = "clean" ]; then
{
while read file
do
# Get track information
id3v2 --list "$file" > $tags_filename
tag_title=`grep "^TIT2 " $tags_filename`
tag_title=${tag_title#*: }
......@@ -308,6 +305,7 @@ if [ "$command" = "clean" ]; then
tag_discnumber=`grep "^TPOS " $tags_filename`
tag_discnumber=${tag_discnumber#*: }
fi
# Clean and set tags
old_size=`stat -c %s "$file"`
id3v2 --delete-all "$file" > /dev/null
id3v2 --id3v2-only --artist "$tag_artist" --song "$tag_title" --album "$tag_album" --year "$tag_date" --track "$tag_tracknumber" "$file"
......@@ -335,24 +333,14 @@ fi
if [ "$command" = "clean-single" ]; then
year_only=0
shift 1
while getopts y OPT
do
case $OPT in
y) year_only=1;;
*) print_usage; exit 1;;
esac
done
shift $(($OPTIND - 1))
file=$1
tags_filename=/tmp/myaudiotags-clean.tags
# FLAC file
if [ "${file%.flac}" != "$file" ]; then
# Get information
# FLAC file
# Get track information
metaflac --export-tags-to=$tags_filename "$file"
tag_artist=`grep "^ARTIST=" $tags_filename | tail -n 1`
tag_artist=${tag_artist#ARTIST=}
......@@ -360,9 +348,6 @@ if [ "$command" = "clean-single" ]; then
tag_title=${tag_title#TITLE=}
tag_date=`grep "^DATE=" $tags_filename | tail -n 1`
tag_date=${tag_date#DATE=}
if [ "$year_only" = "1" ]; then
tag_date=${tag_date%%-*}
fi
tag_comment=`grep "^COMMENT=" $tags_filename | tail -n 1`
tag_comment=${tag_comment#COMMENT=}
tag_license=`grep "^LICENSE=" $tags_filename | tail -n 1`
......@@ -373,8 +358,7 @@ if [ "$command" = "clean-single" ]; then
# Set read-write permission
chmod 644 "$file"
# Set tags in this file
# Clean and set tags
printf "ARTIST=$tag_artist\n" > $tags_filename
printf "TITLE=$tag_title\n" >> $tags_filename
printf "DATE=$tag_date\n" >> $tags_filename
......@@ -396,10 +380,10 @@ if [ "$command" = "clean-single" ]; then
# Set read-only permission
chmod 444 "$file"
# MP3 file
elif [ "${file%.mp3}" != "$file" ]; then
# Get information
# MP3 file
# Get track information
id3v2 --list "$file" > $tags_filename
tag_artist=`grep "^TPE1 " $tags_filename`
tag_artist=${tag_artist#*: }
......@@ -416,6 +400,7 @@ if [ "$command" = "clean-single" ]; then
# Set read-write permission
chmod 644 "$file"
# Clean and set tags
old_size=`stat -c %s "$file"`
id3v2 --delete-all "$file" > /dev/null
id3v2 --id3v2-only --artist "$tag_artist" --song "$tag_title" --year "$tag_date" "$file"
......@@ -465,22 +450,24 @@ if [ "$command" = "seta" ]; then
print_header "Set artist, album, and date in the first track"
# FLAC files
if [ "$flac_files" != "" ]; then
# FLAC files
file=`ls -1 *.flac | grep -m 1 flac`
# Set read-write permission
chmod 644 "$file"
# Set artist/album/date tags
metaflac --set-tag="ARTIST=$tag_artist" --set-tag="ALBUM=$tag_album" --set-tag="DATE=$tag_date" "$file"
# Set read-only permission
chmod 444 "$file"
# MP3 files
elif [ "$mp3_files" != "" ]; then
# MP3 files
file=`ls -1 *.mp3 | grep -m 1 mp3`
# Set read-write permission
chmod 644 "$file"
# Set artist/album/date tags
id3v2 --id3v2-only --artist "$tag_artist" --album "$tag_album" --year "$tag_date" "$file"
# Set read-only permission
chmod 444 "$file"
......@@ -510,22 +497,24 @@ if [ "$command" = "setc" ]; then
print_header "Set comment in the first track"
# FLAC files
if [ "$flac_files" != "" ]; then
# FLAC files
file=`ls -1 *.flac | grep -m 1 flac`
# Set read-write permission
chmod 644 "$file"
# Set comment tag
metaflac --set-tag="COMMENT=$tag_comment" "$file"
# Set read-only permission
chmod 444 "$file"
# MP3 files
elif [ "$mp3_files" != "" ]; then
# MP3 files
file=`ls -1 *.mp3 | grep -m 1 mp3`
# Set read-write permission
chmod 644 "$file"
# Set comment tag
id3v2 --id3v2-only --comment "$tag_comment" "$file"
# Set read-only permission
chmod 444 "$file"
......@@ -573,6 +562,7 @@ if [ "$command" = "set-single" ]; then
# Set read-write permission
chmod 644 "$file"
# Set artist/title/date tags
metaflac --set-tag="ARTIST=$tag_artist" --set-tag="TITLE=$tag_title" --set-tag="DATE=$tag_date" "$file"
# Set read-only permission
chmod 444 "$file"
......@@ -582,6 +572,7 @@ if [ "$command" = "set-single" ]; then
# Set read-write permission
chmod 644 "$file"
# Set artist/title/date tags
id3v2 --id3v2-only --artist "$tag_artist" --song "$tag_title" --year "$tag_date" "$file"
# Set read-only permission
chmod 444 "$file"
......
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