Skip to content

Instantly share code, notes, and snippets.

@cpylua
Last active November 13, 2019 01:42
Show Gist options
  • Save cpylua/f7d1c6e5c22f5e0aa24349a8a20742c4 to your computer and use it in GitHub Desktop.
Save cpylua/f7d1c6e5c22f5e0aa24349a8a20742c4 to your computer and use it in GitHub Desktop.
youtube-dl on termux
#!/bin/sh
# Usage:
# 1. Open a Termux session
# 2. Copy and run the below command in Termux
# source <(curl -s "https://gist.githubusercontent.com/cpylua/f7d1c6e5c22f5e0aa24349a8a20742c4/raw/setup-youtube-dl.sh?t=$(date +%s)")
pkg update && pkg upgrade && pkg install python ffmpeg
pip install --upgrade pip && pip install youtube-dl
# it will ask for storage permission
termux-setup-storage
# config youtube-dl
mkdir -p /data/data/com.termux/files/home/storage/shared/youtube-dl
mkdir -p ~/.config/youtube-dl
cat << EOF > ~/.config/youtube-dl/config
--no-mtime
--restrict-filenames
-o /data/data/com.termux/files/home/storage/shared/youtube-dl/%(title)s-%(id)s.%(ext)s
EOF
# create share handler
mkdir -p ~/bin
cat << "EOF" > ~/bin/termux-url-opener
youtube-dl $1
EOF
@cpylua
Copy link
Author

cpylua commented Nov 13, 2019

Using %(title)s may cause filename too long error when downloading some video.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment