473,503 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RE: no inputstream?

-----Original Message-----
From: py***********************************@python.org [mailto:python-
li****************************@python.org] On Behalf Of max
Sent: Thursday, May 15, 2008 8:02 AM
To: py*********@python.org
Subject: Re: no inputstream?

On May 15, 9:51*am, castironpi <castiro...@gmail.comwrote:
On May 15, 8:37*am, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Thu, 15 May 2008 06:08:35 -0700, max wrote:
i currently have locations of the mp3s in question as strings, which
works for parsing local files, but gives me a "No such file or
directory" error when it tries to process URLs. *it seems terribly
inefficient to download each mp3 just to get at that small tag data,
and i assume there's a way to do this with file() or open() or
something, i just can't get it to work.
You can use `urllib2.urlopen()` to open URLs as files. *But if you
deal
with ID3 V1 tags you'll have to download the file anyway because those
are
in the last 128 bytes of an MP3 file.
Ciao,
* * * * Marc 'BlackJack' Rintsch
Just don't import time. *What would you do with an autolocking timer,
such as time.sleep( ) on a thread? *I am tongue tied in the presence
of a lady.
thanks guys. i guess i just figured there'd be a way to get at those
id3 bytes at the end without downloading the whole file. if java can
do this, seems like i should just stick with that implementation, no?
--
http://mail.python.org/mailman/listinfo/python-list
First off, ignore castironpi, it's a turing test failure.

Second, I'm curious as to how Java manages this. I'd think their streams
would have to be pretty magic to pull this off after the HTTP connection has
already been built.

Anyway, as I see it, this is more of a HTTP protocol question. I think what
you need to do is set the HTTP Range header to bytes=-128, see the urllib2
documentation for how. It's not that hard. Only down side is that not all
HTTP servers support the Range header, and it's an optional part of the HTTP
spec anyway. As far as I know it's the only way to get partial transfers,
though.

Also, are you sure you're dealing with v1 tags and not v2? Since v2 tags are
stored at the beginning (or sometimes end with v2.4) of the file. You might
be better off just opening the file with urllib2 and handing it off to
whatever id3 tag reading library you're using. As long as it's reasonably
smart, it should only download the part of the file it needs (which if the
tag happens to be v1, will be the whole file).

I'd love to know how Java handles all that automatically through a generic
stream interface, though.
--
John Krukoff
jk******@ltgc.com

Jun 27 '08 #1
11 1611
"John Krukoff" <jk******@ltgc.comwrites:
I'd love to know how Java handles all that automatically through a
generic stream interface, though.
It could be that their stream interface supports seek(), and that
seek()ing on HTTP connection sends the appropriate range request and,
if it fails, throws an appropriate exception which the client code
interprets as "seeking impossible, read the whole file".

But that doesn't apply to the InputStream interface described at
http://java.sun.com/j2se/1.5.0/docs/...putStream.html -- no
seeking there.
Jun 27 '08 #2
max
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.

anyway, thanks again....
On May 15, 1:02*pm, Hrvoje Niksic <hnik...@xemacs.orgwrote:
"John Krukoff" <jkruk...@ltgc.comwrites:
I'd love to know how Java handles all that automatically through a
generic stream interface, though.

It could be that their stream interface supports seek(), and that
seek()ing on HTTP connection sends the appropriate range request and,
if it fails, throws an appropriate exception which the client code
interprets as "seeking impossible, read the whole file".

But that doesn't apply to the InputStream interface described athttp://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html-- no
seeking there.
Jun 27 '08 #3
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:
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.
Jun 27 '08 #4
max
On May 15, 6:18*pm, MRAB <goo...@mrabarnett.plus.comwrote:
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:
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...
Jun 27 '08 #5

On Thu, 2008-05-15 at 15:35 -0700, max wrote:
On May 15, 6:18 pm, MRAB <goo...@mrabarnett.plus.comwrote:
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:
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?%3Aactio...&submit=search

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

--
John Krukoff <jk******@ltgc.com>
Land Title Guarantee Company

Jun 27 '08 #6

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...@mrabarnett.plus.comwrote:
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:
>
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?%3Aactio...&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.

--
John Krukoff <jk******@ltgc.com>
Land Title Guarantee Company

Jun 27 '08 #7

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...@mrabarnett.plus.comwrote:
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:

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?%3Aactio...&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 <jk******@ltgc.com>
Land Title Guarantee Company

Jun 27 '08 #8

On Thu, 2008-05-15 at 17:42 -0600, John Krukoff 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...@mrabarnett.plus.comwrote:
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:
>
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?%3Aactio...&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.
Hrm, damn, looks like you'd also have to create a custom ID3 class and
override load there too, since that gets called from the ID3FileType
load method. Definitely looks like work.
--
John Krukoff <jk******@ltgc.com>
Land Title Guarantee Company

Jun 27 '08 #9
On May 15, 6:42*pm, John Krukoff <jkruk...@ltgc.comwrote:
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...@mrabarnett.plus.comwrote:
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:
you're right, my java implementation does indeed parse for Id3v2
(sorry for the confusion). *i'm using the getrawid3v2() methodof 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?%3Aactio...&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...@ltgc.com>
Land Title Guarantee Company- Hide quoted text -

- Show quoted text -
I'm supposed to question "time.toomuch.spend". NAMERS!
Jun 27 '08 #10
On May 15, 6:49*pm, castironpi <castiro...@gmail.comwrote:
On May 15, 6:42*pm, John Krukoff <jkruk...@ltgc.comwrote:


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...@mrabarnett.plus.comwrote:
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:
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 thismight
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 toconvert
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?%3Aactio...&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...@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!
Jun 27 '08 #11
max
On May 15, 10:31*pm, castironpi <castiro...@gmail.comwrote:
On May 15, 6:49*pm, castironpi <castiro...@gmail.comwrote:
On May 15, 6:42*pm, John Krukoff <jkruk...@ltgc.comwrote:
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...@mrabarnett.plus.comwrote:
On May 15, 9:00 pm, max <maxwell.newla...@gmail.comwrote:
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 inputstreamthat 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?%3Aactio...&submit=search
Possibly one with actual documentation, since that would also be astep
up from mutagen.
After a bit of time looking around, looks like nearly all the pythonid3
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...@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...
Jun 27 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
8515
by: Seong Jin, Cho | last post by:
Hi. Is there a way to get an unbuffered InputStream from Process? I found out that java.lang.Win32Process and java.lang.UNIXProcess both wraps the stdout with java.io.BufferedInputStream, but...
1
2104
by: Charles.Deisler | last post by:
XmlTextReader requestdata = new XmlTextReader(Request.InputStream); XmlTextWriter xmltextwriter = new XmlTextWriter(somefile,someencoding); XmlTextWriter xmltextwriter2 = new...
7
6408
by: Steve Drake | last post by:
All, I have a HttpHandler that handles a PUT, if i PUT 700MEGs of data it runs out of memory, i have found that this is due to the Request.InputStream loading the entire stream when you access...
0
1728
by: Keith Harris | last post by:
Hi, I have an HtmlInputFile control which allows a user to upload a CSV file. I want to display the first few rows for preview and later, load the rows to a database. Displaying the preview...
0
2192
by: bvasanth123 | last post by:
Hi, I would like to know how can I read an InputStream into Excel object. In my web app, user uploads MS-Excel file though asp.net html file control. I get UploadedFile.PostedFile.InputStream()...
0
1606
by: bvasanth123 | last post by:
Hi, I would like to know how can I read an InputStream into Excel object. In my web app, user uploads MS-Excel file though asp.net html file control. I get UploadedFile.PostedFile.InputStream()...
1
8055
by: samtilden | last post by:
I want to print out some tracing messages from Global.asax.cs/Application_BeginRequest(). I easily got: System.Web.HttpContext.Current.Request.RawUrl, and...
1
4567
by: O.B. | last post by:
I have the need to read a file (version.txt) that is embedded within an WAR file that is within an EAR file: foo.ear contains bar.war contains resources/version.txt I am able to get the bar.ear...
0
1217
by: raheel javed | last post by:
i am using mobile for communication with live server when mobile send its information to server the input stream is encoded in utf-8 that is converted into string but it is still not...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.