Skip to main content

pyvod-chat

GitHub release (latest by date) PyPI PyPI - Downloads Downloads

Get the stream chat for a given Twitch VOD.

pyvod can be used within your own programs via pip install pyvod-chat. See Usages for how to use it.

pyvod can additionally be used as a CLI (command line interface) script (cmd/terminal). See Usages for more information.

See the documentation section for more information on the available methods.

Requirements

Also see requirements.txt.

If you want to run pyvod from a command line interface, you can install the required packages via pip install -r requirements.txt.

Optional

  • an optional .env file containing your own Twitch.tv Client-ID insde the root directory of your project (or if used via the CLI inside the pyvod-chat directory).

    Add the env-variable inside the .env file like so: twitch-client-id="CLIENT_ID"

A 'Client-ID' (public) is NOT the same as a 'Client-Secret', the latter which is not used here.

Note: if you don't specify a Client-ID, a default Client-ID will be used.

Installation (PyPI)

Available on PyPI.

pip install pyvod-chat

Usage

Note: many comments == taking quite a while. With some barebone testing, around 130.000 comments can take up to roughly 12-ish minutes (around 2400 requests in total, 200-ish per minute).

This is a result of how the Twitch API (v5) is providing the comments (each request comes with a _next param which its value HAS to be used in the next request to fetch the correct next comments), the more comments there are in the VOD, the more requests we have to make, which in turn takes more time.

Currently trying multithreading/multiprocessing out, to see if it is possible to keep the "state" steady and speeding things up.

1. within your own program

import pyvod  # or -> from pyvod import VOD

vod_id = "111111111"
vod = pyvod.VOD(vod_id=vod_id)  # VOD instance, the main entry point

vodchat = vod.get_vodchat()  # get a VODChat instance, contains the VOD chat

# fetches the comments from the VOD
# this returns a list containing VODSimpleComment (NamedTuple) objects,
# which only contain the 'name', 'timestamp', when the message has been posted and
# the 'message' content of a comment
comments = vodchat.get_comments()

# if the raw comment data (JSON) is needed, simply fetch them like so
# and process the JSON as you need it
raw_comments = vodchat.raw

# since VODSimpleComment objects are NamedTuples
# (can do anything a normal tuple does),
# there are 2 distinct ways to extract their data from the comments list

# 1. by calling the class attributes
for comment in comments:
   name = comment.name
   timestamp = comment.timestamp
   posted_at = comment.posted_at
   message = comment.message

# 2. via simple tuple unpacking
for timestamp, posted_at, name, message in comments:
   # process comment data
   print(timestamp, posted_at, name, message)

# if you want to access the VODChat comments again at a later date,
# but do not want to fetch them again from the API,
# simply use the property attribute like so
comments = vodchat.comments

# if you want to save the extracted comments and the raw JSON, simply do:
vodchat.to_file(dirpath="OPTIONAL\PATH\HERE", save_json=True)  # defaults to the current working directory via `os.getcwd()`

2. as a CLI tool in a terminal/cmd

Download the available GitHub folder by clicking on "Code" in the top right (or simply clone the repository).

Open your terminal and navigate to the root directory of: pyvod-chat

cd pyvod-chat
python -m pyvod --help

-h [--help] shows you the usage and the optional -d [-dir] parameter allows you to specify your own output directory. This defaults to the current working directory, i.e. wherever you saved the program: ..\..\pyvod-chat

A full command line could be structured like so:

python -m pyvod -v 979245105 -d C:\Users\MyUser\Documents\Scripts

Documentation

See the documentation here on GitHub: documentation page.

Changelog

See the changelog here on GitHub: changelog page.

License

MIT License. See LICENSE.

Task list

  • Potentially implement multithreading/multiprocessing for the comment fetch requests

  • Make documentation available via readthedocs.

  • Future features like filtering and sorting the comments by user, message (contains X word, etc.) and more

Metadata

Release files for pyvod-chat 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvod-chat 0.2.1
File Size Uploaded Provenance Actions
pyvod-chat-0.2.1.tar.gz 13.2 kB Without provenance Details for pyvod-chat-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyvod-chat 0.2.1
File Interpreter ABI Platform Actions
pyvod_chat-0.2.1-py3-none-any.whl Python 3 none any Details for pyvod_chat-0.2.1-py3-none-any.whl

Total release size: 27.3 kB

Release files / pyvod-chat-0.2.1.tar.gz

Download URL pyvod-chat-0.2.1.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fe4e91274a1a34cf5a51f5d2f8e19a881064967584e66bafd94d6fc90826475b
BLAKE2b-256 checksum
How to use checksums
c2c3ce622d805bd7dc087b9ae1c87ddbdcb80cb5e3e004c4d35b3feb8ba4c979
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.0

Release files / pyvod_chat-0.2.1-py3-none-any.whl

Download URL pyvod_chat-0.2.1-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd46d74a12f3bcb69a552798b5d0a81cbbdd521fc443724b2c1a09c8321ed237
BLAKE2b-256 checksum
How to use checksums
de9a75379d80c649ed849edcb37a18041308801c56efef5abae4a4149a14cf8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.0

Security for pyvod-chat 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page