Browse code

A notifier for KDE/Plasma. Shows newly downloaded videoclips and examples for crontab

dewomser authored on30/12/2019 13:13:16
Showing2 changed files

... ...
@@ -1,39 +1,35 @@
1 1
 #!/bin/bash
2
-
3
-## This Shellscript downloads all fresh videos from array or firefox bookmark folder with youtube playlists. ##
2
+## This Shellscript downloads all fresh videos from a firefox bookmark folder. ##
4 3
 
5 4
 ## Update your youtube-dl ! ##
6
-# "youtube-dl -U" 
5
+youtube-dl -U 
7 6
 ## or 
8 7
 # pip install --upgrade youtube-dl
9 8
 sleep 1
10
-#zaehl=0
11
-
9
+zaehl=0
12 10
 ## Variables ##
13
-## ----------important-------------
14
-## Download folder make it. mkdir ~/Downloads/youtube-dl ##
15
-dl_folder=~/Downloads/youtube-dl
16
-## Save all your Youtube playlists in FF bookmark (bestof) ##
17
-favdir="bestof"
18
-## ------------ may help----------
11
+
12
+## Save all your Youtube playlists in favdir (amp3) ##
13
+favdir="amp3"
19 14
 ## Firefox running ?
15
+# ffon=0; ps -ef|grep firefox|grep -v grep && ffon=1
20 16
 ffon=0; pgrep firefox && ffon=1
21
-## Firefox default Profil
22
-## only if you not using the default FF-profile, this line must be edited ## 
23
-# ffprofile=$(grep 'Path=' ~/.mozilla/firefox/profiles.ini | sed s/^Path=//)
17
+## Download folder ##
18
+dl_folder=~/Downloads/youtube-dl
24 19
 ## Date= yesterday ##
25 20
 datum=$(date -d "1 day ago" '+%Y%m%d')
26
-## Max. videos download in each playlist ##
21
+## Max. videos / datum to each playlist ##
27 22
 perday=4
28 23
 ## if aria2 is installed example : ##
29 24
 # aria2='--external-downloader aria2c  --external-downloader-args "-j 8 -s 8 -x 8 -k 5M"'
30 25
 aria2=''
31
-## load from "database" or "array". database == firefox SQLITE 
26
+## load from "database" or "array".
32 27
 loadfrom=database
33 28
 ## firefox database
34 29
 sqltdata=places.sqlite
35 30
 
36 31
 ## Start ##
32
+
37 33
 cd ~/.mozilla/firefox/*default* || exit
38 34
 
39 35
 if [ $ffon == 1 ] && [ $loadfrom == database ]
... ...
@@ -41,6 +37,7 @@ then
41 37
 cp $sqltdata places2.sqlite
42 38
 sqltdata=places2.sqlite
43 39
 fi
40
+
44 41
 ## only edit dbarray test-content if you want to use it
45 42
 
46 43
 if [ $loadfrom == array ]
... ...
@@ -49,8 +46,8 @@ then
49 46
  "https://www.youtube.com/user/GalileoOffiziell/videos"
50 47
  "https://www.youtube.com/user/BibisBeautyPalace/videos?sort=dd&shelf_id=1&view=0"
51 48
  "https://www.youtube.com/channel/UC53bIpnef1pwAx69ERmmOLA"
52
-)
53
- ##
49
+ )
50
+##
54 51
 ##--------------------Do not edit below this line ! -----------------------
55 52
 ##
56 53
  
... ...
@@ -62,18 +59,30 @@ fi
62 59
 cd  $dl_folder || exit
63 60
 
64 61
 ## Let youtube-dl do the work  and download brandnew videos ##
65
-## Wenn die Variable zaehl aktiviert ist, kann der parameter eingebaut werden.
66
-##--download-archive $dl_folder/archive/archive-$zaehl.txt und ((zaehl++))
67 62
 
68 63
 for i in "${dbarray[@]}"; do
69
-youtube-dl $aria2 --dateafter "$datum" --playlist-end "$perday" --max-downloads "$perday" "$i"
64
+((zaehl++))
65
+youtube-dl $aria2 --download-archive $dl_folder/archive/archive-$zaehl.txt --dateafter "$datum" --playlist-end "$perday" --max-downloads "$perday" "$i"
70 66
 # echo $i
71 67
 done
68
+##
69
+##--------------------Do not edit above this line ! -----------------------
70
+##
71
+
72
+## optional after all Downloads ##
73
+
74
+## Feedback if this script is started from crontab
72 75
 
76
+## Open folder in dolphin KDE
77
+#dolphin $dl_folder
78
+## Notifier KDE
79
+#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
73 80
 
74
-## optional ##
81
+## Notifier KDE in nice
82
+# This part of the is from now on a separated script. To get in this repository
75 83
 
76
-# dolphin $dl_folder
77
-## send-notify ##
78
-# 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
84
+# f=$(find $dl_folder -mtime 0 -type f -regex '.*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\)')
85
+# folder1=$(echo $dl_folder|sed "s/\//\\\\\//g")
86
+# f1=$(echo $f|sed "s/$folder1/\n /g")
87
+# notify-send "Neue Videos": "$f1" --icon=video-x-generic
79 88
 
80 89
new file mode 100755
... ...
@@ -0,0 +1,16 @@
1
+#!/bin/bash
2
+
3
+#This schows new Viedoclips. Script is tested with Kubuntu 19.10 and uses notify-send Popup-Window
4
+#dl_folder should be the same as in youtube-dl.sh
5
+#if you use the default,you need not edit this script.
6
+#If you want to be noticed regulary there is a line for your user crontab
7
+
8
+#0 *  * * *  XDG_RUNTIME_DIR=/run/user/$(id -u) /home/foo/bin/yt-dl-send-notify.sh
9
+
10
+
11
+
12
+dl_folder=~/Downloads/youtube-dl/
13
+f=$(find $dl_folder -mtime 0 -type f -regex '.*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\)')
14
+folder1=$(echo $dl_folder|sed "s/\//\\\\\//g")
15
+f1=$(echo $f|sed "s/$folder1/\n /g")
16
+notify-send "Neue Videos": "$f1" --icon=video-x-generic