Commit 0a8505e1 authored by Cédric Marie's avatar Cédric Marie
Browse files

tag-sieve: Keep text containing ":" in MP3 tags



If a MP3 tag contains ":" character, or a FLAC tag contains "="
character, it is removed, as well as following text.

The filter "tail -n 1" is not necessary in case of MP3 tags, because
id3v2 tags are unique.
Signed-off-by: default avatarCédric Marie <cedric.marie@openmailbox.org>
parent 7be38ef7
......@@ -166,19 +166,27 @@ if [ "$command" = "clean" ]; then
print_header "Get album information from the first track ($file)"
file=`ls -1 *.flac | grep -m 1 flac`
metaflac --export-tags-to=$tags_filename "$file"
tag_artist=`grep "^ARTIST=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_album=`grep "^ALBUM=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_date=`grep "^DATE=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_artist=`grep "^ARTIST=" $tags_filename | tail -n 1`
tag_artist=${tag_artist#ARTIST=}
tag_album=`grep "^ALBUM=" $tags_filename | tail -n 1`
tag_album=${tag_album#ALBUM=}
tag_date=`grep "^DATE=" $tags_filename | tail -n 1`
tag_date=${tag_date#DATE=}
if [ "$keep_date" = "0" ]; then
tag_date=${tag_date%%-*}
fi
tag_tracktotal=`grep "^TRACKTOTAL=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_discnumber=`grep "^DISCNUMBER=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_tracktotal=`grep "^TRACKTOTAL=" $tags_filename | tail -n 1`
tag_tracktotal=${tag_tracktotal#TRACKTOTAL=}
tag_discnumber=`grep "^DISCNUMBER=" $tags_filename | tail -n 1`
tag_discnumber=${tag_discnumber#DISCNUMBER=}
if [ "$tag_discnumber" != "" ]; then
tag_disctotal=`grep "^DISCTOTAL=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_disctotal=`grep "^DISCTOTAL=" $tags_filename | tail -n 1`
tag_disctotal=${tag_disctotal#DISCTOTAL=}
fi
tag_comment=`grep "^COMMENT=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_license=`grep "^LICENSE=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_comment=`grep "^COMMENT=" $tags_filename | tail -n 1`
tag_comment=${tag_comment#COMMENT=}
tag_license=`grep "^LICENSE=" $tags_filename | tail -n 1`
tag_license=${tag_license#LICENSE=}
if [ "$tag_discnumber" != "" -a "$tag_disctotal" = "" ]; then
printf "DISCTOTAL is missing, please enter a value for this tag: "
......@@ -220,13 +228,18 @@ if [ "$command" = "clean" ]; then
do
metaflac --export-tags-to=$tags_filename "$file"
if [ "$multi_artist" = "1" ]; then
tag_artist=`grep "^ARTIST=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_artist=`grep "^ARTIST=" $tags_filename | tail -n 1`
tag_artist=${tag_artist#ARTIST=}
fi
tag_title=`grep "^TITLE=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_tracknumber=`grep "^TRACKNUMBER=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_title=`grep "^TITLE=" $tags_filename | tail -n 1`
tag_title=${tag_title#TITLE=}
tag_tracknumber=`grep "^TRACKNUMBER=" $tags_filename | tail -n 1`
tag_tracknumber=${tag_tracknumber#TRACKNUMBER=}
if [ "$multi_disc" = "1" ]; then
tag_tracktotal=`grep "^TRACKTOTAL=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_discnumber=`grep "^DISCNUMBER=" $tags_filename | cut -d= -f2 | tail -n 1`
tag_tracktotal=`grep "^TRACKTOTAL=" $tags_filename | tail -n 1`
tag_tracktotal=${tag_tracktotal#TRACKTOTAL=}
tag_discnumber=`grep "^DISCNUMBER=" $tags_filename | tail -n 1`
tag_discnumber=${tag_discnumber#DISCNUMBER=}
fi
printf "ARTIST=$tag_artist\n" > $tags_filename
printf "TITLE=$tag_title\n" >> $tags_filename
......@@ -262,9 +275,12 @@ if [ "$command" = "clean" ]; then
print_header "Get album information from the first track ($file)"
file=`ls -1 *.mp3 | grep -m 1 mp3`
id3v2 --list "$file" > $tags_filename
tag_artist=`grep "^TPE1 " $tags_filename | cut -d: -f2 | tail -n 1 | sed 's/^ \+//'`
tag_album=`grep "^TALB " $tags_filename | cut -d: -f2 | tail -n 1 | sed 's/^ \+//'`
tag_date=`grep "^TYER " $tags_filename | cut -d: -f2 | tail -n 1 | sed 's/^ \+//'`
tag_artist=`grep "^TPE1 " $tags_filename`
tag_artist=${tag_artist#*: }
tag_album=`grep "^TALB " $tags_filename`
tag_album=${tag_album#*: }
tag_date=`grep "^TYER " $tags_filename`
tag_date=${tag_date#*: }
# Print album information
printf "\033[7m"
......@@ -286,8 +302,10 @@ if [ "$command" = "clean" ]; then
while read file
do
id3v2 --list "$file" > $tags_filename
tag_title=`grep "^TIT2 " $tags_filename | cut -d: -f2 | tail -n 1 | sed 's/^ \+//'`
tag_tracknumber=`grep "^TRCK " $tags_filename | cut -d: -f2 | tail -n 1 | sed 's/^ \+//'`
tag_title=`grep "^TIT2 " $tags_filename`
tag_title=${tag_title#*: }
tag_tracknumber=`grep "^TRCK " $tags_filename`
tag_tracknumber=${tag_tracknumber#*: }
old_size=`stat -c %s "$file"`
id3v2 --delete-all "$file" > /dev/null
......
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