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”,
“圖像”:[
...
],,
“徽章”:[
...
這是給出的
},,
...
}
有關包含字段的廣泛記錄列表,請諮詢聊天項字段頁面。
即將推出
找到錯誤還是有建議?在這裡提出問題。為了協助開發人員解決問題,請盡可能接近問題。
如果您想幫助改進工具,您將在我們的貢獻指南中找到有關貢獻的更多信息。