clipdl


Logs | Files | README | LICENSE | GitLab


1
commit 18cbb1c4f1a0b8f723f805e4dc55a15a367d1edf
2
Author: Connor Etherington <[email protected]>
3
Date:   Wed May 18 09:25:15 2022 +0200
4
5
    Update.
6
---
7
 PKGBUILD       |  4 ++--
8
 usr/bin/clipdl | 43 +++++++++++++++++++++++++++----------------
9
 2 files changed, 29 insertions(+), 18 deletions(-)
10
11
diff --git a/PKGBUILD b/PKGBUILD
12
index b38122f..4a1a4cb 100644
13
--- a/PKGBUILD
14
+++ b/PKGBUILD
15
@@ -1,7 +1,7 @@
16
 # Maintainer: Connor Etherington <[email protected]>
17
 # ---
18
-pkgname=clipdl;
19
-pkgver=1.1
20
+pkgname=clipdl
21
+pkgver=1.2
22
 pkgrel=1
23
 pkgdesc="A simple script for downloading videos from linkss coppied to your primary clipboard"
24
 arch=(any)
25
diff --git a/usr/bin/clipdl b/usr/bin/clipdl
26
index 686449b..91fcbeb 100755
27
--- a/usr/bin/clipdl
28
+++ b/usr/bin/clipdl
29
@@ -9,35 +9,45 @@
30
 
31
 ## Supported Browsers: brave, chrome, chromium, firefox, opera, vivaldi, edge, safari.
32
 
33
-## NOTE: Only the last / most recent link(s) coppied to your clipboard will be downloaded.
34
+## NOTE: Only the last / most recent link coppied to your clipboard will be downloaded.
35
 
36
 
37
+LINKS=`mktemp -qu`
38
+
39
+xclip -selection clipboard -o|sed 's/ /\n/g'|xargs -n1 > ${LINKS}
40
 
41
-LINKS="$(xclip -selection clipboard -o|xargs -n1)"
42
 
43
 BROWSERS=( 'brave' 'chrome' 'chromium' 'firefox' 'opera' 'vivaldi' 'safari' 'edge')
44
 
45
 withCookies(){  
46
-notify-send "⏬ Downloading: $(basename ${LINK})" ; yt-dlp \
47
-  --continue --cookies-from-browser "${BROWSER}" \
48
-  --output "${1:-${downDir}/$(basename ${LINK}|tr ' ' '_')}" \
49
-  ${LINK}  && notify-send \
50
-  "✅ Downloade Complete!" || notify-send \
51
-  "❌ Download Failed!" ; }
52
+  
53
+  ! [ -d ${dlDir} ] && mkdir -p ${dlDir} ; cd ${LOCATION:-${dlDir}}
54
+  
55
+  notify-send \
56
+    "⏬ Downloading ..." ;  notify-send \
57
+    "⏬"$(echo "$(yt-dlp --get-filename ${LINK})"|tr ' ' '_')""
58
+    yt-dlp --continue --cookies-from-browser ${BROWSER} \
59
+      --output "${LOCATION:-${downDir}/$(yt-dlp --get-filename ${LINK}|tr ' ' '_')}" ${LINK}  && 
60
+      notify-send "✅ Downloade Complete!" ||
61
+      notify-send "❌ Download Failed!" ; }
62
 
63
 noCookies(){
64
-notify-send "⏬ Downloading: $(basename ${LINK})" ; yt-dlp \
65
-  --continue --output "${1:-${downDir}/$(basename ${LINK}|tr ' ' '_')}" \
66
-  ${LINK}  && notify-send \
67
-  "✅ Downloade Complete!" || notify-send \
68
-  "❌ Download Failed!" ; }
69
+  
70
+  ! [ -d ${dlDir} ] && mkdir -p ${dlDir} ; cd ${LOCATION:-${dlDir}}
71
 
72
+  notify-send \
73
+    "⏬ Downloading ..." ; notify-send \
74
+    "⏬"$(echo "$(yt-dlp --get-filename ${LINK})"|tr ' ' '_')""
75
+    yt-dlp --continue \
76
+      --output "${LOCATION:-${downDir}/$(yt-dlp --get-filename ${LINK}|tr ' ' '_')}" ${LINK}  && 
77
+      notify-send "✅ Downloade Complete!" ||
78
+      notify-send "❌ Download Failed!" ; }
79
 
80
-for LINK in "${LINKS[@]}"; do
81
 
82
+for LINK in "$(cat ${LINKS[@]})"; do
83
 
84
-siteName="$(echo "${LINKS}"|sed 's/https:\/\///;s/http:\/\///;s/www\.//;s/\/.*//')"  >/dev/null 2>&1
85
 
86
+siteName="$(echo "${LINKS}"|sed 's/https:\/\///;s/http:\/\///;s/www\.//;s/\/.*//')"  >/dev/null 2>&1
87
 
88
 sitesDir="${HOME}/Media/AutoDownloads"  >/dev/null 2>&1
89
 
90
@@ -47,6 +57,8 @@ downDir="${HOME}/Media/AutoDownloads/${siteName}/Downloads"  >/dev/null 2>&1
91
 
92
 linkFile="${HOME}/Media/AutoDownloads/${siteName}/Links"  >/dev/null 2>&1
93
 
94
+case ${1} in -o|-d|--output) LOCATION="${2}" ;; esac
95
+
96
 
97
 echo ${LINK}|grep -E '^https?' || continue
98
 
99
@@ -70,4 +82,3 @@ noCookies
100
 done
101
 
102
 
103
-