Python 3 - Urllib3读取互联网广播元数据

时间:2016-01-29 17:05:37

标签: python audio-streaming shoutcast urllib3

如何使用urllib3阅读有关播放歌曲的信息?我应该使用哪些标题?

putback

我试过这个。但它坚持发送请求。谁能帮我?谢谢你的回答。

1 个答案:

答案 0 :(得分:1)

以下代码返回给定流的所有标头数据。不幸的是,我无法以这种方式获得歌曲名称。

import requests

url = 'http://pool.cdn.lagardere.cz/fm-evropa2-128'

def print_url(r, *args, **kwargs):
    print(r.headers)

requests.get(url, hooks=dict(response=print_url))

输出如下:

{'icy-description': 'Evropa 2', 'Via': '1.1 s670-6.noc.rwth-aachen.de:80 (Cisco-WSA/8.8.0-085)', 'icy-genre': 'Various', 'icy-url': 'http://www.evropa2.cz', 'icy-pub': '0', 'ice-audio-info': 'ice-samplerate=44100;ice-bitrate=128;ice-channels=2', 'Date': 'Fri, 29 Jan 2016 17:24:20 GMT', 'icy-br': '128, 128', 'Content-Type': 'audio/mpeg', 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked', 'icy-name': 'Evropa 2', 'Server': 'Icecast 2.3.2', 'Cache-Control': 'no-cache'}