🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

pytchat

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pytchat

a python library for fetching youtube live chat.

0.5.5
PyPI
Maintainers
1

pytchat

pytchat is a python library for fetching youtube live chat.




Description

pytchat is a python library for fetching youtube live chat without using Selenium or BeautifulSoup.

Other features:

  • Customizable chat data processors including youtube api compatible one.
  • Available on asyncio context.
  • Quick fetching of initial chat data by generating continuation params instead of web scraping.

For more detailed information, see wiki.
wiki (Japanese)

Install

pip install pytchat

Examples

Fetch chat data (see wiki)

import pytchat
chat = pytchat.create(video_id="uIx8l2xlYVY")
while chat.is_alive():
    for c in chat.get().sync_items():
        print(f"{c.datetime} [{c.author.name}]- {c.message}")

Output JSON format string (feature of DefaultProcessor)

import pytchat
import time

chat = pytchat.create(video_id="uIx8l2xlYVY")
while chat.is_alive():
    print(chat.get().json())
    time.sleep(5)
    '''
    # Each chat item can also be output in JSON format.
    for c in chat.get().items:
        print(c.json())
    '''     

other

Structure of Default Processor

Each item can be got with sync_items() function.

nametyperemarks
typestr"superChat","textMessage","superSticker","newSponsor"
idstr
messagestremojis are represented by ":(shortcut text):"
messageExstrlist of message texts and emoji dicts(id, txt, url).
timestampintunixtime milliseconds
datetimestre.g. "2019-10-10 12:34:56"
elapsedTimestrelapsed time. (e.g. "1:02:27") *Replay Only.
amountValuefloate.g. 1,234.0
amountStringstre.g. "$ 1,234"
currencystrISO 4217 currency codes (e.g. "USD")
bgColorintRGB Int
authorobjectsee below

Structure of author object.

nametyperemarks
namestr
channelIdstr*chatter's channel ID.
channelUrlstr
imageUrlstr
badgeUrlstr
isVerifiedbool
isChatOwnerbool
isChatSponsorbool
isChatModeratorbool

Licence

MIT License

Keywords

youtube livechat asyncio

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts