This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
DefaultProcessor_
taizan-hokuto edited this page Nov 15, 2020
·
10 revisions
DefaultProcessorは、pytchatの既定のChat Processorです。
import pytchat
chat = pytchat.create(video_id="uIx8l2xlYVY", processor=DefaultProcessor())
while chat.is_alive():
for c in chat.get().sync_items():
print(f"{c.datetime} [{c.author.name}]- {c.message}")
description | return value |
---|---|
チャットデータのリストを返します。 | チャットデータのリスト |
description | return value |
---|---|
チャットデータのイテレータを返します。チャットアイテム1件ごとに自動的に計算された時間だけ停止(time.sleep() )します。 |
チャットデータのイテレータ |
description | return value |
---|---|
チャットデータの非同期イテレータを返します。チャットアイテム1件ごとに自動的に計算された時間だけ停止(await asyncio.sleep() )します。 |
チャットデータの非同期イテレータ |
async_items()を使用する際は、下記のようにasync for
構文を使用します。
async for c in chat.get().async_items():
print(c.json())
チャットデータのJSONフォーマット文字列を返します。 get()で取得できるチャットデータのリストおよび、個々のチャットそれぞれにjson()関数を適用することができます。
livechat = pytchat.create(video_id="xxxxxxxx")
while livechat.is_alive():
# チャットデータのリスト
chatdata = livechat.get()
print(chatdata.json())
# 個々のチャット
for c in chatdata.items:
print(c.json())
time.sleep(5)
description |
---|
次のチャットが表示されるまで待ちます. |
description |
---|
(LiveChatAsync使用時のみ有効)次のチャットが表示されるまで待ちます。この関数はawaitをつけて呼び出さなければなりません。 |
name | type | remarks |
---|---|---|
type | str | "superChat","textMessage","superSticker","newSponsor" |
id | str | チャットの個別ID |
message | str | カスタム絵文字は ":(テキスト):"のように表示されます。 |
messageEx | str | メッセージおよびカスタム絵文字のリスト。カスタム絵文字は画像URLとして表示されます。 |
timestamp | int | チャット投稿時刻(unixタイムスタンプ、ミリ秒) |
datetime | str | 例: "2019-10-10 12:34:56" |
elapsedTime | str | 経過時間 (例 "1:02:27") *リプレイモードのみ対応 |
amountValue | float | スパチャの金額部分(例: 1,234.0) |
amountString | str | スパチャの通貨+金額表示(例 "$ 1,234") |
currency | str | ISO 4217 通貨記号 (例: "USD") |
bgColor | int | メッセージの背景色(RGB) |
author | object | チャット投稿者データ。下記参照。 |
colors | object | スーパーチャット・スパーステッカーの色データ。下記参照 |
チャット投稿者データ
name | type | remarks |
---|---|---|
name | str | 投稿者名 |
channelId | str | 投稿者のユーザーチャンネルID. |
channelUrl | str | 投稿者のユーザーチャンネルURL |
imageUrl | str | 投稿者のプロフィール画像URL |
badgeUrl | str | メンバーのバッジ画像URL |
isVerified | bool | 確認済み |
isChatOwner | bool | 配信者本人 |
isChatSponsor | bool | メンバーシップ加入者(※スパチャデータの場合、メンバーか否かにかかわらず常にFalse) |
isChatModerator | bool | モデレータ |
色データ
name | type | remarks |
---|---|---|
headerBackgroundColor | int (ARGB) | type:`superChat`でのみ利用可能 |
headerTextColor | int (ARGB) | type:`superChat`でのみ利用可能 |
bodyBackgroundColor | int (ARGB) | type:`superChat`でのみ利用可能。`bgColor`と同じ値を返します。 |
bodyTextColor | int (ARGB) | type:`superChat`でのみ利用可能 |
timestampColor | int (ARGB) | type:`superChat`でのみ利用可能 |
authorNameTextColor | int (ARGB) | type:`superChat` と `superSticker`でのみ利用可能 |
backgroundColor | int (ARGB) | type:`superSticker`でのみ利用可能。`bgColor`と同じ値を返します。 |
moneyChipBackgroundColor | int (ARGB) | type:`superSticker`でのみ利用可能。 |
moneyChipTextColor | int (ARGB) | type:`superSticker`でのみ利用可能 |