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

twitch-highlights-1.1.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twitch_highlights-1.1.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: twitch-highlights-1.1.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for twitch-highlights-1.1.1.tar.gz
Algorithm Hash digest
SHA256 2986854bd434f721f9442c4c6925ba70944cca2704de0b9f1368b127b7054af3
MD5 41179d3b1dec03a8609ea5ae9ee5ac83
BLAKE2b-256 294303961d811e380548b0a23130acf04f66377797a506dbabd41747e233597e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: twitch_highlights-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for twitch_highlights-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f46ca3e64e7e9caf9c410291d6a918640e886272d8871f68d13c316eed16042d
MD5 de809dc7cb4dcfec96643c0fc8c588fc
BLAKE2b-256 a97fced5ee2f3e0fc5ebc6ff8e787948e5e7e93cac17e14130a7ebece0bbf663

See more details on using hashes here.

Supported by

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