Donnerstag, 20. Mai 2010

Link Tracklist metadata to id3-tags

Problem: You have a mp3 album, but the files have no id3-tags set, but you've found a tracklist with the format:

<track-number>. <artist> - <title>

i.e.:

cat tracklist.txt | 
 while read f; do
  tr=$(echo "$f" | sed -e 's/\. .*//');
  a= $(echo "$f" | sed -e 's/...\. \(.*\) - .*/\1/');
  t=$(echo "$f" | sed -e 's/.* - \(.*\)/\1/');
  mid3v2 -T "$tr" -a "$a" -t "$t" -A "100 хитов русского рока" -g 17
    "$(find ./ -type f -iname "${tr}-*")";
 done

We pipe the tracklist 'tracklist.txt' to a loop, which does for each line (mp3-file):
We extract the track# 'tr', the author 'a' and the title 't'.
Then we set the id3v2.4 tags with mutagen mid3vs of the corresponding file - identified by the track#, we get the filename with a find-cmd.
Additionally we set the Album (-A) to '100 хитов русского рока' (100 Russian rock hits).

convmv - Convert encoding of filenames.

convmv is a perl script, which converts filenames from one encoding to another

i.e.:
$ convmv -f iso8859-15 -t utf-8 --notest *mp3

converts all mp3-files in the current directory  from iso8859-15 to utf-8.
--notest is needed to actually convert the filenames, otherwise convmv does a dry-run and only prints what it would do.

You can even convert a hole filetree (recursively) by adding the -r otpion.

It also checks if the encoding is already in utf-8 and aborts.

Sonntag, 16. Mai 2010

Utf-8 id3v2.4 tags

The UTF-8 support of id3 & id3v2 are broken. With id3v2 -l <mp3-file> the output will be OK, but other programs won't be able to read the character-encoding and display Mojibake (scrambled text).

Solution: use another id3-tagging tool, i.e. mutagen mid3v2 and mid3iconv.

mid3iconv is very handy - it converts the id3-tags from a source character-encoding (specied with -e <character-set>, default:UTF-8) to UTF-8 and also writes the correct character-encoding metadata into the id3v2.4 tags, so they'll display well in other apps.

If you've already converted the id3-tags to UTF-8 with id3/id3v2 you can repair them with:

$ find ./ -iname "*.mp3" | while read f; do  mid3iconv --remove-v1 -d  "$f"; done