forked from rimoliga/youtify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
termux-url-opener
64 lines (54 loc) · 1.82 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
#!/data/data/com.termux/files/usr/bin/bash
# Get the URL
URL=$1
clear
echo "Opening URL"
# Cheks if its Youtube or Spotify URL and downloads it
if [[ $URL == *"open.spotify.com"* ]] ; then
SONG_DIR="/storage/emulated/0/Download/spotifydl" #for Termux only
NODE_ENV=$(which node)
SPOTIFYDL=$(which spotifydl)
# check if directory exist or not
if [[ ! -d $SONG_DIR ]]; then
# directory doesn't exist create it for use.
mkdir $SONG_DIR
fi
echo "Spotify link detected"
if [[ $URL == *"playlist"* ]]; then
echo "Downloading Playlist"
# Download the song to song directory.
$NODE_ENV $SPOTIFYDL $URL -o $SONG_DIR
fi
if [[ $URL == *"track"* ]]; then
echo "Downloading Song"
# Download the song to song directory.
$NODE_ENV $SPOTIFYDL $URL -o $SONG_DIR
fi
if [[ $URL == *"album"* ]]; then
echo "Downloading Album"
# Download the song to song directory.
$NODE_ENV $SPOTIFYDL $URL -o $SONG_DIR
fi
elif [[ $URL == *"youtu.be"* || $URL == *"youtube.com"* ]]; then
formatvar=0
read -p $'What do you want to download \n(Select the number and press enter) \n 1) Video \n 2) Audio \n' formatvar
if [[ $formatvar == 1 ]]; then
read -p $'Do you want to download the subtitles for this video? \n(Select the number and press enter) \n 1) Yes \n 2) No \n' formatvar
if [[ $formatvar == 1 ]]; then
echo 'Downloading Video with subtitles'
youtube-dl --all-subs $URL
elif [[ $formatvar == 2 ]]; then
echo 'Downloading Video'
youtube-dl $URL
fi
elif [[ $formatvar == 2 ]]; then
echo 'downloading Audio'
youtube-dl -x --audio-format 'mp3' $URL
else
echo 'Default downloading Video'
youtube-dl $URL
fi
else
echo "No downloader for this URL type"
fi
read -n 1 -s -p "Press any key to exit..."