Subtitles for ITV and BBC downloads
I use qtube (that calls youtube-dl) to download files from BBC or ITV, and use this to check to see if a program has subtitles
youtube-dl --list-subs <url>
. As many will know, the downlaoded files are mp4 format, and the Humax will be able to pick up subtitles if a matching srt file has the exact name with srt extention
<filename>.srt
Background info regarding using srt files on Humax
https://wiki.hummy.tv/wiki/Custom_Firmware_Package_Notes#SRT
https://hummy.tv/forum/threads/handbrake-files-subtitles.8273/
ITV has lang
en, type
vtt. We can use the youtube-dl convert option, then change the filename slightly.
I find using these options work well
--sub-lang en --write-sub --convert-subs srt
After download, I manually locate the paired file
<filename>.en.srt
and rename it to
<filename>.srt
BBC has lang
en or
en-GB (for Click), type
ttml. The youtube-dl convert works ok for ttml (but the result is not that great for the Humax) and we still need to change the filename. I find using these options work well
--sub-lang en,en-GB --write-sub -k
After download, I manually locate the paired file
<filename>.en.ttml
or
<filename>.en-GB.ttml
convert the ttml file into srt by using python script found here
https://github.com/yuppity/ttml2srt
eg
python ttml2srt.py <filename>.en-GB.ttml <filename>.srt
So for ease of use and simplicity I just add this to the options file
/mod/etc/youtube-dl.conf
--sub-lang en,en-GB --write-sub -k
I will add
--convert-subs srt
to qtube when kicking off ITV downloads.
Note this is just a workaround for the Humax, as srt files often have suffix
en.srt
for english, but Humax expects it to be just
.srt
I tried to write this script to semi automate the process - eg calling via cron. It works on Linux Mint shell, but not on the Humax.
The offeding contruct seems to be
while IFS= read -r -d '' iitem; do
so I got stuck!
Code:
#find files of type ttml and checks to see if there is a matching srt for it.
#If srt does NOT exist, create it using the python script ttml2srt.py
#find "/mnt/hd2/My Video/60-Downloaded_Video/" -type f -name '*.en*.ttml' -print0 |
find "Documents/My tv-subtitles/" -type f -name '*.en*.ttml' -print0 |
while IFS= read -r -d '' iitem; do
# printf '%s\n' "$iitem"
ipath="${iitem%/*}"
ifilename="${iitem##*/}"
ibasename="${ifilename%%.*}"
isrtname="$ibasename.srt"
inewfile="$ipath/$isrtname"
if [ ! -f "$inewfile" ]
then
echo "Creating srt-" "$inewfile"
#python /mod/tmp/ztools/ttml2srt.py "$iitem" > "$inewfile" ;
python Documents/ttml2srt2.py "$iitem" > "$inewfile" ;
fi
done