我正在开发一个可以提取 mp3 文件的 ID3 标签的 python 程序。我正在使用 urllib2 检查 URL 的 MIME 类型(如果它是 audio/mpeg),之后我需要找到关于这个 MP3 文件的信息。
问题是,我不想在我的 PC 中完全加载那个 Mp3 文件,我只想提取 ID3 标签?那么是否可以在不完全下载 MP3 文件的情况下提取它们,因为下载会减慢我的进程?
请提出一些建议。
谢谢,
最佳答案
您可以进行部分下载:Download file using partial download (HTTP) (如果服务器支持的话)
重新阅读并看到 joelhardi 的评论后,这就更容易了:
jcomeau@intrepid:/tmp$ python
Python 2.6.6 (r266:84292, Apr 20 2011, 11:58:30)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.urlopen('http://latest/temp.csv')
<addinfourl at 160617676 whose fp = <socket._fileobject object at 0x9872aec>>
>>> input=_
>>> input.read(128)
'gene,species,C_frame,start_exon1,end_exon1,start_exon2,end_exon2,start_exon3,end_exon3,start_exon4,end_exon4,intron1,intron2,int'
>>> input.close()
>>>
关于python - 使用 python 提取 MP3 URL 的 ID3 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6134521/