Browse code

small improvements, aria2c build in , shellchecked

dewomser authored on22/05/2018 07:41:49
Showing1 changed files

... ...
@@ -1,34 +1,53 @@
1
-#! /bin/bash
2
-#This Bash-script should be executed every day (crontab -e) 
1
+#!/bin/bash
2
+#
3
+# This Shellscript downloads all fresh videos from afirefox favorite folder.
4
+# sqlite3 and youtube-dl must  be installed
5
+# 
6
+#update youtube-dl
7
+# "youtube-dl -U" or "pip youtube-dl install"
8
+# pip install --upgrade youtube-dl
9
+# sleep 5
3 10
 
4
-update youtube-dl
5
-youtube-dl -U
6
-sleep 5
7
-# fav dir
8
-# put in your favorite path
9
-favdir="auto-yt"
10
-#echo $favdir
11
+# Variables #
12
+#firefox manages bookmarks from database. 
13
+#save all your Youtube playlists in $favdir
14
+favdir="gestof"
15
+echo $favdir
16
+#Download folder
17
+dl_folder="/home/foo/Downloads/youtube-dl/"
18
+echo  $dl_folder
11 19
 #Date= yesterday
12 20
 datum=$(date -d "1 day ago" '+%Y%m%d')
21
+# Videos per day in each playlist
22
+perday=4
23
+
24
+# from Firefox bookmarks
25
+# switch to the default firefox folder with sqlite databases.
26
+# change *default* if you have other profiles than default.
27
+cd ~/.mozilla/firefox/*default* || exit
13 28
 
14
-# from array. No Firefox needed
29
+# uncomment if you  load from an array
30
+# No Firefox no variables needed 
31
+#dl_folder="~/Downloads"
32
+#perday=4
15 33
 #dbarray=(
16 34
 #"https://www.youtube.com/user/example-foo"
17 35
 #"https://www.youtube.com/channel/example-bar/videos?sort=dd&shelf_id=0&view=0"
18 36
 #)
19 37
 
20
-# from Firefox bookmarks
21
-#switch to the default firefox folder with sqlite databases.
22
-#change *default* if you have other profiles than default.
23
-cd ~/.mozilla/firefox/*default*
24
-
38
+#comment this if you load from array
25 39
 #firefox manages bookmarks from database. 
26
-#Firefox  bookmarks needs a folder auto-yt.
27
-#save all your Youtube playlists in auto-yt
40
+#Firefox  bookmarks needs a folder $favdir.
41
+#save all your Youtube playlists in $favdir
28 42
 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'"))'; ))
29
-#switch  to your youtube download folder
30
-cd ~/Downloads
31
-#let youtube-dl do the work  and download brandnew videos
32
-for i in ${dbarray[@]}; do
33
-youtube-dl --dateafter $datum --playlist-end 4 --max-downloads 2 $i
43
+
44
+#this  must not be commented
45
+cd  $dl_folder || exit
46
+# let youtube-dl do the work  and download brandnew videos
47
+# 
48
+for i in "${dbarray[@]}"; do
49
+youtube-dl --external-downloader aria2c  --external-downloader-args "-j 8 -s 8 -x 8 -k 5M" --dateafter "$datum" --playlist-end "$perday" --max-downloads "$perday" "$i"
50
+# echo $i
34 51
 done
52
+
53
+#dolphin $dl_folder