Closed DarrenIce closed 2 years ago
发一下不能播的房间号吧,我随便找了两个直播间试了没发现问题。
随便试了一个,这是日志 2022-11-07 17:43:09,450 - INFO: provider: bilibili, room: 23994870, bit_rate: None 2022-11-07 17:43:09,738 - INFO: extracted url: {'http_hls_fmp4_avc': 'https://c1--cn-gotcha208.bilivideo.com/live-bvc/345924/live_1700084287_54629009/index.m3u8?expires=1667817849&len=0&oi=3707971177&pt=web&qn=10000&trid=100727267c7850f748eab6dae027e39404a6&sigparams=cdn,expires,len,oi,pt,qn,trid&cdn=cn-gotcha208&sign=fcd6379b722e630bec8e30e9b74af9df&sk=70bfbb46fa1346771bc96130a46b5c55&p2p_type=1&src=57345&sl=1&free_type=0&pp=rtmp&machinezone=jd&source=onetier&site=987d4eee5a689536a5ad6628ad073f19&order=2', 'http_hls_ts_avc': 'https://cn-sdyt-cu-01-07.bilivideo.com/live-bvc/345924/live_1700084287_54629009.m3u8?expires=1667817849&len=0&oi=3707971177&pt=web&qn=10000&trid=100327267c7850f748eab6dae027e39404a6&sigparams=cdn,expires,len,oi,pt,qn,trid&cdn=cn-gotcha01&sign=5f51ab3e458693613e76a30bce1d53dd&sk=630d3ac6733a4d7ab4e2a1e5bf5f2cf7&p2p_type=1&src=57345&sl=1&free_type=0&sid=cn-sdyt-cu-01-07&chash=1&sche=ban&score=4&pp=rtmp&machinezone=jd&source=onetier&site=987d4eee5a689536a5ad6628ad073f19&order=1', 'http_stream_flv_avc': 'https://cn-sdyt-cu-01-07.bilivideo.com/live-bvc/345924/live_1700084287_54629009.flv?expires=1667817849&pt=web&deadline=1667817849&len=0&oi=3707971177&platform=web&qn=10000&trid=100027267c7850f748eab6dae027e39404a6&uipk=100&uipv=100&nbs=1&uparams=cdn,deadline,len,oi,platform,qn,trid,uipk,uipv,nbs&cdn=cn-gotcha01&upsig=57d817f4c67c5ffc30ea4aad750efdeb&sk=630d3ac6733a4d7ab4e2a1e5bf5f2cf7&p2p_type=1&src=57345&sl=1&free_type=0&sid=cn-sdyt-cu-01-07&chash=1&sche=ban&score=4&usgroup=eg&pp=rtmp&machinezone=jd&source=onetier&site=987d4eee5a689536a5ad6628ad073f19&order=1'}
这是我用Postman请求得到的
"stream": [ { "protocol_name": "http_stream", "format": [ { "format_name": "flv", "codec": [ { "codec_name": "avc", "current_qn": 10000, "accept_qn": [ 10000, 150 ], "base_url": "/live-bvc/152988/live_1700084287_54629009.flv?", "url_info": [ { "host": "https://d1--ov-gotcha05.bilivideo.com", "extra": "expires=1667818006&len=0&oi=1915081747&pt=h5&qn=10000&trid=10004111b0cdc2f141c2988d8bd0afd7d29c&sigparams=cdn,expires,len,oi,pt,qn,trid&cdn=ov-gotcha05&sign=26326ed9d928438cd2ac5111fbd9cea7&sk=630d3ac6733a4d7ab4e2a1e5bf5f2cf7&p2p_type=0&src=57345&sl=1&free_type=0&usgroup=eg&pp=rtmp&machinezone=ylf&source=onetier&site=05b837e96699b3e07e91b65f760b92cf&order=1", "stream_ttl": 3600 }, { "host": "https://d1--ov-gotcha07.bilivideo.com", "extra": "expires=1667818006&len=0&oi=1915081747&pt=h5&qn=10000&trid=10004111b0cdc2f141c2988d8bd0afd7d29c&sigparams=cdn,expires,len,oi,pt,qn,trid&cdn=ov-gotcha07&sign=6c292779e7e227ec4144c9518ef2c99e&sk=630d3ac6733a4d7ab4e2a1e5bf5f2cf7&p2p_type=0&src=57345&sl=1&free_type=0&usgroup=eg&pp=rtmp&machinezone=ylf&source=onetier&site=05b837e96699b3e07e91b65f760b92cf&order=2", "stream_ttl": 3600 } ], "hdr_qn": null, "dolby_type": 0, "attr_name": "" } ] } ] }, { "protocol_name": "http_hls", "format": [ { "format_name": "ts", "codec": [ { "codec_name": "avc", "current_qn": 10000, "accept_qn": [ 10000, 150 ], "base_url": "/live-bvc/152988/live_1700084287_54629009.m3u8?", "url_info": [ { "host": "https://d1--ov-gotcha105.bilivideo.com", "extra": "expires=1667818006&len=0&oi=1915081747&pt=h5&qn=10000&trid=10034111b0cdc2f141c2988d8bd0afd7d29c&sigparams=cdn,expires,len,oi,pt,qn,trid&cdn=ov-gotcha105&sign=0313fa2e7ff8784477214a0ea01f9cfe&sk=630d3ac6733a4d7ab4e2a1e5bf5f2cf7&p2p_type=0&src=57345&sl=1&free_type=0&pp=rtmp&machinezone=ylf&source=onetier&site=05b837e96699b3e07e91b65f760b92cf&order=1", "stream_ttl": 3600 } ], "hdr_qn": null, "dolby_type": 0, "attr_name": "" } ] } ] } ]
Postman的参数 尝试过python或者go用相同的headers请求,不过返回的地址都是不能播放的
代码里调用的也是这个API,不过platform参数是web,不是h5。但无论platform参数是哪个,我这里测试得到的flv和fmp4格式的地址都是可以播放的。注意:ts格式的地址是无法播放的。 我测试用的房间号是47917和127343。
我又加代理试了一下,获取到的链接可以正常播放了。可能是我的Ip被限制了
我不确定是否是b站的反爬机制,我用postman和程序获取拼接的直播源并不相同,postman得到的可以播放,但是程序获取的就不可以,暂不清楚是什么原因