chat downloader
v0.2.8)
聊天下载器是一种简单的工具,用于从直播,视频,剪辑和过去的广播中检索聊天消息。无需认证!
该工具分布在PYPI上,可以使用pip安装:
$ pip install chat-downloader要更新到最新版本,请在上面的命令中添加--upgrade标志。
另外,可以使用git安装该工具:
$ git clone https://github.com/xenova/chat-downloader.git
$ cd chat-downloader
$ python setup.py install usage: chat_downloader [-h] [--version] [--start_time START_TIME]
[--end_time END_TIME]
[--message_types MESSAGE_TYPES | --message_groups MESSAGE_GROUPS]
[--max_attempts MAX_ATTEMPTS]
[--retry_timeout RETRY_TIMEOUT]
[--interruptible_retry [INTERRUPTIBLE_RETRY]]
[--max_messages MAX_MESSAGES]
[--inactivity_timeout INACTIVITY_TIMEOUT]
[--timeout TIMEOUT] [--format FORMAT]
[--format_file FORMAT_FILE] [--chat_type {live,top}]
[--ignore IGNORE]
[--message_receive_timeout MESSAGE_RECEIVE_TIMEOUT]
[--buffer_size BUFFER_SIZE] [--output OUTPUT]
[--overwrite [OVERWRITE]] [--sort_keys [SORT_KEYS]]
[--indent INDENT] [--pause_on_debug | --exit_on_debug]
[--logging {none,debug,info,warning,error,critical} | --testing | --verbose | --quiet]
[--cookies COOKIES] [--proxy PROXY]
url例如,要将消息从直播到JSON文件保存,您可以使用:
$ chat_downloader https://www.youtube.com/watch ? v=jfKfPfyJRdk --output chat.json有关这些选项的说明以及高级命令行用例和示例,请咨询命令行的使用页面。
from chat_downloader import ChatDownloader
url = 'https://www.youtube.com/watch?v=jfKfPfyJRdk'
chat = ChatDownloader (). get_chat ( url ) # create a generator
for message in chat : # iterate over messages
chat . print_formatted ( message ) # print the formatted message对于先进的Python用例和示例,请咨询Python文档。
聊天项目/消息被解析为JSON对象(又称字典),应遵循类似的格式:
{
...
“ messages_id”:“ xxxxxxxxxxx”,
“消息”:“实际消息到这里”,
“ message_type”:“ text_message”,
“时间戳”:1613761152565924,
“ time_in_seconds”:1234.56,
“ time_text”:“ 20:34”,
“作者”: {
“ id”:“ ucxxxxxxxxxxxxxxxxxxxxxxxxx”,
“名称”:“ username_of_sender”,
“图像”:[
...
],,
“徽章”:[
...
这是给出的
},,
...
}
有关包含字段的广泛记录列表,请咨询聊天项字段页面。
即将推出
找到错误还是有建议?在这里提出问题。为了协助开发人员解决问题,请尽可能接近问题。
如果您想帮助改进工具,您将在我们的贡献指南中找到有关贡献的更多信息。