YouTube 提供了在直播中发送字幕的可能性,如记录 here .但是,本指南引用了 Youtube Studio Classic 中的链接,该链接已不存在。在新的直播控制室里,我只能找到一个字幕链接,看起来像
http://upload.youtube.com/closedcaption?cid=....
并且不包含ns
或sparams
等参数。
如何为直播控制室提供字幕?其他页面上也有一些误导性信息 - 我可以只使用简单的 HTTP POST 还是需要购买 supported softwares 中的一个? ?
如果无法使用 POST,我可以使用 Livestreaming API 吗?
最佳答案
它适用于我使用以下 python 代码。
import time
import requests
from datetime import datetime
word = "this is caption " + str(seq)
ytlink = "http://upload.youtube.com/closedcaption?cid=xxx-xxx-xxx-xxx="+str(seq)
post_fields = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + ' \n' + word + '\n'
headers = {'content-type': 'text/plain'}
r = requests.post(url=ytlink, data=post_fields.encode('utf-8'), headers=headers)
print(ytlink)
print(r.text)
基本上其他的都不需要了。
关于http - 如何为 YouTube 直播添加字幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61210976/