LifeActor / ykdl

a video downloader focus on China mainland video sites.(一款专注于中国大陆视频网站的视频下载器。)
https://github.com/LifeActor/ykdl
Other
1.45k stars 285 forks source link

Huya live offline #606

Closed fraic closed 2 years ago

fraic commented 2 years ago

虎牙直播有时会错误提示未开播

看了一下,原因是 stream 有一定概率直接返回json 不经过base64编码

SeaHOH commented 2 years ago

确实是,不过我暂时没精力顾到这边,欢迎各路高手 PR。 :smile_cat:

fraic commented 2 years ago

粗略改了一下,只是能用不知道会不会有问题,不提交PR了

def prepare(self):
        info = MediaInfo(self.name, True)

        html  = get_content(self.url)
        json_stream = match1(html, '"stream": "([a-zA-Z0-9+=/]+)"')
        isbase64 = True
        if not json_stream:
            json_stream = match1(html, 'stream: ({[^;]+)')
            isbase64 = False
        assert json_stream, 'live video is offline'
        data = json.loads(base64.b64decode(json_stream).decode()) if isbase64 else json.loads(json_stream[:-1])
        self.logger.debug('data:\n%s', data)
        #assert data['status'] == 200, data['msg']
bigmangos commented 2 years ago

目前是稳定返回不用base64编码的json了吧

SeaHOH commented 2 years ago

终于稳定,已改好。