Skip to content

Instantly share code, notes, and snippets.

@Nithanim
Created December 26, 2019 18:49
Show Gist options
  • Save Nithanim/d5db25bb175e500fac3f9ce879a7781c to your computer and use it in GitHub Desktop.
Save Nithanim/d5db25bb175e500fac3f9ce879a7781c to your computer and use it in GitHub Desktop.
Download twitch broadcasts with youtube-dl including chat with help of PetterKraabol/Twitch-Chat-Downloader
#!/bin/bash
# This file is in the same folder as the other file below. Is called by youtube-dl after the download as "processor".
# We get the filename as parameter and extract the video id from it. Then we pass it to "tcd", the chat downloader.
# Finally, we change the filename of the downloaded chat to match the filename of the downloaded video.
filename="$1"
id=$(echo "$filename" | sed -En 's/v([0-9]+)-.*/\1/p')
tcd --format irc --video "$id"
mv "${id}.log" "${filename%.*}.chat"
#!/bin/bash
# This is the main script executed. It calls the chat downloading script above as processor after the download.
# The format of the output filename is important because the chat script extracts the video id from it.
youtube-dl --download-archive "archive.log" -i --add-metadata --embed-thumbnail -f "best" --merge-output-format mkv -o "%(id)s-%(title)s.%(ext)s" -a urls.txt --exec "./dl_twitch_chat.sh {}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment