N
N
Nikita Lubchich2014-09-23 18:29:38
Python
Nikita Lubchich, 2014-09-23 18:29:38

How to feed Mutagen a string as a file?

I need to get ID3 tags from a string (.mp3 fragments) that cannot be saved as a file and read from there. There is an idea to make a pseudo file with cStringIO, but how can it be used for that?
Mutagen (in particular, the EasyID3 module) can get these tags from a file (by querying it at a fed address), but how can you parse tags from a file as from a string? Or is there another way to solve this problem?

from mutagen.easyid3 import EasyID3
from cStringIO import StringIO

file = StringIO(first_chunk.content + last_chunk.content) 
audio = EasyID3(file) # что-то навроде такого
print audio['title']

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question