-
Notifications
You must be signed in to change notification settings - Fork 0
/
termux-url-opener
executable file
·67 lines (60 loc) · 1.71 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
#! /data/data/com.termux/files/usr/bin/bash
# Date: May 29 2022 at 10:43:19 AM
# Description: Get content from the web
set -e
# Check for args
if [[ $# -eq 0 ]]; then
echo -e "Usage: $0 <video-url>"
exit 0
else
url=$1
fi
# Check OS
if [ $(uname -o | grep -io "Android") ]; then
aoutput=$HOME/storage/music
voutput=$HOME/storage/movies
mkdir -p $aoutput
mkdir -p $voutput
else
aoutput=$HOME/Music
voutput=$HOME/Videos
fi
# Check url origin
if echo $url | grep -q 'tiktok'; then
mkdir -p "$voutput/tiktok"
tiktok-dl $url "$voutput/tiktok"
elif echo $url | grep -q 'youtu\.be'; then
echo -e "Options"
echo -e "\t1) Audio"
echo -e "\t2) Audio playlist"
echo -e "\t3) Video"
echo -e "\t4) Video playlist"
echo -e "\nOutput\n\tAudio: $aoutput\n\tVideo: $voutput"
echo -ne "\nChoice: "
read CHOICE
case $CHOICE in
1)
# yt-dlp
youtube-dl --audio-format mp3 --extract-audio --no-playlist $url -o "$aoutput/%(title)s %(id)s.%(ext)s" # --quiet
;;
2)
# yt-dlp
youtube-dl --audio-format mp3 --extract-audio --yes-playlist $url -o "$aoutput/%(title)s %(id)s.%(ext)s" # --quiet
;;
3)
mkdir -p "$voutput/youtube"
# yt-dlp
youtube-dl --no-playlist --format mp4 $url -o "$voutput/youtube/%(title)s %(id)s.%(ext)s" # --quiet
;;
4)
mkdir -p "$voutput/youtube"
# yt-dlp
youtube-dl --yes-playlist --format mp4 $url -o "$voutput/youtube/%(title)s %(id)s.%(ext)s" # --quiet
;;
esac
else
echo -e "Url origin not supported: $url"
sleep 1
exit 0
fi
echo -e "\n[!] Done!"