http - 如何为 YouTube 直播添加字幕?
问题描述
YouTube 提供了在直播中发送字幕的可能性,如此处所述。但是,本指南引用了来自 Youtube Studio Classic 的链接,该链接已不存在。在新的直播控制室中,我只能找到一个字幕链接,看起来像
http://upload.youtube.com/closedcaption?cid=....
并且不包含类似ns
or的参数sparams
。
如何为直播控制室提供字幕?其他页面上也有一些误导性信息 - 我可以只使用简单的 HTTP POST 还是需要购买一个受支持的软件?
如果无法使用 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)
基本上,其他人将不再需要。
推荐阅读
- r - 如何根据列的内容添加 2 个数据框的大小?
- java - 哪种 Apache Camel 方法将 Java 对象转换为 XML?
- html - P 标签正在下推父 div
- excel - 使用 Shell 从 Excel VBA 运行 .command 文件
- html - 模态值绑定到表中的最后一个单元格而不是选定的一个
- mysql - 与 MyISAM 相关的数字海洋数据库问题
- c# - 将不同的随机字符组合成一个字符串
- vue.js - 如何获取动态数组的数组长度
- c++ - 如何在 Visual Studio 解决方案的附加库目录中删除 $(Configuration)?
- bash - tar:压缩和删除原始文件并保持目录不变