Created
April 12, 2022 12:09
-
-
Save geolaw/c296fbdb56e1014aa5773c64eb55a8b8 to your computer and use it in GitHub Desktop.
watches sqlite urls.db db and downloads links with youtube-dl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment