forked from crimera/termux-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
termux-url-opener
executable file
·133 lines (115 loc) · 2.25 KB
/
termux-url-opener
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/data/data/com.termux/files/usr/bin/bash
# Config
MUSIC="$HOME/storage/music"
ASMR="/sdcard/.nsfw"
VIDEOS="$HOME/storage/movies"
CLIPS="$HOME/storage/movies/Clips"
DOWNLOADS="$HOME/storage/downloads"
# End
bashrc="$HOME/.bashrc"
if [ -f "$bashrc" ]; then
source "$bashrc"
fi
url=$1
echo $url
# Site regexs
yt="^(https?\:\/\/)?(((www|m)\.)?youtube\.com|youtu\.be)\/.+$"
# Functions for downloading
asmr() {
echo ASMR
yt-dlp -f bestaudio --extract-audio --embed-thumbnail --embed-metadata \
--external-downloader aria2c --external-downloader-args "-x 16 -k 1M" \
-o "$ASMR/yt/%(channel)s/%(upload_date)s-%(title).150B-%(id)s.%(ext)s" --no-mtime $url
}
music() {
echo Music
yt-dlp -f bestaudio --extract-audio --embed-thumbnail --embed-metadata \
--external-downloader aria2c --external-downloader-args "-x 16 -k 1M" \
--postprocessor-args "-filter:v crop=in_h" \
-o "$MUSIC/%(title)s.%(ext)s" --no-mtime $url
}
video() {
echo Video
yt-dlp $url -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' \
-o "$VIDEOS/%(title)s-%(id)s.%(ext)s" \
--external-downloader aria2c --external-downloader-args "-x 16 -k 1M" \
--embed-subs --embed-thumbnail --embed-metadata \
-S res,hdr,fps,vcodec:av01:h265:vp9.2:vp9:h264,vbr \
--no-mtime
}
aria() {
aria2c -x16 -d $DOWNLOADS \
--on-download-complete "$HOME/bin/openfile" \
$url
exit
}
spot() {
spotdl $url --output $MUSIC
exit
}
play_audio() {
mpv --no-video $url
exit
}
yt() {
method="$(termux-dialog sheet -v "ASMR,Music,Video,Play in mpv" | jq '.index' -r)"
case $method in
0)
asmr
;;
1)
music
;;
2)
video
;;
3)
play_audio
;;
*)
exit
;;
esac
}
uns() {
method="$(termux-dialog sheet -v "Music,Video,Aria" | jq '.index' -r)"
case $method in
0)
music
;;
1)
video
;;
2)
aria
;;
esac
}
# Enable extglob for regex
shopt -s extglob
# Check what site is being passed
case $url in
https://music.youtube.com/watch?v=+([a-zA-Z0-9_-])*)
music
;;
*youtube.com* | *youtu.be*)
echo Download a yt vid
yt
;;
*twitter*)
echo twitter
video
;;
*sourceforge* | *zippyshare*)
echo download file
aria
;;
*spotify*)
spot
;;
*)
echo "unsupported site"
uns
;;
esac
termux-toast -s "Download Done"