How to open a remote file in binary read mode?

I am trying to use mutagen module to read metadata of 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 causes the error when I send the remote mp3 address as the first parameter.

 fp = file(f, "rb") 

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

+6
source share
2 answers
 fp = urllib2.urlopen("http://remotedomain.com/file.mp3") 

default binary mode

+6
source

file () cannot be used to get arbitrary URLs.

Cm

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

+4
source

Source: https://habr.com/ru/post/891787/


All Articles