Skip to main content

twitch-highlights

GitHub PyPI Project PyPI Downloads Discord

An OS-independent and easy-to-use module for creating highlight videos from trending Twitch clips. Twitch highlight videos can be created by either specifying a category or a list of streamer names.

Getting started

Installing

pip install twitch-highlights

Import

import twitch_highlights

Examples

This section will describe the functions and methods provided by the package. If you would like to get started with some example code, make sure to take a look at the examples directory.

TwitchHighlights

The class used to interact with the Twitch API and collect trending clips. By passing twitch_credentials and/or acr_credentials to the constructor, the proper authentication steps are performed to interact with the APIs. The object returned can be used to generate highlight videos.

twitch_credentials = {
   "client_id": "1at6pyf0lvjk48san9j7fjak6hue2i",
   "client_secret": "5i2c7weuz1qmvtahrok6agi7nbqo7d"
}

acr_credentials = {
   "access_key": "m73k42t5v1jttq2h4h1r41v450lgqdpl",
   "secret_key": "1haPnq6StnU6S4FqoqzOvNAzLkapbaFeG7Pj945U",   
   "host": "identify-eu-west-1.acrcloud.com"  
}

TwitchHighlights(twitch_credentials=twitch_credentials, acr_credentials=acr_credentials)

Arguments:

  • twitch_credentials: Dictionary storing the client_id and client_secret keys. Information on how to obtain these credentials can be found here.
  • acr_credentials: (optional) Dictionary storing the access_key, secret_key and, host keys. ACR is used for copyright music detection. Information on how to obtain these credentials can be found here.

make_video_by_category

Creates a highlight video consisting of trending clip from the provided category in the current directory.

highlight_generator.make_video_by_category(category = "Just Chatting", language = "en", video_length = 500)

Arguments:

  • category: Name of the category from which the clips are gathered (case-insensitive).
  • output_name: Name of the generated output mp4 file. Defaults to "output_video".
  • language: Preferred language of the clips to be included in the video. Note that the clip's language tag might not actually match the language spoken in the clip. Defaults to None, which means that no clips are removed.
  • video_length: Minimum length of the video to be created in seconds. Clips are added to the combined video until this length is reached. Defaults to 300.
  • started_at: Starting date/time for included clips as a datetime object in the UTC standard. Defaults to exactly one day before the time at which the method is called.
  • ended_at: Ending date/time for included clips as a datetime object in the UTC standard. Defaults to the time at which the method is called.
  • render_settings: Dictionary containing information used for rendering and combining the clips. More information here. Defaults to None.
  • sort_by: Preferred ordering of clips ("popularity", "chronologically", or "random"). Defaults to "popularity".
  • filter_copyright: If set to True, clips containing copyrighted music are not included in the video. Defaults to False.

make_video_by_streamer

Creates a highlight video consisting of trending clip from the provided category in the current directory.

highlight_generator.make_video_by_streamer(streamers = ["Ninja", "Myth"])

Arguments:

  • streamers: List of streamer names to gather clips from.
  • output_name: Name of the generated output mp4 file. Defaults to "output_video".
  • language: Preferred language of the clips to be included in the video. Note that the clip's language tag might not actually match the language spoken in the clip. Defaults to None, which means that no clips are removed.
  • video_length: Minimum length of the video to be created in seconds. Clips are added to the combined video until this length is reached. Defaults to 300.
  • started_at: Starting date/time for included clips as a datetime object in the UTC standard. Defaults to exactly one day before the time at which the method is called.
  • ended_at: Ending date/time for included clips as a datetime object in the UTC standard. Defaults to the time at which the method is called.
  • render_settings: Dictionary containing information used for rendering and combining the clips. More information here. Defaults to None.
  • sort_by: Preferred ordering of clips ("popularity", "chronologically", or "random"). Defaults to "popularity".
  • filter_copyright: If set to True, clips containing copyrighted music are not included in the video. Defaults to False.

get_top_categories

Returns a list of the names of the most trending categories on Twitch at the moment of invocation.

highlight_generator.get_top_categories(5)

Arguments:

  • amount: Maximum number of categories to return. Maximum: 100. Defaults to 20.

render_settings

Dictionary containing information used for rendering and combining the clips. When None is passed or if any of the keys is missing, the default values are used.

Keys:

  • intro_path: Path to the file containing the intro video that has to be added to the start of the generated video. If not specified, no intro is added.
  • transition_path: Path to the file containing the transition video that has to be added between each of the clips in the generated video. If not specified, no transitions are added.
  • outro_path: Path to the file containing the outro video that has to be added to the end of the generated video. If not specified, no outro is added.
  • target_resolution: Tuple containing (desired_height, desired_width) to which the resolution is resized. Defaults to (1080, 1920).
  • fps: Number of frames per second. Defaults to 60.

License

Apache-2.0

Contributing

So far, I have been the only one who has worked on the project, and it would be great if I could get an extra pair of hands. Feel free to contact me if you have any great ideas and would like to contribute to this project. New features I'm currently working on are:

  • Uploading the created video directly to YouTube
  • The option to have a small animation with the name of the streamer at the start of each clip

Metadata

Release files for twitch-highlights 1.1.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 twitch-highlights 1.1.1
File Size Uploaded
twitch-highlights-1.1.1.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for twitch-highlights 1.1.1
File Interpreter ABI Platform
twitch_highlights-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.7 kB

Release files / twitch-highlights-1.1.1.tar.gz

Download URL twitch-highlights-1.1.1.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2986854bd434f721f9442c4c6925ba70944cca2704de0b9f1368b127b7054af3
BLAKE2b-256 checksum
How to use checksums
294303961d811e380548b0a23130acf04f66377797a506dbabd41747e233597e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / twitch_highlights-1.1.1-py3-none-any.whl

Download URL twitch_highlights-1.1.1-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f46ca3e64e7e9caf9c410291d6a918640e886272d8871f68d13c316eed16042d
BLAKE2b-256 checksum
How to use checksums
a97fced5ee2f3e0fc5ebc6ff8e787948e5e7e93cac17e14130a7ebece0bbf663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.1

2 release files

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