youtube-dl.sh
d6817323
 #!/bin/bash
98f81a9b
 ## This Shellscript downloads all fresh videos from afirefox favorite folder. ##
 
 ## update youtube-dl ##
 ## "youtube-dl -U" or "pip youtube-dl install" ##
d6817323
 # pip install --upgrade youtube-dl
 # sleep 5
1bc42e08
 
98f81a9b
 ## Variables ##
 ## Firefox manages bookmarks from database. ##
 # #save all your Youtube playlists in $favdir ##
ea599a4a
 favdir="bestof"
d6817323
 echo $favdir
98f81a9b
 ## Download folder ##
d6817323
 dl_folder="/home/foo/Downloads/youtube-dl/"
 echo  $dl_folder
98f81a9b
 ## Date= yesterday ##
1bc42e08
 datum=$(date -d "1 day ago" '+%Y%m%d')
b5f73923
 ## Videos per day in each playlist##
d6817323
 perday=4
98f81a9b
 ## if aria2 is installed example : ##
 # aria2='--external-downloader aria2c  --external-downloader-args "-j 8 -s 8 -x 8 -k 5M"'
ea599a4a
 aria2=''
d6817323
 
98f81a9b
 ## from Firefox bookmarks ##
 ## change *default* if you have other profiles than default. ##
 ## comment if you load from array ##
d6817323
 cd ~/.mozilla/firefox/*default* || exit
353161a7
 
98f81a9b
 ## uncomment if you  load from an array ##
 ## No Firefox no variables needed ##
 # dl_folder="~/Downloads"
 # perday=4
 # dbarray=(
 # "https://www.youtube.com/user/example-foo"
 # "https://www.youtube.com/channel/example-bar/videos?sort=dd&shelf_id=0&view=0"
 # )
353161a7
 
98f81a9b
 ## comment this if you load from array ##
 ## this line puts FF favourites from sqlite3 to an array ##
e91f949c
 dbarray=( $(sqlite3 -list places.sqlite 'select url from moz_places where id in (select fk from moz_bookmarks where parent in ( select "id" from moz_bookmarks where title == "'$favdir'"))'; ))
d6817323
 
98f81a9b
 ## this  must not be commented ##
d6817323
 cd  $dl_folder || exit
b5f73923
 ## let youtube-dl do the work  and download brandnew videos##
d6817323
 # 
 for i in "${dbarray[@]}"; do
01076e72
 youtube-dl $aria2 --dateafter "$datum" --playlist-end "$perday" --max-downloads "$perday" "$i"
d6817323
 # echo $i
1bc42e08
 done
d6817323
 
98f81a9b
 ## optional ##
d6817323
 #dolphin $dl_folder