I have problems with writing downloading subtitles on Raspberry Pi with bash script.
The issue is I would like to have 1 script running with cron every hour or so that would download subtitles for new video files in some directory.
There is a program called qnapi that automatically downloads subtitles in the correct format in the directory but it works for 1 folder and always re-downloads subtitle files.
usage is:
qnapi /path/to/folder
So what I've found is
find /media/pi/RaspStorage -iname "*.mkv"
basically gives me a list of all movie files. Now I would like to somehow compare if a *.srt subtitle file with a same base name exists and if no then somehow loop through all found files with qnapi command. Write it in a bash script and cron it.
thanks for help :)
I got it working
#!/bin/bash
echo "Updated DLNA folder"
sudo minidlnad -R
for file in $(find /media/pi/RaspStorage -name '*.mkv' -or -name '*.avi'); do
name=${file:: -4}
ext=".srt"
name=$name$ext
if [ -f $name ]; then
echo "Napisy już ściągnięte dla:" "$(basename "$file")"
else
qnapi "$(dirname "$file")"/"$(basename "$file")"
fi
done
Works fine. All subtitles are downloading and if there are some already it's skipping