Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huya live offline #606

Closed
fraic opened this issue Jul 3, 2022 · 4 comments
Closed

Huya live offline #606

fraic opened this issue Jul 3, 2022 · 4 comments
Labels

Comments

@fraic
Copy link
Contributor

fraic commented Jul 3, 2022

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

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

@SeaHOH
Copy link
Owner

SeaHOH commented Jul 6, 2022

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

@SeaHOH SeaHOH added the bug label Jul 6, 2022
@fraic
Copy link
Contributor Author

fraic commented Jul 7, 2022

粗略改了一下,只是能用不知道会不会有问题,不提交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
Copy link

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

@SeaHOH SeaHOH closed this as completed in 58e4ffd Aug 21, 2022
@SeaHOH
Copy link
Owner

SeaHOH commented Aug 21, 2022

终于稳定,已改好。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants