python id3 tag unicode

一笑奈何 提交于 2019-12-08 10:00:46

问题


I have a mp3 with my artist tag in russian. All english meta data prints normally but the russian shows up as question marks. How can I force the module to use unicode or utf8 encoding?

python

from ID3 import *
import glob
import re
import os
for name in glob.glob('*.mp3'):
  id3info = ID3(name)
  print id3info

I am using this library: http://id3-py.sourceforge.net/


回答1:


You can't do Unicode in ID3v1, and that module only does ID3v1 (and it doesn't even do it correctly).

If you're explicitly trying to tag your files for some ID3v1-only application, then you really need to figure out how to trick that application into reading Russian characters. Most likely, that will be impossible. But if not, then you can trick your ID3v1 library into outputting strings that will trick your application, by manually pre-processing the strings.

However, if you're trying to tag your files for any modern application, just use Mutagen, Stagger, PyTagLib, or something else that's not a decade out of date. They'll all export valid Unicode in the ID3v2 tags, and do the best possible with the ID3v1 tags (which usually isn't great, but usually doesn't matter).



来源:https://stackoverflow.com/questions/10923086/python-id3-tag-unicode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!