With the recent changes to Twitch highlights which limit the total duration of highlights for a channel to 100 hours, there has been significant panic about the loss of Twitch VODs on speedrun.com. This program aims to assist in archiving Twitch VODs, by providing the following functions:
- Finding all runs submitted by a user OR all runs on a game leaderboard, that are hosted on Twitch, and writing that information to a file
- Downloading all runs as described above
- For runs from a game leaderboard, optionally only downloading runs from channels which have exceeded the highlight limit.
Have any questions? Ask in the official speedrun.com Discord.
For people prefering a video tutorial, here is one that helps you to setup the tool on windows.
http://www.youtube.com/watch?v=tkgnHt2aVmQ
- Download the latest release here. Be sure to download the file called "SpeedrunRescueScript_v{xxx}.zip", where {xxx} is the version number.
- Extract the zip file and open its contents.
- Run the program by clicking
speedrun_rescue.bat
, BUT DON'T DO SO YET. Read the configuration options first.
Before running the script you need to have the following tools installed:
- Python 3.x which you can download here if you have not yet: http://www.python.org/downloads/
- Install the required Python packages. The script depends on several external libraries. You can install these using pip and the requirements.txt file you find in this project as well.
- Click the Code button on top of the webpage and press download Zip. If you are an advanced user, clone the repository.
- Unpack the zip file or go into the folder and open a command line. If you are on Windows you can do that by clicking into the Link field in windows explorer and typing in cmd.
- Install all the dependencies using the following command (copy pasting this into the command prompt)
pip install -r requirements.txt
- Make sure to have ffmpeg installed. This script is using yt-dlp which absolutely requires ffmpeg. Look for an installation guide for installing ffmpeg. You can download it here on their official website
To run the script, run python speedrunrescue.py
. Please read the configuration options below.
Options to the program are provided in a file called config.yml
, in the same folder as the script (For executable users, do not worry, where config.yml is placed is correct).
Telling the program what to do is very simple. The program is controlled by options, which dictates one aspect of what the program should do.
To specify an option:
- Find an empty line to place the option.
- Place the option name, e.g.
username
, followed by a colon and a space (:
), followed by the option value, e.g.luckytyphlosion
.
For this example, the full option would be:
username: luckytyphlosion
You should not list the same option multiple times. For example, do not do this:
username: luckytyphlosion
username: Matse007
This is important as in the pre-made config.yml
in the executable release, some options have already been specified, so you should not add multiple of the option.
Sometimes, you may to ignore an option in your configuration. There are two ways to do this.
- Add a
#
at the start of the option. For example,#username: luckytyphlosion
- Remove the option entirely by deleting the line.
There are two ways of editing config.yml
, depending on your purposes. These two are explained below.
-
Ignore the
game
option if it is there and not ignored already. -
Specify an option called
username
. The value should be the speedrun.com username for which you want to download runs from. -
Optionally, you can specify the option
video-folder-name
, which will control the folder where your videos are stored. You can get the folder name by double clicking the address bar in Windows Explorer of the folder you want. Note that you must use forward slashes as path separators, e.g.D:\speedrunrescuescript\videos
must becomeD:/speedrunrescuescript/videos
. If you aren't sure, leave it asvideos
. -
Ignore the
app-id
andapp-secret
options if they exist. -
Specify the
download-videos
option, by puttingtrue
if you want to fetch information about the user's runs and download the videos, orfalse
if you only want to fetch the information. -
Optionally, you can specify a video quality target using the
video-quality
option. The value should either be the video quality or the video height which you want to target, e.g."360p"
,"720"
,"1080p"
,"542"
. It can also be"best"
, which will just automatically download the highest quality video. The program will default to"best"
is this option is omitted. THIS OPTION SHOULD BE IN QUOTES, i.e. do"360p"
, not360p
. In case the specified quality cannot be found, the program will try to find an adjacent quality and download that. Add>=
before the quality to download the closest higher quality, e.g.">=480p"
, and>=
to download the closest lower quality, e.g."<=480p"
. If neither are specified, the program assumes>=
is chosen. For example, if a video has the quality options 360p and 542p, this is the logic of>=
and<=
:>=480p
: Will download 542p, as it is the next higher quality<=480p
: Will download 360p, as it is the next lower quality
Sometimes, the lower quality encodes Twitch produces are greater in size than the lower quality resolutions (e.g. viewing the sizes of this video using TwitchDownloader says that the Source resolution is smaller than 480p). After deciding the desired quality, the program will check if this is the case, and download the Source quality if it is smaller than the initial desired quality.
-
Specify the
ignore-links-in-description
option withtrue
if want to ignore video links that are posted in the run description and only check video links in the submission field, andfalse
if you want to check links from both the submission field and the description. Not recommended as some people put other parts of the run in the description. -
Specify the
safe-only-pbs
option withtrue
if you want to only want to consider your own pbs orfalse
if you want to include obsolete runs. This option does only work on a user as of right now. -
Optionally you can specify the
concurrent-fragments
option with a postive integer of how many video fragments you want to download concurrently. Note that this will create the specified number of threads so if your system can't handle this leave this at 1.
Here is an example config that will download twitch runs from speedrun.com user luckytyphlosion.
# Specify either a game or a speedrun.com username
username: "luckytyphlosion"
# The output folder of the videos. Stored on a separate drive in this example
video-folder-name: D:/speedrunrescuescript/videos
# Whether to download the videos or just look at the output
download-videos: true
#specify the desired videoquality ranges from 160 - 1080. Can be left empty, it will default to the best quality.
video-quality: ">=1080p"
#specify if you explicitly want to ignore links that are posted in the run description and only check submission videos.
ignore-links-in-description: false
#specify if you explicitly only want to only look at your personal bests.
safe-only-pbs: true
#amount of concurrent video fragments that you want to download concurrently. Note that this will create the specified number of threads so if your system can't handle this leave this at 1.
concurrent-fragments: 1
Before you start, you must set up a Twitch API App. You will only need to do this once. Instructions are provided below. You can also read Twitch's official instructions here.
- Enable two-factor authentication (2FA) for your account. This is required in order to create apps. To enable 2FA, navigate to Security and Privacy, and follow the steps for enabling 2FA under the Security section.
- Log in to the developer console using your Twitch account.
- Select the Applications tab on the left side and then click Register Your Application.
- Set the Name of your application to anything (I used "Highlight Limit Detector").
- Set the OAuth Redirect URLs to
http://localhost
. Do not click Add. - Set the Category of your application to something fitting (I used "Analytics")
- Keep the Client Type as Confidential.
- Click Create to make your app. You may need to solve a Captcha.
- Back in the Applications tab, locate your app under Developer Applications, and click Manage.
- Scroll down to the Client ID and save the text in the textbox (looks like a random string of characters) for later.
- Under Client Secret, click the New Secret button, confirm with OK, and then save the text that is shown for later. This will disappear after you leave the page, so be sure to save it somewhere safe.
- WARNING: DO NOT SHARE THIS CLIENT SECRET. Letting it become public can lead to people abusing the API with YOUR account, and can possibly lead to you getting banned from Twitch.
-
Ignore the
username
option if it is there and not ignored already. -
Specify an option called
game
. The value should be the speedrun.com game abbreviation of the leaderboard you want to download. You can find the abbreviation in the url of a leaderboard, afterspeedrun.com
. For example, the abbreviation of http://speedrun.com/sm64 issm64
. -
Optionally, you can specify the option
video-folder-name
, which will control the folder where your videos are stored. You can get the folder name by double clicking the address bar in Windows Explorer of the folder you want. Note that you must use forward slashes as path separators, e.g.D:\speedrunrescuescript\videos
must becomeD:/speedrunrescuescript/videos
. If you aren't sure, leave it asvideos
. -
Specify the
app-id
option. The value should be the Client ID which you saved earlier. -
Specify the
app-secret
option. The value should be the Client Secret which you saved earlier. -
Specify the
download-videos
option, by puttingtrue
if you want to fetch information about the user's runs and download the videos, orfalse
if you only want to fetch the information. -
Specify the
allow-all
option. This should befalse
if you only want to download videos of channels who have not reached the 100h limit, ortrue
if you want to download all runs regardless. -
Optionally, you can specify a video quality target using the
video-quality
option. The value should either be the video quality or the video height which you want to target, e.g."360p"
,"720"
,"1080p"
,"542"
. It can also be"best"
, which will just automatically download the highest quality video. The program will default to"best"
is this option is omitted. THIS OPTION SHOULD BE IN QUOTES, i.e. do"360p"
, not360p
. In case the specified quality cannot be found, the program will try to find an adjacent quality and download that. Add>=
before the quality to download the closest higher quality, e.g.">=480p"
, and>=
to download the closest lower quality, e.g."<=480p"
. If neither are specified, the program assumes>=
is chosen. For example, if a video has the quality options 360p and 542p, this is the logic of>=
and<=
:>=480p
: Will download 542p, as it is the next higher quality<=480p
: Will download 360p, as it is the next lower quality
Sometimes, the lower quality encodes Twitch produces are greater in size than the lower quality resolutions (e.g. viewing the sizes of this video using TwitchDownloader says that the Source resolution is smaller than 480p). After deciding the desired quality, the program will check if this is the case, and download the Source quality if it is smaller than the initial desired quality.
-
Specify the
ignore-links-in-description
option withtrue
if want to ignore video links that are posted in the run description and only check video links in the submission field, andfalse
if you want to check links from both the submission field and the description. Not recommended as some people put other parts of the run in the description. -
Specify the
safe-only-pbs
option withtrue
if you want to only want to consider your own pbs orfalse
if you want to include obsolete runs. This option does only work on a user as of right now. -
Optionally you can specify the
concurrent-fragments
option with a postive integer of how many video fragments you want to download concurrently. Note that this will create the specified number of threads so if your system can't handle this leave this at 1.
Here is an example config that will download twitch runs from the speedrun.com leaderboard for Rockman EXE 4.5: Real Operation.
# Specify either a game or a speedrun.com username
game: "mmbn4.5"
# The output folder of the videos. Stored on a separate drive in this example
video-folder-name: D:/speedrunrescuescript/videos
# Whether to download the videos or just look at the output
app-id: e3udyluhnly6q6g2qp5a00nwaz73dj
app-secret: n8p6t5qy6f33lnm3v8jjgwliqazps0
download-videos: false
allow-all: false
#specify the desired videoquality ranges from 160 - 1080. Can be left empty, it will default to the best quality.
video-quality: ">=1080p"
#specify if you explicitly want to ignore links that are posted in the run description and only check submission videos.
ignore-links-in-description: false
#specify if you explicitly only want to only look at your personal bests.
safe-only-pbs: true
#amount of concurrent video fragments that you want to download concurrently. Note that this will create the specified number of threads so if your system can't handle this leave this at 1.
concurrent-fragments: 1
If download-videos
is false
, you can edit the list of files that would be downloaded. For downloading user runs, the relevant files are in output/user/<username>
. For downloading leaderboard runs, the relevant files are in output/game/<game>
.
You can delete lines in remaining_downloads.json
to omit downloading certain files. This can be useful if you want to avoid downloading runs which you know have a mirror elsewhere. Note that if you choose not to process the "remaining downloads file", this file will be overwritten, so please keep a backup somewhere.
Q: I'm getting outdated information from speedrun.com/Twitch. How do I fix this?
A: To get updated information from speedrun.com, delete the folder named srcom_cached
. To get updated information from Twitch, delete the file named twitch_cache.json
. It is recommended to do this infrequently in order to save time by not issuing requests for information which is mostly up-to-date.