Skip to content

Instantly share code, notes, and snippets.

@procopaeus
Last active November 16, 2024 10:33
Show Gist options
  • Save procopaeus/69160a74198794626e569359ca2b2d7a to your computer and use it in GitHub Desktop.
Save procopaeus/69160a74198794626e569359ca2b2d7a to your computer and use it in GitHub Desktop.
Script to setup Termux from scratch with tools to use with termux-url-opener

Clean Install

Install Termux and Termux:API

F-Droid | GitHub

Setup Termux Storage

termux-setup-storage

Install dependencies

It's better to run these commands bellow before installing dependencies or running the script:

pkg update -y && pkg upgrade -y && pkg install wget -y

These tools and deps. will also be on the script:

pkg install python -y && pkg install ffmpeg -y && install termux-api -y && pkg install aria2 -y && pkg install imagemagick -y && pkg install tsu -y && pkg install git -y && pkg install rust -y && pkg install binutils -y && pkg install build-essential -y
yes | pip install setuptools && yes | pip install wheel && yes | pip install yt-dlp && yes | pip install gallery-dl && yes | pip install bs4

Or use this installer

wget --no-check-certificate  "https://gist.github.com/procopaeus/69160a74198794626e569359ca2b2d7a/raw/3daf36d498e83c844d6179f464de235fd998b419/install.sh" && chmod +x install.sh && bash install.sh

After installing go to Android Settings and enable Termux to display over other apps. This is required to make termux-url-opener work.

Customize it:

Install LITMux to make it amazing!

bash -c "$(curl -fsSL https://git.io/Jei6P)"
#!/bin/bash
#Clean Install
rm -f "/data/data/com.termux/files/home/bin/termux-url-opener"
mkdir /data/data/com.termux/files/home/bin
#Installing dependencies
pkg update -y && pkg upgrade -y && pkg install wget -y
pkg install python -y && pkg install ffmpeg -y && install termux-api -y && pkg install aria2 -y && pkg install imagemagick -y && pkg install tsu -y && pkg install git -y && pkg install rust -y && pkg install binutils -y && pkg install build-essential -y
yes | pip install setuptools && yes | pip install wheel && yes | pip install yt-dlp && yes | pip install gallery-dl && yes | pip install bs4
#Installing termux-url-opener
wget -P /data/data/com.termux/files/home/bin/ --no-check-certificate "https://gist.github.com/procopaeus/69160a74198794626e569359ca2b2d7a/raw/6cf712d3f58cbf4ed1e73e03423cd1be999908e6/termux-url-opener"
chmod +x "/data/data/com.termux/files/home/bin/termux-url-opener"
termux-setup-storage
#!/bin/bash
clear
url=$1
echo "All-in-one Download Script for Termux"
echo "----------Last updated Mar 26 2023----------"
echo "--------------------------------------------"
echo "1: yt-dlp (generic)"
echo "2: wget"
echo "3: aria2"
echo "4: gallery-dl"
echo "5: yt-dlp mp3"
echo "6: yt-dlp mp3 + crop thumbnail"
echo "7: yt-dlp 480p"
echo "8: yt-dlp 720p"
echo "9: yt-dlp 1080p"
echo "10: yt-dlp tiktok"
echo "Default: yt-dlp (generic)"
read n
if [ "$n" == '2' ]; then
wget -nd -P "/data/data/com.termux/files/home/storage/downloads/" -c --no-use-server-timestamps --content-disposition --no-check-certificate "$url"
else
if [ "$n" == '3' ]; then
aria2c "$url" -d "/data/data/com.termux/files/home/storage/downloads"
else
if [ "$n" == '4' ]; then
gallery-dl --config "~/.gallery-dl.conf" --cookies "~/cookies.txt" "$url"
else
if [ "$n" == '5' ]; then
[ ! -d "/data/data/com.termux/files/home/storage/downloads/yt-dlp" ] && mkdir "/data/data/com.termux/files/home/storage/downloads/yt-dlp"
yt-dlp --extractor-args "youtube:player_client=android" --no-mtime --extract-audio --audio-quality 0 --embed-thumbnail --add-metadata --audio-format mp3 -c -i "$url" -o "/data/data/com.termux/files/home/storage/downloads/yt-dlp/%(title)s.%(ext)s"
else
if [ "$n" == '6' ]; then
[ ! -d "/data/data/com.termux/files/home/storage/downloads/yt-dlp" ] && mkdir "/data/data/com.termux/files/home/storage/downloads/yt-dlp"
yt-dlp --extractor-args "youtube:player_client=android" --no-mtime --extract-audio --audio-quality 0 --embed-thumbnail --convert-thumbnails jpg --ppa "ffmpeg: -c:v mjpeg -vf crop=\"'if(gt(ih,iw),iw,ih)':'if(gt(iw,ih),ih,iw)'\"" --add-metadata --audio-format mp3 -c -i "$url" -o "/data/data/com.termux/files/home/storage/downloads/yt-dlp/%(title)s.%(ext)s"
else
if [ "$n" == '7' ]; then
[ ! -d "/data/data/com.termux/files/home/storage/downloads/yt-dlp" ] && mkdir "/data/data/com.termux/files/home/storage/downloads/yt-dlp"
yt-dlp --extractor-args "youtube:player_client=android" --external-downloader aria2c --downloader-args "aria2c:-j16 -x16 -s16 -k1M" --no-mtime -S res:480,codec:avc:m4a "$url" -o "/data/data/com.termux/files/home/storage/downloads/yt-dlp/%(title)s.%(ext)s"
else
if [ "$n" == '8' ]; then
[ ! -d "/data/data/com.termux/files/home/storage/downloads/yt-dlp" ] && mkdir "/data/data/com.termux/files/home/storage/downloads/yt-dlp"
yt-dlp --extractor-args "youtube:player_client=android" --external-downloader aria2c --downloader-args "aria2c:-j16 -x16 -s16 -k1M" --no-mtime -S res:720,codec:avc:m4a "$url" -o "/data/data/com.termux/files/home/storage/downloads/yt-dlp/%(title)s.%(ext)s"
else
if [ "$n" == '9' ]; then
[ ! -d "/data/data/com.termux/files/home/storage/downloads/yt-dlp" ] && mkdir "/data/data/com.termux/files/home/storage/downloads/yt-dlp"
yt-dlp --extractor-args "youtube:player_client=android" --external-downloader aria2c --downloader-args "aria2c:-j16 -x16 -s16 -k1M" --no-mtime -S res:1080,codec:avc:m4a "$url" -o "/data/data/com.termux/files/home/storage/downloads/yt-dlp/%(title)s.%(ext)s"
else
if [ "$n" == '10' ]; then
[ ! -d "/data/data/com.termux/files/home/storage/downloads/yt-dlp" ] && mkdir "/data/data/com.termux/files/home/storage/downloads/yt-dlp"
yt-dlp --extractor-args "youtube:player_client=android" --no-mtime -S codec:h265:aac "$url" -o "/data/data/com.termux/files/home/storage/downloads/yt-dlp/@%(uploader)s-%(upload_date)s.%(ext)s"
else
[ ! -d "/data/data/com.termux/files/home/storage/downloads/yt-dlp" ] && mkdir "/data/data/com.termux/files/home/storage/downloads/yt-dlp"
yt-dlp --extractor-args "youtube:player_client=android" --no-mtime -c -i "$url" -o "/data/data/com.termux/files/home/storage/downloads/yt-dlp/%(title)s-%(id)s.%(ext)s"
fi
fi
fi
fi
fi
fi
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment