Skip to main content

PyPI version Unit Tests Coverage Status

twitch_auto_clipper

Automatically create Twitch clips when chat activity spikes.

Twitch Auto Clipper monitors Twitch chat and detects moments where a large number of viewers send the same emote/message within a short period of time. When activity exceeds a configurable threshold, it automatically creates a Twitch clip.

https://github.com/user-attachments/assets/de26cc92-f84c-4ed1-9942-328684f99298

Installation

pip install twitch_auto_clipper

Requirements

Minimum Python version supported by twitch_auto_clipper is 3.10.

Quick start

from twitch_auto_clipper.TwitchAutoClipper import TwitchAutoClipper

clipper = TwitchAutoClipper(
    ["Marlon", "Lacy"],
    "YOUR_CLIENT_ID",
    "YOUR_CLIENT_SECRET",
    on_clip=lambda clip: print(clip),
    common_value=1,
    emote_value=2,
    clipable_message_ratio=0.5,
)

clipper.start()
clipper.join()

Features

  • Automatically handles Twitch OAuth token refresh
  • Automatically monitors multiple Twitch streams
  • Supports custom emotes/messages as clipping triggers
  • Optional 7TV emote support
  • Runs each streamer in separate thread

How it works

Twitch chat
     │
     ▼
Collect messages
     │
     ▼
Count messages / emotes
     │
     ▼
Detect activity spike
     │
     ▼
Threshold exceeded?
     │
    YES
     ▼
Create Twitch clip
     │
     ▼
Call on_clip callback

Usage

There are two classes that you will typically need:

  • TwitchAutoClipper — monitors Twitch chat and automatically creates clips when a message reaches the configured threshold.
  • Clip — contains information about a clip that was created.

TwitchAutoClipper

TwitchAutoClipper(
    streamers_names,
    client_id,
    client_secret,
    on_clip,
    counter_interval_seconds=...,
    clipable_message_ratio=...,
    clipable_wait=...,
    common_value=...,
    emote_value=...,
    excluded_words=...,
    logging_handlers=...,
    logging_level=...
)
Argument Description
streamers_names List of Twitch usernames to monitor. Usernames are case-insensitive and are converted to lowercase.
client_id Your Twitch application client ID. Available from the Twitch Developer Console.
client_secret Your Twitch application client secret. Available from the Twitch Developer Console.
on_clip Callback function invoked with a Clip instance when a clip is created.
counter_interval_seconds Time interval over which chat message frequencies are counted. Once the interval ends, the counters are reset.
clipable_message_ratio The weighted frequency of the most frequent message divided by the total number of messages received during the current interval. Because messages can have different values (common_value and emote_value), the ratio can exceed 1.
clipable_wait Time to wait before creating a clip after a message reaches the clipping threshold. The waiting and clipping are performed in a separate thread, so this does not block the streamer thread.
common_value Value assigned to a regular chat message. A regular message is any message that is not a 7TV emote when the streamer has a 7TV profile.
emote_value Value assigned to a 7TV emote.
excluded_words Words that should be excluded from message frequency counting.
logging_handlers Logging handlers used by the package. See examples/logger.py for an example using multiple handlers.
logging_level Logging level used by the package. See the Python logging documentation.

Clip

A Clip instance contains information about the clip that was created.

Attribute Description
message The chat message that triggered the clip.
message_count Number of occurrences of the triggering message.
ratio Ratio of the triggering message to the total number of messages received during the counting interval.
broadcaster_id Twitch broadcaster ID of the streamer for whom the clip was created. See the Twitch API documentation.
url URL of the created clip.
timestamp Expected timestamp of the event highlighted by the clip.
duration Clip duration in seconds.

Motivation

There are a lot of AI clippers that are mostly paid services, largely as a result of their high inference costs. But why use AI when, on popular streams, you constantly have thousands of people evaluating the current state of the stream through chat?

By using the audience's reactions, you can extract clips from Twitch with almost no processing power.

Roadmap

  • Analyze Twitch chat through IRC
  • Twitch OAuth authentication
  • Automatically create clips
  • Monitor multiple live streamers
  • Save clips to a log
  • Add automated tests
  • Pip package
  • Web page for constants editing

Metadata

Release files for twitch-auto-clipper 1.0.0

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

Source distribution (sdist)

Source distribution for twitch-auto-clipper 1.0.0
File Size Uploaded Provenance
twitch_auto_clipper-1.0.0.tar.gz 17.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for twitch-auto-clipper 1.0.0
File Interpreter ABI Platform
twitch_auto_clipper-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.2 kB

Release files / twitch_auto_clipper-1.0.0.tar.gz

Download URL twitch_auto_clipper-1.0.0.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5510cc135a2e3bc9ab26e8d88e284b540649d76f1092a2925e9ee799a0e78279
BLAKE2b-256 checksum
How to use checksums
fdaeb0ffcfc5979fd0246eb8f3f08ee4855fd178bf7bbeedb200ef986e56bb24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / twitch_auto_clipper-1.0.0-py3-none-any.whl

Download URL twitch_auto_clipper-1.0.0-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e2a47f5f9dbee9dbee06971006febeb840cbd898a92e03cab53b40e6585c82c
BLAKE2b-256 checksum
How to use checksums
6023096191de93d2523150fbec0ff43d2a1b08b0eea8d65ca7d4f9f724a3fdf7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for twitch-auto-clipper 1.0.0

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