-
Notifications
You must be signed in to change notification settings - Fork 0
/
songdl
executable file
·28 lines (23 loc) · 1.5 KB
/
songdl
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
#!/bin/bash
gum style --border rounded --margin "3" --align="center" --padding "2 2" --border-foreground 212 "$(gum style --foreground 85 'Song Downloader')"
SONGNAME="Song Name"; URL="URL"
ACTIONS=$(gum choose --cursor.foreground="33" --item.foreground 212 "$URL" "$SONGNAME")
if [ "$URL" == "$ACTIONS" ]
then
URLINP=$(gum input --prompt.foreground="57" --cursor.foreground="85" --placeholder "Paste the link of your song")
yt-dlp -x --quiet --audio-format mp3 "$URLINP" & pid=$!
while ps -p $pid &>/dev/null; do
gum spin --spinner.foreground="57" --title.foreground="85" --title "Fetching Song from the URl..." -- sleep 3
done
echo -e "the download is over, $(gum style --foreground 57 "VIBE TIME"). :3"
else
SONGINP=$(gum input --prompt.foreground="57" --cursor.foreground="85" --placeholder "What song are you looking for ?")
SONGINP_NOSPACE="$(echo -e "${SONGINP}" | tr -d '[:space:]')"
QUERY=$(curl -s https://www.googleapis.com/youtube/v3/search\?part\=snippet\&q\=$SONGINP_NOSPACE\&type\=video\&maxResults\=10\&key\=$YT_API_KEY | jq -r '.items[] | "\(.snippet.channelTitle) => \(.snippet.title) \(.id.videoId)"' | gum filter | awk '{ print $NF }')
yt-dlp -x --quiet --audio--audio-format mp3 https://www.youtube.com/watch?v=${QUERY:(-11)} & pid=$!
while ps -p $pid &>/dev/null; do
gum spin --spinner.foreground="57" --title.foreground="85" --title "Fetching Song from the URl..." -- sleep 3
done
echo -e "Aight ! the download is over, $(gum style --foreground 57 "VIBE TIME")."
fi
yt-dlp -x --audio-format mp3