leosongwei / mutagen

Automatically exported from code.google.com/p/mutagen
GNU General Public License v2.0
0 stars 0 forks source link

ID3: failure to write SYLT frame on mp3 files. #94

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Dear all,

I am a new user of mutagen and my project tries to write time synchronized 
Lyrics (SYLT) on mp3 files. However, after I created one SYLT frame and added 
it to the audio dictionary, I got "ValueError" when I tried to save it. Does 
anyone know what is wrong? I suppose I didn't get the text format correctly. 
Does anyone have a template? I very much appreciate if someone met this before 
and is able to solve the problem. Below I attached the command lines executed 
and the error I got:

============================================
>>> from mutagen.id3 import ID3
>>> 
dirF='e:/project/mir_project/harmony_progression_toolbox/062_Ticket_To_Ride.mp3'
;
>>> audio=ID3(dirF);
>>> audio
{'TIT2': TIT2(encoding=3, text=[u'062_Ticket_To_Ride.mp3'])}
>>> from mutagen.id3 import SYLT
>>> 
audio.add(SYLT(encoding=3,lang='eng',format=1,type=2,desc=u'abc',text=('\x00eng\
x02\x01some lyrics\x00foo\x00\x00\x00\x00\x01bar')))
>>> audio
{u"SYLT:abc:'eng'": SYLT(encoding=3, lang='eng', format=1, type=2, desc=u'abc', 
text='\x00eng\x02\x01some lyrics\x00foo\x00\x00\x00\x00\x01bar'), 'TIT2': 
TIT2(encoding=3, text=[u'062_Ticket_To_Ride.mp3'])}
>>> audio.save()
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    audio.save()
  File "E:\Project\MIR_project\Harmony_Progression_Toolbox\Toolbox\mini_mutagen_id3tagger\mutagen\id3.py", line 365, in save
    try: f = open(filename, 'rb+')
  File "E:\Project\MIR_project\Harmony_Progression_Toolbox\Toolbox\mini_mutagen_id3tagger\mutagen\id3.py", line 443, in __save_frame
  File "E:\Project\MIR_project\Harmony_Progression_Toolbox\Toolbox\mini_mutagen_id3tagger\mutagen\id3.py", line 1026, in _writeData
    # The data length int is syncsafe in 2.4 (but not 2.3).
  File "E:\Project\MIR_project\Harmony_Progression_Toolbox\Toolbox\mini_mutagen_id3tagger\mutagen\id3.py", line 884, in write
ValueError: need more than 1 value to unpack
============================================  

Regards,

Y. Ni

Original issue reported on code.google.com by Yizhao...@googlemail.com on 12 Jul 2011 at 4:53

GoogleCodeExporter commented 9 years ago
The proper form of the SYLT text value is pairs of strings and timecodes, e.g. 
[("Foo", 1), ("Bar", 2)...], not the raw ID3 data for the frame.

Original comment by joe.wreschnig@gmail.com on 12 Jul 2011 at 8:43

GoogleCodeExporter commented 9 years ago
Great! It works perfectly. Just one more question: do the values of "encoding", 
"format" and "type" in SYLT function correspond to SYLT characters "encoding" 
(value in {0,1}), "time stamp format" (value in {1,2}) and content type (value 
in {0,1,2,3,4,5,6})? Thanks!

Original comment by Yizhao...@googlemail.com on 12 Jul 2011 at 9:02

GoogleCodeExporter commented 9 years ago
Hi again, I met the problem. I saved the tags successfully, but when I read it 
again, the SYLT frame disappear. Is it a bug of Mutagen? Very much appreciate 
if you can help! I attached the code I executed and the results I got:

==============================================
>>> from mutagen.id3 import ID3
>>> from mutagen.id3 import SYLT
>>> 
dirF='e:/project/mir_project/Harmony_Progression_Toolbox/062_Ticket_To_Ride.mp3'
;
>>> audio=ID3(dirF);
>>> audio
{'TIT2': TIT2(encoding=3, text=[u'062_Ticket_To_Ride.mp3'])}
>>> audio.add(SYLT(encoding=1,lang='eng',format=1,type=1,text=[("foo",1)]));
>>> audio
{u"SYLT:None:'eng'": SYLT(encoding=1, lang='eng', format=1, type=1, 
desc=u'None', text=[('foo', 1)]), 'TIT2': TIT2(encoding=3, 
text=[u'062_Ticket_To_Ride.mp3'])}
>>> audio.save();
>>> del audio
>>> audio=ID3(dirF);
>>> audio
{'TIT2': TIT2(encoding=3, text=[u'062_Ticket_To_Ride.mp3'])}
==============================================

Regards,

Y. Ni

Original comment by Yizhao...@googlemail.com on 13 Jul 2011 at 11:29