7

I'm trying to use the mutagen module to read the metadata of an mp3 file. The problem is that the module is expecting a local mp3 file, but my mp3 files are on a remote server.

This is the line in the module that raises an error when I send a remote mp3 URL as the first parameter.

fp = file(f, "rb")

How can I alter this line of code so that it can open a remote file (e.g. http://remotedomain.com/file.mp3) in rb mode?

Balanivash
  • 6,709
  • 9
  • 32
  • 48
sujjj
  • 73
  • 1
  • 3
  • 1
    +1 to counteract downvote. the question was worded clearly and the OP made an effort. this is what SO is all about, guys. – jcomeau_ictx Jul 01 '11 at 05:03

2 Answers2

8
fp = urllib2.urlopen("http://remotedomain.com/file.mp3")

binary mode is default

jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107
4

file() can not be used to fetch arbitrary URLs.

See

http://docs.python.org/dev/howto/urllib2.html