[PY]BiliBili-Live直播间录制工具

请注意,本文编写于 3042 天前,最后修改于 1641 天前,其中某些信息可能已经过时。

详情请到Friends下的rabbit的博客查看解析。
由他的影响我也做了一个QWQ,直接上代码辣

import md5,requests,threading,time
_clock_ = 0
times = 0
def _clock():
    global _clock_
    while 1:
        _clock_ = _clock_ + 1
        time.sleep(1)
        print _clock_
        if(_clock_ == times):
            break
def _txt(start_str, end, html):
    start = html.find(start_str)
    if start >= 0:
        start += len(start_str)
        end = html.find(end, start)
        if end >= 0:
            return html[start:end].strip()
def liveURL(url):
    web = requests.get(url)
    ROOMID = 'cid=' + _txt('var ROOMID =',';',web.content)
    appkey = 'appkey=85eb6835b0a1034e'
    ts = 'ts='+str(time.time())
    players = 'player=1'
    quality = 'quality=0'
    m = md5.new()
    m.update(appkey+'&'+ROOMID+'&'+players+'&'+quality+'&'+ts)
    sign = m.hexdigest()
    web = requests.get('http://live.bilibili.com/api/playurl?'+appkey+'&'+ROOMID+'&'+players+'&'+quality+'&'+ts+'&'+sign)
    live_url = _txt('<url><![CDATA[',']]></url>',web.content)
    print live_url
    downLoad(live_url)
def downLoad(url):
    global _clock_,time
    down = requests.get(url)
    with open('D:\\'+str(time.time())+'.flv','wb') as code:
        for data in down.iter_content(chunk_size=4096):
            code.write(data)
            if _clock_ == time:
                break

if __name__ == '__main__':
    url = raw_input("Please Input Bilibili-Live's url:")
    times = int(raw_input("Please Input luzhishijian(i don't know this word for english.QVQ):"))
    t = threading.Thread(target=_clock())
    liveURL(url)
    t.start()

添加新评论

已有 2 条评论

我还想看看这场PY交易是怎样的,进来怎么不见了😂

⑨BIE ⑨BIE 回复 @兰陵

_(:3」∠)_。。。之前插件权限没设置好,导致代码显示不出来惹