Skip to main content

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.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

witch-highlights-1.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

witch_highlights-1.1.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file witch-highlights-1.1.1.tar.gz.

File metadata

  • Download URL: witch-highlights-1.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for witch-highlights-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a970de1f9dc8949b601e3405937e527e4adc94f31ae03877a9aaf468b7664332
MD5 54930e984428333c69b80cb12656fcce
BLAKE2b-256 70e1c56a32b275823412f8e3700db69f6f96bf58f6ddecc83ec06f50237449a7

See more details on using hashes here.

File details

Details for the file witch_highlights-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: witch_highlights-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for witch_highlights-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1aa0745dc39da58cf3f01b0b25cad12703e55a5dd6c83bc3b2319e313a29e37e
MD5 8988f2b85c0236eb12dd81964bc2cfbf
BLAKE2b-256 4124279087ff2347b2b19d2731f95b6fa8aa72e323d0661c63be120a001668ff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page