This Python script merges .vtt
subtitle files from two folders (watch
and shorts
) and combines them into merged .vtt
files. It outputs three merged subtitle files:
- One for captions from the
watch
folder. - One for captions from the
shorts
folder. - One combining all captions from both folders.
- Python 3.x
webvtt-py
library for reading.vtt
files. You can install it using pip:
pip install webvtt-py
Ensure the following folder structure:
your_project_folder/
βββ watch/ # Folder containing VTT files for "watch"
βββ shorts/ # Folder containing VTT files for "shorts"
βββ merge/ # Folder where merged VTT files will be saved
βββ merge_vtt.py # Python script (this script)
watch/
: Place.vtt
files related to "watch" content here.shorts/
: Place.vtt
files related to "shorts" content here.merge/
: The merged.vtt
files will be saved in this folder.
- Place your
.vtt
subtitle files into thewatch/
andshorts/
folders. - Run the script:
python merge_vtt.py
- The script will generate the following merged files in the
merge/
folder:watch_merge.vtt
: Merged captions from thewatch
folder.shorts_merge.vtt
: Merged captions from theshorts
folder.all_merge.vtt
: Merged captions from both thewatch
andshorts
folders.
- The script reads all
.vtt
files in thewatch/
andshorts/
folders. - It merges the captions from these files and stores the result in a new file.
- Three merged
.vtt
files are generated:watch_merge.vtt
: Contains merged captions from thewatch
folder.shorts_merge.vtt
: Contains merged captions from theshorts
folder.all_merge.vtt
: Contains merged captions from bothwatch
andshorts
folders.
The following paths are used in the script:
watch_folder
: Path to the folder containing thewatch
.vtt
files (../watch
).shorts_folder
: Path to the folder containing theshorts
.vtt
files (../shorts
).merge_results_folder
: Path to the folder where the merged.vtt
files will be saved (merge/
).
your_project/
βββ watch/
β βββ video1.vtt
β βββ video2.vtt
βββ shorts/
β βββ short1.vtt
β βββ short2.vtt
βββ merge/
β βββ watch_merge.vtt
β βββ shorts_merge.vtt
β βββ all_merge.vtt
After running the script, the merge/
folder will contain:
merge/
βββ watch_merge.vtt
βββ shorts_merge.vtt
βββ all_merge.vtt
MIT License (or your preferred license)
andrepradika
sh``` yt-dlp --write-auto-subs --skip-download --sleep-requests 1.25 --min-sleep-interval 60 --max-sleep-interval 90 -o "%(uploader)s/%(title)s.%(ext)s" "https://www.youtube.com/@MyFirstMillionPod"