twitch-dlp-2 Code
Brought to you by:
dragomerlin
Simple script for downloading twitch VODs from start during live broadcast.
Can also download some other VODs that are not live.
This is a fork of twitch-dlp aiming for some improvements:
0.ts_Frag1
where 0.ts
are the names as appear in the m3u8. If there's init file will start like init.mp4_Frag0
..mp4
or .ts
, otherwise warn error.init file
(for MP4 as header), by detecting the tag #EXT-X-MAP:URI=
.segments.txt
in the download dir, using in each index (position) the first segment that appears there in the playlist.twitch-batch-downloader is more feature rich for VODs that are not still live stream. Otherwise this is better.
--live-from-start
)--retry-streams DELAY
)yt-dlp
(youtube-dl
) syntaxInstall Node.js v20 or newer.
node twitch-dlp-2.js 'LINK'
# Download a VOD from start using channel link, continue until stream ends
node twitch-dlp-2 https://www.twitch.tv/xqc --live-from-start
# Download a VOD. If it's live, continue until stream ends
node twitch-dlp-2 https://www.twitch.tv/videos/2022789761
# Download live stream from the current time using streamlink
node twitch-dlp-2 https://www.twitch.tv/xqc
# Download sub-only or hidden VOD
# Follow this instructions first:
# https://github.com/DmitryScaletta/twitch-dlp/blob/master/DOWNLOAD_PRIVATE_VIDEOS.md
node twitch-dlp-2 video:xqc_51582913581_1721686515
# Check every 60 seconds is channel live
# If it's live, start to download it using streamlink
node twitch-dlp-2 https://www.twitch.tv/xqc --retry-streams 60
# Check every 60 seconds is channel live
# If it's live, start to download it's VOD from start
node twitch-dlp-2 https://www.twitch.tv/xqc --retry-streams 60 --live-from-start
# Display available formats
node twitch-dlp-2 https://www.twitch.tv/videos/2022789761 -F
# Download specified format
node twitch-dlp-2 https://www.twitch.tv/videos/2022789761 -f 480p30
# Change output template
node twitch-dlp-2 https://www.twitch.tv/videos/2022789761 -o "%(title)s [%(id)s].%(ext)s"
# Limit download rate
node twitch-dlp-2 https://www.twitch.tv/videos/2022789761 -r 720k
-h, --help Show this help message and exit
-f, --format FORMAT Select format to download
Available formats:
- best: best quality (default)
- FORMAT: select format by format_id
-F, --list-formats List available formats and exit
-o, --output OUTPUT Output filename template
Available template variables:
- %(title)s
- %(id)s
- %(ext)s
- %(description)s
- %(duration)s
- %(uploader)s
- %(uploader_id)s
- %(upload_date)s
- %(release_date)s
- %(view_count)s
--live-from-start Download live streams from the start
--retry-streams DELAY Retry fetching the list of available
streams until streams are found
while waiting DELAY second(s)
between each attempt.
-r, --limit-rate RATE Limit download rate to RATE
--keep-fragments Keep fragments after downloading
For VODs
┌─────────┬──────────────┬────────┬────────┐
│ (index) │ format_id │ width │ height │
├─────────┼──────────────┼────────┼────────┤
│ 0 │ 'Source' │ '1920' │ '1080' │
│ 1 │ '720p60' │ '1280' │ '720' │
│ 2 │ '720p30' │ '1280' │ '720' │
│ 3 │ '480p30' │ '852' │ '480' │
│ 4 │ '360p30' │ '640' │ '360' │
│ 5 │ '160p30' │ '284' │ '160' │
│ 6 │ 'Audio_Only' │ null │ null │
└─────────┴──────────────┴────────┴────────┘
For live streams (streamlink)
Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best)
Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60_alt, 720p60 (best)
--limit-rate
option)--live-from-start
)