Download both dashcams all videos

Download all videos from both cameras

This script is for the Blackvue DR-900S dashcam.

The script does the following:

  • Checks to see if the dashcam is on the network (and won’t proceed unless it is)
  • Gets list of files available
  • Sort list into alphanumeric order (so it starts with the oldest files first)
  • Checks if directory exists for the date of the file it’s processing, and if not then creates it
  • Downloads file into the corresponding directory with the same date (if doesn’t already exist)
#!/bin/bash

if ping -c 1 192.168.50.3
then
 CAR=1;
 echo "Car is on the network";
else
 CAR=0;
 echo "Car is not on the network";
fi

if [ $CAR -eq 1 ];
then

curl http://192.168.50.3/blackvue_vod.cgi | grep "mp4" | cut -d/ -f3 | cut -d, -f1  > filelistunsorted

sort -t= filelistunsorted -o filelist

while read -r line; do
 currentfile="$line";
 echo "Current file is $line";
 currentdate="$(echo $currentfile | cut -d_ -f1)"
 echo "Current date is $currentdate";
 if [ -d $currentdate ]; then
        echo "dir exists"
 else
  mkdir "$currentdate"
 fi

 cd $currentdate
 if [ -f $currentfile ]; then
  echo "File $currentfile exists. Skipping download."
 else
  echo "File $currentfile does not exist. Downloading $currentfile"
  curl "http://192.168.50.3/Record/$currentfile" > $currentfile.part
  mv $currentfile.part $currentfile
 fi
 cd ..
done < filelist

fi