3

I have some mp3 files with Cyrillic chars on file names and also on their tags.

I'm using audacious to play them. See the file info below:

enter image description here

Is it possible to change some encoding to show the contents correctly?

Âûñîêî should be Высоко, I guess.

  • Are thes ID3v1 or ID3v2 tags? If these are v1 then there is no encoding information available and you can only guess. – Anthon Feb 9 '14 at 15:26
  • @Anthon, I don't know. How to discover the version? – Sigur Feb 9 '14 at 15:37
  • 2
    Some commandline tools will tell you. e.g. eyeD3. It can do some tricks with encoding, but I am not sure if it can do cyrillic ID3v1 to UTF-8 ID3v2, I think not because there seems no way to specify the input encoding. – Anthon Feb 9 '14 at 15:39
  • Can you share one of these files, or are they copyrighted? – Anthon Feb 9 '14 at 15:42
  • I installed eyed3 and the output is ID3 v2.3. – Sigur Feb 9 '14 at 15:45
3

I don't have any Cyrillic characters in my music collection but I can do Greek with no problem using the latest version of eyed3 installed by sudo pip install --upgrade eyed3:

 $ eyeD3 Μπεστ\ οφ/Τζίμης\ Πανούσης\ -\ Κάγκελα\ Παντού.mp3 
Τζίμης Πανούσης - Κάγκελα Παντού.mp3    [ 3.43 MB ]
-------------------------------------------------------------------------------
Time: 03:45 MPEG1, Layer III    [ 128 kb/s @ 44100 Hz - Joint stereo ]
-------------------------------------------------------------------------------
ID3 v2.4:
title: Tzimis Panousis-Kagkela Pantou.mp3
artist: Tzimis Panousis
album: Unknown

In the example above, I have a directory (album name) called Μπεστ οφ which contains a song called Κάγκελα Παντού by Τζίμης Πανούσης. As you can see in the id3tool output above, the tags are not in Greek. Let's fix that:

$ eyeD3 -A "Μπεστ οφ" \
        -t "Κάγκελα Παντού" \
        -a "Τζίμης Πανούσης" \
        "./Μπεστ οφ/Τζίμης Πανούσης - Κάγκελα Παντού.mp3"

That correctly set the tags using the Greek alphabet:

$ eyeD3 Μπεστ\ οφ/Τζίμης\ Πανούσης\ -\ Κάγκελα\ Παντού.mp3 
Τζίμης Πανούσης - Κάγκελα Παντού.mp3    [ 3.43 MB ]
-------------------------------------------------------------------------------
Time: 03:45 MPEG1, Layer III    [ 128 kb/s @ 44100 Hz - Joint stereo ]
-------------------------------------------------------------------------------
ID3 v2.4:
title: Κάγκελα Παντού
artist: Τζίμης Πανούσης
album: Μπεστ οφ

OK, but since the information is encoded in the name of the file, this can be automated. In the example above, the file name has this format:

Album/Artist - Title.mp3

So, we can parse and add the tags for all files with a little shell magic:

find . -type f -name "*mp3" | while read file; do 
    album="$(basename "$(dirname "$file")")"; 
    filename="$(basename "$file")"; 
    artist=${filename%%-*}; 
    title=${filename##*-}; 
    title=${title%%.mp3}; 
    eyeD3 -A "$album" -t "$title" -a "$artist" "$file"; 
done

After running this command, all files will have had their id3 tags modified:

  enter image description here

  • 1
    Please note that as Sigur commented, it might be that older versions of eyeD3 do not work correctly. I would also explicitly set --to-v2.4 to be sure the tag version is updated. – Anthon Feb 9 '14 at 17:44
  • The script worked so nice! You can see here dl.dropboxusercontent.com/u/42709342/03.png Thanks so much. – Sigur Feb 9 '14 at 17:45
  • @terdon, OK. Now I have to adapt the script. Since my file name is Юлия Савичева - 03 - Отпусти меня.mp3 the title tag is starting with empty space. I don't know why. Maybe because the number. Also the track number does not appear. I don't care but since it is contained in file name I guess that it should be used somewhere in the tag. – Sigur Feb 9 '14 at 17:54
  • @Sigur this is just an example, I recommend you post a new question explaining the format of your file names and I'll give you a more specific script. – terdon Feb 9 '14 at 18:09
  • @terdon, done! unix.stackexchange.com/q/114413/19195 – Sigur Feb 9 '14 at 18:30
3

I could succesfully update an MP3 file using:

eyeD3 -a "Ю" abc.mp3

This was done with eyeD3 0.7.4-beta as installed using pip from PyPI:

pip install eyeD3

Using that eyeD3 you could use a script to extract the artist and title from the MP3's file path and set them as ID3v2 2.4 tags with eyeD3.

  • Can you confirm that the info is displayed correctly in audacious or vlc or any other GUI app? Following the procedure in my answer it works fine on the CLI but GUI apps seem to ignore it and take the info from somewhere else. – terdon Feb 9 '14 at 16:51
  • I installed eyeD3 0.7.4-beta (C) Copyright 2002-2013 Travis Shirk from the source. I rename my file to abc.mp3 (to remove all Cyrillic chars from file name) but eyeD3 -a "Ю" abc.mp3 produces errors. After some info I can find Writing ID3 version v2.3 Uncaught exception: 'latin-1' codec can't encode characters in position 0-3: ordinal not in range(256). – Sigur Feb 9 '14 at 16:55
  • @terdon vlc, audacious both display fine. You might need to specify --to-v2.4 if you start with a v2.3 file to begin with. – Anthon Feb 9 '14 at 16:58
  • It worked! eyeD3 --encoding utf8 -a "Ю" abc.mp3 had success! – Sigur Feb 9 '14 at 17:10
  • Thanks, Anthon, I think id3tool only works with v1. @Sigur I've changed my answer to use eyeD3 as suggested by Anthon. – terdon Feb 9 '14 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.