Skip to content

Instantly share code, notes, and snippets.

@aziascreations
Last active January 11, 2021 05:21
Show Gist options
  • Save aziascreations/2865ccebaebf9004a7b65056e42a7f01 to your computer and use it in GitHub Desktop.
Save aziascreations/2865ccebaebf9004a7b65056e42a7f01 to your computer and use it in GitHub Desktop.
Termux URL opener script with youtube downloader
#!/bin/bash
clear
bold=$(tput bold)
normal=$(tput sgr0)
if [[ $1 =~ ^.*youtu.*$ ]]; then
echo "${bold}Youtube-dl${normal}"
echo "> ${1}"
echo $'\nDownload as an mp3 file ? (Y/N/E)'
read -p "> " -n 1 -r
echo $'\n'
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo 'Downloading mp3 file...'
youtube-dl -f 'bestaudio' -o '/data/data/com.termux/files/home/storage/music/youtube-dl/%(title)s.f%(format_id)s.%(ext)s' $1
elif [[ $REPLY =~ ^[Nn]$ ]]; then
echo 'Downloading video...'
youtube-dl -o "/data/data/com.termux/files/home/storage/movies/youtube-dl/%(title)s.%(ext)s" -f "best[height<=480]" $1
else
echo "Exiting..."
fi
elif [[ $1 =~ ^.*nourlselected.*$ ]]; then
echo "ERROR1"
else
echo Unhandled URL type: $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment