bottletop
Active Member
Thanks for the pointers /df, you're right about the read construct which was what I changed (after unsuccessfully trying to use awk and getting myself thoroughly confused!).
I did eventually manage to get the script working on the Humax default ash environment. I placed my files in newly created directory /mod/tmp/ztools/.
I've only got average bash scripting skills so it is a bit of a trail and error route for me.
Also great tip regarding the Python script.
This script simply renames en.srt files to .srt from ITV or calls the python script for BBC .ttml to .srt conversion
Create script /mod/tmp/ztools/srt-subtitles.sh, change "/mnt/hd2/My Video/60-Downloaded_Video/", and make script executable.
To perform the script every 30 minutes, install package
Then reboot the Humax or restart cron service
I did eventually manage to get the script working on the Humax default ash environment. I placed my files in newly created directory /mod/tmp/ztools/.
I've only got average bash scripting skills so it is a bit of a trail and error route for me.
Also great tip regarding the Python script.
This script simply renames en.srt files to .srt from ITV or calls the python script for BBC .ttml to .srt conversion
Create script /mod/tmp/ztools/srt-subtitles.sh, change "/mnt/hd2/My Video/60-Downloaded_Video/", and make script executable.
Code:
#!/mod/bin/busybox/ash
#Find files of type ttml and checks to see if there is a matching srt for it.
#If srt does NOT exist, convert ttml to srt using the python script ttml2srt.py
#or rename the en.srt file to .srt
# /mod/bin/bash /mod/bin/busybox/ash
# Note- change istartdir="/mnt/hd2/My Video/60-Downloaded_Video/" to suit your needs
ibatch=srt-subtitles.sh
echo $ibatch "..starts" $(date)
istartdir="/mnt/hd2/My Video/60-Downloaded_Video/"
find "$istartdir" -type f \( -name '*.en*.ttml' -o -name '*.en.srt' \) -print |
while IFS= read -r iitem; do
# printf '%s\n' "$iitem"
ipath="${iitem%/*}"
ifilename="${iitem##*/}"
ibasename="${ifilename%%.*}"
isuffix="${iitem##*.}"
isrtname="$ibasename.srt"
inewfile="$ipath/$isrtname"
if [ ! -f "$inewfile" ]
then
if [ "$isuffix" = "ttml" ]
then
echo "Creating srt-" "$inewfile"
python /mod/tmp/ztools/ttml2srt.py "$iitem" > "$inewfile" ;
else
echo Renaming "$iitem" to "$inewfile" ;
mv "$iitem" "$inewfile" ;
fi
fi
done
echo $ibatch "..ends " $(date)
cron-daemon
and add this to end of file /mod/var/spool/cron/crontabs/root
*/30 * * * * /mod/tmp/ztools/srt-subtitles.sh >> "/mod/tmp/srt-subtitles-"$(date +%Y%m)".log" 2>&1
Then reboot the Humax or restart cron service
service cron restart
Last edited: