首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何发送Zoom.us meeting的隐藏字幕?

如何发送Zoom.us meeting的隐藏字幕?
EN

Stack Overflow用户
提问于 2020-07-13 20:01:10
回答 1查看 181关注 0票数 1

我一直在尝试按照Zoom的website上的说明进行操作,但每次我尝试发送字幕时都会收到400错误提示。

{"timestamp":1594640701018,"status":400,"error":"Bad Request","message":"No message available","path":"/closedcaption"}

文档显示,当会议尚未开始时,400将返回,但在我的测试场景中,我有两个设备连接到会议,并且在将隐藏字幕API令牌提供给我的测试程序之前,我从主机复制它。据我所知,这是一个开始的会议,所以一定有其他事情要做。我已经多次尝试发送请求,但仍然收到400个错误。

我使用的是Python3,我尝试过urllib.requesthttp.client,但都没有用。我遗漏了什么?

代码语言:javascript
复制
    import urllib.request
    import http.client
    third_party_api_token = input('Third Party CC Token: ')
    domain = third_party_api_token.split('/')[2]
    if 'https://' in third_party_api_token:
        domain = domain + ':443'
    else:
        domain = domain + ':80'
    seq = 1
    while True:
        input('Press Enter to continue')
        
        formatted_url = '{}&lang=en-US&seq={}'.format(zoom_cc_url, seq)
        # formatted_text = 'Hello World\n'.encode('utf-8')
        formatted_text = 'Hello World\n'    
        headers = {'Content-Type':'text/plain'}
        print(domain)
        print(formatted_url)
        try:
            # r = urllib.request.Request(formatted_url, data=formatted_text, headers=headers, method='POST')
            # with urllib.request.urlopen(r) as response:
            #     print(response.read().decode('utf-8'))
            
            conn = http.client.HTTPSConnection(domain)
            conn.request("POST", formatted_url.replace(domain, ''), body=formatted_text, headers=headers)
            res = conn.getresponse()
            data = res.read()
            print(data.decode("utf-8"))
        except Exception as e:
            print(e)
        seq += 1
EN

回答 1

Stack Overflow用户

发布于 2020-07-13 20:32:08

在代码中保留了一个旧的变量名,当我删除它时,它工作得很好。作为参考,下面的代码可以工作:

代码语言:javascript
复制
import urllib.request
import http.client
third_party_api_token = input('Third Party CC Token: ')
domain = third_party_api_token.split('/')[2]
if 'https://' in third_party_api_token:
    domain = domain + ':443'
else:
    domain = domain + ':80'
seq = 1
while True:
    input('Press Enter to continue')
    
    formatted_url = '{}&lang=en-US&seq={}'.format(third_party_api_token , seq)
    # formatted_text = 'Hello World\n'.encode('utf-8')
    formatted_text = 'Hello World\n'    
    headers = {'Content-Type':'text/plain'}
    print(domain)
    print(formatted_url)
    try:
        # r = urllib.request.Request(formatted_url, data=formatted_text, headers=headers, method='POST')
        # with urllib.request.urlopen(r) as response:
        #     print(response.read().decode('utf-8'))
        
        conn = http.client.HTTPSConnection(domain)
        conn.request("POST", formatted_url.replace(domain, ''), body=formatted_text, headers=headers)
        res = conn.getresponse()
        data = res.read()
        print(data.decode("utf-8"))
    except Exception as e:
        print(e)
    seq += 1
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62875415

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档