no inputstream?

John Krukoff jkrukoff at ltgc.com
Thu May 15 19:11:22 EDT 2008


On Thu, 2008-05-15 at 15:35 -0700, max wrote:
> On May 15, 6:18 pm, MRAB <goo... at mrabarnett.plus.com> wrote:
> > On May 15, 9:00 pm, max <maxwell.newla... at gmail.com> wrote:
> >
> > > you're right, my java implementation does indeed parse for Id3v2
> > > (sorry for the confusion).  i'm using the getrawid3v2() method of this
> > > bitstream class (http://www.javazoom.net/javalayer/docs/docs0.4/
> > > javazoom/jl/decoder/Bitstream.html) to return an inputstream that then
> > > i buffer and parse.  apologies if i misrepresented my code!
> >
> > > back to python, i wonder if i'm misusing the mutagen id3 module.  this
> > > brief tutorial (http://www.sacredchao.net/quodlibet/wiki/Development/
> > > Mutagen/Tutorial) leads me to believe that something like this might
> > > work:
> >
> > > from mutagen.mp3 import MP3
> > > id3tags = MP3(urllib2.urlopen(URL))
> >
> > > but this gives me the following TypeError: "coercing to Unicode: need
> > > string or buffer, instance found".  does this mean i need to convert
> > > the "file-like object" that is returned by urlopen() into a unicode
> > > object?  if so, do i just decode() with 'utf-8', or is this more
> > > complex?  as of now, doing so gives me mostly "No such file or
> > > directory" errors, with a few HTTP 404s.
> >
> > [snip]
> > I think it's expecting the path of the MP3 but you're giving it the
> > contents.
> 
> cool, so how do i give it the path, if not in the form of a URL
> string?  maybe this is obvious...
> --
> http://mail.python.org/mailman/listinfo/python-list

It doesn't look like you can, with mutagen. So, time to find a different
library that supports arbitrary file objects instead of only file paths.
I'd suggest starting here:
http://pypi.python.org/pypi?%3Aaction=search&term=id3&submit=search

Possibly one with actual documentation, since that would also be a step
up from mutagen.

-- 
John Krukoff <jkrukoff at ltgc.com>
Land Title Guarantee Company




More information about the Python-list mailing list