Skip to main content

Twitch application for automatically downloading streams

Project description

Twitch-Recorder

twitch-recorder

PyPI - Python Version PyPI - Version PyPI - License

Twitch application for automatically downloading streams as they go live.
Particularly useful for archiving streams that have disabled VODs.

Installation

twitch-recorder can be installed from PyPI and Nix/NixOS as a package or configured as a service with the module from stackpkgs.
After installing you should be able to run twitch-recorder from the terminal.

PyPI

pip install twitch-recorder

Nix/NixOS

# Install just the package
environment.systemPackages = [
    pkgs.stackpkgs.twitch-recorder
];

# Or configure the service
services.twitch-recorder = {
    enable = true;

    # You can use environment file to safely store client details
    environmentFile = "/var/lib/secrets/twitch-recorder.env";
    settings = {
        twitch = {
            client_id = "$CLIENT_ID";
            client_secret = "$CLIENT_SECRET";
            token = "$TOKEN";
        };
    };
};

Configuration

twitch-recorder is configured using TOML, an example configuration file with defaults can be found here.

On Linux and macOS, configuration file can be placed at the following paths, in order of priority:

  1. $XDG_CONFIG_HOME/twitch-recorder.toml
  2. $HOME/.config/twitch-recorder.toml
  3. /etc/twitch-recorder.toml

On Windows, the file should be placed at %APPDATA%/twitch-recorder/twitch-recorder.toml

You can also specify path to the configuration file by setting environment variable TWITCH_RECORDER_CONFIG or with command line flags -c and --config.

In the config you need to set client ID, client secret and token provided by Twitch for your application, as well as a list of users to watch.

Registering application and obtaining the user token

To register application for use with twitch-recoder, go to this page on Twitch developer console.

On the page, fill in the details and click the create button. Make sure the redirect URL is set to something local (e.g. https://localhost) and client type is set to "Confidential". Next, click on the application you just created and press "New secret key" button. Now copy the client ID and the client secret from respective fields and put them to your config.

To obtain the user token you need to authorize the application using your Twitch account by going to this URL:

https://id.twitch.tv/oauth2/authorize?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&redirect_uri=REDIRECT_URI&response_type=token&scopes=

Replace CLIENT_ID, CLIENT_SECRET and REDIRECT_URI with values for your application.

After authorization Twitch will redirect you to a URL similar to:

https://localhost/#access_token=TOKEN$&scope=&token_type=bearer

Where TOKEN is the token you should put in your config.

Limitations

  • You cannot watch more than 10 unauthorized users per client ID and token pair. This is a limitation imposed by Twitch for their EventSub API. Note, users that have authorized your application do not count towards this limit.
  • Ad stubs may appear in the resulting videos. There isn't much twitch-recoder can do about this, as the issue is on yt-dlp side.

Development

twitch-recorder requires the following tools for development:

  • uv - building and managing the Python project;
  • ruff - linter and code formatter;
  • mypy - type checking;

Install them on your system or use virtualenv. You can also use provided development shell for Nix.

Used libraries

  • TwitchIO - interacting with Twitch API
  • yt-dlp - downloading the actual video streams
  • pyserde - serde-like style deserialization for configuration

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_recorder-0.9.0.tar.gz (8.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_recorder-0.9.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file twitch_recorder-0.9.0.tar.gz.

File metadata

  • Download URL: twitch_recorder-0.9.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for twitch_recorder-0.9.0.tar.gz
Algorithm Hash digest
SHA256 fc204a0e682d8f0e362cfcfdfe5ae31d25a2a7b5adfd00b987c3beb7fc2b074a
MD5 9e5d113a8824d243615e7bf35be74a21
BLAKE2b-256 295b980d1be5de53b687ae4e9dcd3b03480d6c614f41af0819464de39367361e

See more details on using hashes here.

File details

Details for the file twitch_recorder-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: twitch_recorder-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for twitch_recorder-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0044bec8b515be41bb36b25811ba0b925aa37cd174aab6e8517d6fb686b6e9fe
MD5 dc4796500cbcd6030b32246334451636
BLAKE2b-256 a7cf2fd922d52a4b7ad36798dc401aedb77253202f61d0ac2ecdc714adebc271

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