# COLORS
GREEN="\e[32m"
CYAN="\e[36m"
MAGENTA="\e[35m"
YELLOW="\e[33m"
BLUE="\e[34m"
RED="\e[31m"

# BOLD COLORS
GREEN_B="\e[01;32m"
CYAN_B="\e[01;36m"
MAGENTA_B="\e[01;35m"
YELLOW_B="\e[01;33m"
BLUE_B="\e[01;34m"
RED_B="\e[01;31m"

# RESET
RESET="\e[0m"

clear
command -v yt-dlp || printf "${RED_B} Please install yt-dlp manually or run the the install.sh script again.\n${RESET}"
OUTPUT_PATH="/storage/emulated/0/Youtube"

echo -e "${RED}" "          ▄▀▄     ▄▀▄"
echo -e "${RED}" "         ▄█░░▀▀▀▀▀░░█▄"
echo -e "${RED}" "     ▄▄  █░░░░░░░░░░░█  ▄▄"
echo -e "${RED}" "    █▄▄█ █░░█░░┬░░█░░█ █▄▄█"
echo -e "${CYAN}" "╔════════════════════════════════════════╗"                                                                          
echo -e "${GREEN}" "║ ♚ Project Name : 🆃🅴🆁🅼🆄🆇-🆈🆃🅳™           ║"
echo -e "${GREEN}" "║ ♚ Author : KhanSaad1275                ║"
echo -e "${GREEN}" "║ ♚ Github : g̲i̲t̲h̲u̲b̲.̲c̲o̲m̲/̲k̲h̲a̲n̲s̲a̲a̲d̲1̲2̲7̲5̲/̲    ║"
echo -e "${GREEN}" "║ ♚ Website : www.LearnTermux.tech       ║"
echo -e "${CYAN}" "╠════════════════════════════════════════╝"
echo -e "${CYAN}" "╠═▶ [𝗦𝗲𝗹𝗲𝗰𝘁 𝗔 𝗙𝗼𝗿𝗺𝗮𝘁]  ➳"
echo -e "${GREEN}" "╠═▶ 1. Music Mp3♫"
echo -e "${GREEN}" "╠═▶ 2. Video 360p"
echo -e "${GREEN}" "╠═▶ 3. Video 480p"
echo -e "${GREEN}" "╠═▶ 4. Video 720p"
echo -e "${GREEN}" "╠═▶ 5. Video 1080p"
echo -e "${GREEN}" "╠═▶ 6. Video 2160p"
echo -e "${GREEN}" "╠═▶ 7. Exit Termux-YTD" # Added

#Edit From Oak Atsume 
printf "${GREEN} ╚═:➤  ${RESET}"
read option

if [[ -z $option ]];
then
	clear
	printf "${RED_B} Please choose a option!\n${RESET}"
else
case $option in #Make Case list
	1)
	yt-dlp -f 140 $1
	;;
	2)
	yt-dlp -f "best[height<=360]" $1
	;;
	3)
	yt-dlp -f "best[height<=480]" $1
	;;
	4)
	yt-dlp -f "best[height<=720]" $1
	;;
	5)
	yt-dlp -f "best[height<=1080]" $1
	;;
	6)
  yt-dlp -f "best[height<=2160]" $1
	;;
	7)
	exit 0
	;;
esac 
fi

if [ $? -eq 0 ]; then
  printf "${GREEN_B}Files correctly downloaded at ${OUTPUT_PATH} !${RESET}\n"
else
  printf "${RED_B}An error occurred when downloading the files!${RESET}\n"
	exit 0
fi

if [ $(echo -n $TERMUX_API_VERSION | wc -c ) -gt 1 ]; then
printf "${YELLOW_B}Scanning ${OUTPUT_PATH}${RESET}\n"
termux-media-scan -v -r "${OUTPUT_PATH}"
	if [ $? -eq 0 ]; then
  	printf "${GREEN_B}${OUTPUT_PATH} correctly scanned${RESET}\n"
	else
  	printf "${RED_B}An error occurred during the ${OUTPUT_PATH} scanning${RESET}\n"
	fi
fi

printf "${MAGENTA_B}Program completed. Press any key to exit.${RESET}\n"
read x


#There's a cat on the code!!
#          ▄▀▄     ▄▀▄
#         ▄█░░▀▀▀▀▀░░█▄
#     ▄▄  █░░░░░░░░░░░█  ▄▄
#    █▄▄█ █░░█░░┬░░█░░█ █▄▄█

#Oh hey there It's me Oak I have no idea how youtube-dl (now yt-dlp) works but i came across this github an,and edited a few things hope it helps :D 

#I wanted to mess a little with the Download code but didn't 

# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------#

#There's another cat on the code!! (this one is prepared to fight)
# ───▄▄─▄████▄▐▄▄▄▌
# ──▐──████▀███▄█▄▌
# ▐─▌──█▀▌──▐▀▌▀█▀
# ─▀───▌─▌──▐─▌
# ─────█─█──▐▌█
# Hi, I'm cosmic3d
# I was just wondering if there was any cool way of downloading youtube videos without the need to
# visit these awful and uncomfortable websites infested with ads.
# I found this repository and realized there was an unsolved error related with the youtube-dl command.
# I was really bored and I thought this would be really useful for me, so if you dont
# merge my changes its okay :)
#  ,_,
# (O,O)
# (   )
# -"-"
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------#

#email: Kamilohulau@gmail.com
#Date: Wed Dec  2 15:48:19 PST 2020#
#Project name : Termux-YTD#
#Github: https://github.com/khansaad1275/Termux-YTD#

# -----------------------------------------------------