GithubHelp home page GithubHelp logo

pytchat's Introduction

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.

name type remarks
type str "superChat","textMessage","superSticker","newSponsor"
id str
message str emojis are represented by ":(shortcut text):"
messageEx str list of message texts and emoji dicts(id, txt, url).
timestamp int unixtime milliseconds
datetime str e.g. "2019-10-10 12:34:56"
elapsedTime str elapsed time. (e.g. "1:02:27") *Replay Only.
amountValue float e.g. 1,234.0
amountString str e.g. "$ 1,234"
currency str ISO 4217 currency codes (e.g. "USD")
bgColor int RGB Int
author object see below

Structure of author object.

name type remarks
name str
channelId str *chatter's channel ID.
channelUrl str
imageUrl str
badgeUrl str
isVerified bool
isChatOwner bool
isChatSponsor bool
isChatModerator bool

Licence

MIT License

pytchat's People

Contributors

1jtp8sobiu avatar dependabot[bot] avatar mark-ignacio avatar miyuk avatar re2cc avatar taizan-hokuto avatar wakame1367 avatar zecktos avatar

Stargazers

 avatar  avatar

Forkers

databasedav

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.