Skip to content

Instantly share code, notes, and snippets.

@cwkirchner
Forked from LordH3lmchen/termux-url-opener
Last active June 26, 2022 18:44
Show Gist options
  • Save cwkirchner/2e197448ef12fb179aca2fed5722664f to your computer and use it in GitHub Desktop.
Save cwkirchner/2e197448ef12fb179aca2fed5722664f to your computer and use it in GitHub Desktop.
termux-url-opener
#!/data/data/com.termux/files/usr/bin/zsh
#
# This is a termux-url-opener script (based on https://gist.github.com/LordH3lmchen/dc35e8df3dc41d126683f18fe44ebe17)
# to do diffrent tasks on my Android phone. Youtube-dl has been replaced by yt-dlp and scdl has been replaced by soundscrape.
#
# How to use this script:
#############################
# Create the bin directory
# ➜ ~ mkdir bin
# Copy script to bin directory
# ➜ ~ mv termux-url-opener ~/bin
# Make it executable
# ➜ chmod +x ~/bin/termux-url-opener
# Install zsh, wget, and ffmpeg
# ➜ pkg install zsh wget ffmpeg
# Install yt-dlp, soundscrape with pip
# ➜ pip install yt-dlp soundscrape
# Run the following command to enable the termux storage features
# ➜ termux-setup-storage
url=$1
echo "What should I do with $url ?"
echo "1) Download YouTube video"
echo "2) Extract audio, auto-number, embed thumbnail"
echo "3) Extract audio, split chapters, auto-number, embed thumbnail"
echo "4) Extract audio, embed thumbail"
echo "5) Extract audio from playlist, auto-number"
echo "6) Download with Soundscrape (SoundCloud/Bandcamp)"
echo "7) Download album with Soundscrape (Bandcamp)"
echo "8) wget file to download-folder"
echo "x) nothing"
read CHOICE
case $CHOICE in
1)
yt-dlp -o "/storage/emulated/0/Download/%(title)s.%(ext)s" $url
;;
2)
yt-dlp --extract-audio --audio-format mp3 --audio-quality 128K -o "/storage/emulated/0/Download/%(autonumber)s-%(title)s.%(ext)s" --embed-thumbnail $url
;;
3)
yt-dlp --split-chapters --extract-audio --audio-format mp3 --audio-quality 128K -o "/storage/emulated/0/Download/%(autonumber)s-%(title)s.%(ext)s" --embed-thumbnail $url
;;
4)
yt-dlp --extract-audio --audio-format mp3 --audio-quality 128K --embed-thumbnail -o "/storage/emulated/0/Download/%(uploader)s - %(title)s.%(ext)s" $url
;;
5)
yt-dlp -o "/storage/emulated/0/Download/%(playlist_index)s-%(title)s.%(ext)s" $url
;;
6)
soundscrape $url
;;
7)
soundscrape -bf $url
;;
8)
cd ~/storage/downloads
wget $url
;;
x)
echo "bye"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment