Python script to convert the Json containing all the chat of Twitch, to the Youtube Timed Text subtitle format (YTT).
- Use the users' colors
- Create a unique color for users who don't have one
- Display the subtitles in chat order (new at bottom). Do this by compiling collisions
- Display the chat at the bottom left of the screen
- Display unicode emojis
- Doesn't show Twitch only emojis (show only their names)
- Doesn't show users' badges
Either make it executable (chmod +x
), or just run python3 convert-combined-ytt.py twitchChat.json
. It will write the output to the console. You can save the file by redirecting the output with >
:
python3 convert-combined-ytt.py twitchChat.json > twitchChat.ytt
You can also use a second command line argument to set an output file. It's probably needed if your console/cmd is not in UTF-8. Beware, it'll write to the file without any confirmation asked if the file exists, overwritting it by default.
python3 convert-combined-ytt.py twitchChat.json twitchChat.ytt
You can use Twitch Downloader to download the JSON of the Twitch Chat :
TwitchDownloaderCLI -m ChatDownload -u videoID -o videoID.json
I also used YTSubConverter extensively to understand the YTT format. Note that they implemented at my request a feature to handle the reverse order of Collision in .ass format, allowing for chat order of subtitles (new at bottom).
This tool is great, so don't hesitate to use it if it fits your needs more.
Note that in order to do this script, I also made JSON to .ssa and JSON to .ass converters. If you want them, ask and I'll add them.
The script may have bugs. I didn't test it extensively. But looks good as far as I know. Don't hesitate to comment if you find bugs.
Thanks :)
Ah I think it's a Windows problem :
I'm on Linux, and everything, from the files to the console is in UTF-8. I suspect that the console/cmd in Windows is not in UTF-8 and so, it can create issues. It looks like you are in Windows-949, or Unified Hangul Code.
In any case, there are possibly two somewhat easy solutions to this issue. Either you switch to UTF-8 (just kidding), or instead of outputting to the console, I output to a file.
So, I replaced the last line
by
which means that if there is another thing in the command line, it will be used as an output file. Beware, it will do it even if the file already exist.
I'll update the files above to reflect that change, and I'll add the encoding as well.
Please tell me if it works :)