no inputstream?

max maxwell.newlands at gmail.com
Fri May 16 07:50:40 EDT 2008


On May 15, 10:31 pm, castironpi <castiro... at gmail.com> wrote:
> On May 15, 6:49 pm, castironpi <castiro... at gmail.com> wrote:
>
>
>
> > On May 15, 6:42 pm, John Krukoff <jkruk... at ltgc.com> wrote:
>
> > > On Thu, 2008-05-15 at 17:32 -0600, John Krukoff wrote:
> > > > On Thu, 2008-05-15 at 17:11 -0600, John Krukoff wrote:
> > > > > 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.
>
> > > > After a bit of time looking around, looks like nearly all the python id3
> > > > modules expect to work with filenames, instead of file objects.
>
> > > > I can't vouch for it, and the documentation still looks sparse, but this
> > > > module at least looks capable of accepting a file object:
> > > >http://pypi.python.org/pypi/tagpy
>
> > > > Looks like it'd be a challenge to build if you're on windows, since it
> > > > depends on an external library.
>
> > > > Alternately, you could probably create a subclass of the mutagen stuff
> > > > that used an existing file object instead of opening a new one. No idea
> > > > what that might break, but seems like it would be worth a try.
>
> > > > As last ditch option, could write the first few kb of the file out to a
> > > > temp file and see if mutagen will load the partial file.
>
> > > Okay, now I'm officially spending too much time looking through this
> > > stuff.
>
> > > However, looks like the "load" method of the MP3 class is what you'd
> > > want to override to change mutagen's file loading behavior. Probably
> > > pass the URL as the filename, and take a cut & paste version of the
> > > default load method from ID3FileType and change it to use urllib2 to
> > > open it instead of a local file open.
>
> > > Might work. Might not. No warranty express or implied.
> > > --
> > > John Krukoff <jkruk... at ltgc.com>
> > > Land Title Guarantee Company- Hide quoted text -
>
> > > - Show quoted text -
>
> > I'm supposed to question "time.toomuch.spend".  NAMERS!- Hide quoted text -
>
> > - Show quoted text -
>
> Is there a way 'time.toomuch.spend' can be scanned for in code?  If
> not, let's play!

really, really appreciate your help, john.  gonna have to ponder my
next move here...



More information about the Python-list mailing list