Browse code

Variablen neu sortiert. readarray commando gefixt .

dewomser authored on20/03/2020 07:10:32
Showing1 changed files

... ...
@@ -1,37 +1,45 @@
1 1
 #!/bin/bash
2 2
 ## This Shellscript downloads all fresh videos from a firefox bookmark folder. ##
3 3
 
4
-## Update your youtube-dl ! ##
5
-#youtube-dl -U 
6
-## or 
7
-# pip install --upgrade youtube-dl
8
-sleep 1
9
-zaehl=0
10
-## Variables ##
4
+##Variables to edit from the user##
11 5
 
12
-## Save all your Youtube playlists in favdir Example amp3 ##
6
+#path to youtube-dl. If you dont know, use cli: "which youtube"#
7
+yot_dl_p="$HOME/bin/youtube-dl"
8
+# folder for the downkoaded Videos #
9
+dl_folder=~/Downloads/youtube-dl
10
+# load from "database" or "array".#
11
+loadfrom=database
12
+# If Loadfrom=database, save all your Youtube playlists in favdir example (amp3) #
13 13
 favdir="amp3"
14
-## Firefox running ? 
15
-# ffon=0; ps -ef|grep firefox|grep -v grep && ffon=1
14
+
15
+## Variables to edit carefully ##
16
+sleep 1
17
+zaehl=0
18
+# Firefox running ?#
16 19
 ffon=0; pgrep firefox && ffon=1
17
-## Download folder ##
18
-dl_folder=~/Downloads/youtube-dl
19
-## Date= yesterday ##
20
+# Date= yesterday #
20 21
 datum=$(date -d "1 day ago" '+%Y%m%d')
21
-## Max. videos / datum to each playlist ##
22
+# Max. videos / datum to each playlist #
22 23
 perday=4
23
-## if aria2 is installed example : ##
24
+# if aria2 is installed example : #
24 25
 # aria2='--external-downloader aria2c  --external-downloader-args "-j 8 -s 8 -x 8 -k 5M"'
25 26
 aria2=''
26
-## load from "database" or "array".
27
-loadfrom=database
28
-## firefox database
27
+# firefox database#
29 28
 sqltdata=places.sqlite
30 29
 
31
-## Start ##
32 30
 
33
-cd ~/.mozilla/firefox/*default* || exit
34 31
 
32
+## Update your youtube-dl ! ##
33
+$yot_dl_p -U 
34
+## or 
35
+# pip install --upgrade youtube-dl
36
+
37
+
38
+
39
+## Start ##
40
+# there should only be one default , if not change cd #
41
+cd ~/.mozilla/firefox/*default* || exit
42
+# you cannot read from a running sqlite, but to copy is allowed#
35 43
 if [ $ffon == 1 ] && [ $loadfrom == database ]
36 44
 then
37 45
 cp $sqltdata places2.sqlite
... ...
@@ -54,8 +62,9 @@ then
54 62
 else
55 63
  ## This line puts FF bookmarks from sqlite3 to an array ##
56 64
 
57
-# dbarray=( $(sqlite3 -list $sqltdata 'select url from moz_places where id in (select fk from moz_bookmarks where parent in ( select "id" from moz_bookmarks where title == "'$favdir'"))'; ))
58
-readarray -t dbarray < "$(sqlite3 -list $sqltdata 'select url from moz_places where id in (select fk from moz_bookmarks where parent in ( select "id" from moz_bookmarks where title == "'$favdir'"))'; )"
65
+#dbarray=( $(sqlite3 -list $sqltdata 'select url from moz_places where id in (select fk from moz_bookmarks where parent in ( select "id" from moz_bookmarks where title == "'$favdir'"))'; ))
66
+
67
+readarray -t dbarray < <(sqlite3 -list $sqltdata 'select url from moz_places where id in (select fk from moz_bookmarks where parent in ( select "id" from moz_bookmarks where title == "'$favdir'"))')
59 68
 fi
60 69
 cd  $dl_folder || exit
61 70
 
... ...
@@ -63,9 +72,26 @@ cd  $dl_folder || exit
63 72
 
64 73
 for i in "${dbarray[@]}"; do
65 74
 ((zaehl++))
66
-youtube-dl $aria2 --download-archive $dl_folder/archive/archive-$zaehl.txt --dateafter "$datum" --playlist-end "$perday" --max-downloads "$perday" "$i"
75
+$yot_dl_p $aria2 --download-archive $dl_folder/archive/archive-$zaehl.txt --dateafter "$datum" --playlist-end "$perday" --max-downloads "$perday" "$i"
67 76
 # echo $i
68 77
 done
69 78
 ##
70
-##--------------------The notifier for KDE is now an extra script : yt-dl-send-notify.sh ! -----------------------
79
+##--------------------Do not edit above this line ! -----------------------
80
+##
81
+
82
+## optional after all Downloads ##
83
+
84
+## Feedback if this script is started from crontab
85
+#export HOME=/home/karl
86
+#export DISPLAY=:0.0
87
+## Open folder in dolphin KDE
88
+#dolphin $dl_folder
89
+## Notifier KDE
90
+#f=$(find $dl_folder -mtime 0,2 -type f -regex '.*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\)') && notify-send "Neue Videos": "$f" --icon=video-x-generic
91
+
92
+ ## Notifier KDE in nice
93
+#f=$(find $dl_folder -mtime 0 -type f -regex '.*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\)')
94
+#folder1=$(echo $dl_folder|sed "s/\//\\\\\//g")
95
+#f1=$(echo $f|sed "s/$folder1/\n /g")
96
+#notify-send "Neue Videos": "$f1" --icon=video-x-generic
71 97