Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

SpeedCalculator

taizan-hokuto edited this page Jan 13, 2020 · 8 revisions

SpeedCalculator object

  • calculates speed of chatdata (per minute).

Usage

on-demand style

from pytchat import LiveChat, SpeedCalculator
chat = LiveChat(video_id = "xxxxxxxxxxx", processor = SpeedCalculator(capacity = 20)) 
while chat.is_alive():
    speed = chat.get()
    print(speed)
    time.sleep(3)

callback style

from pytchat import LiveChat, SpeedCalculator
chat = LiveChat("xxxxxxxxxxx", 
           processor = SpeedCalculator(), 
           callback = disp_speed) 
while chat.is_alive():
    time.sleep(3)

def disp_speed(speed):
    print(speed)

Constructor parameter

capacity : int

(default value = 10)

the max capacity of speed data for calculating speed.
Speed data has numbers of chat data, and start time / end time of chat.
Each speed data are stored to ring queue, so if the count of speed data exseeds capacity,
oldest item is overwritten by new one.