#!/bin/bash # video downloader. uses ~/urls.db as reference. # seperate script watches the clip board for any http links and puts them in the # table # all downloads to /data/p/Downloads cd /data/p/Downloads while true; do while true; do num=$(sqlite3 ~/urls.db "select count (UID) from urls where processed=0;") if [ $num -eq 0 ]; then echo "no more current URLS, sleeping for 60 seconds" break fi url=$(sqlite3 ~/urls.db "select url from urls where processed=0 limit 1;") echo "Starting $url" # use the --no-mtime to avoid old file date stamps youtube-dl -q --no-mtime "$url" # if the download failed, e.g. unsupported, whatever, then log this if [ "$?" != "0" ]; then sqlite3 ~/urls.db "update urls set processed = 2 where url='$url';" echo $line >> ~/failed_downloads else sqlite3 ~/urls.db "update urls set processed = 1 where url='$url';" notify-send "Download of $url done" echo "$url done" fi done sleep 60 done echo "db done,Reader exiting"