Skip to content

kairusds/termux-url-opener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

termux-url-opener

My termux-url-opener script with yt-dlp

Installation

Install the Termux:API app

Paste these commands into Termux and run them one by one

cd ~
termux-setup-storage
pkg update
pkg upgrade
pkg install python3 aria2 ffmpeg jq termux-api wget nano deno
mkdir -p yt-dlp
wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O yt-dlp/
chmod +x yt-dlp/yt-dlp
termux-fix-shebang yt-dlp/yt-dlp # optional workaround for 'bad interpreter' errors while using termux-url-opener
echo 'export PATH="$PATH:$HOME/yt-dlp"' >> .bashrc # or use global $PREFIX/etc/bash.bashrc
source .bashrc
mkdir ~/bin
wget https://github.com/kairusds/termux-url-opener/raw/master/termux-url-opener -P ~/bin
termux-fix-shebang ~/bin/termux-url-opener # optional workaround for 'bad interpreter' errors while using termux-url-opener
chmod +x ~/bin/termux-url-opener

Getting cookies.txt file for yt-dlp

  1. Install and run a Firefox-based browser for Android: Original Firefox, Iceraven or IronFox
  2. Install the Get cookies.txt LOCALLY Firefox extension
  3. Open a Private Tab by clicking the Tabs icon > then the Mask icon, and login to YouTube. WARNING: USE A THROWAWAY ACCOUNT FOR THIS SINCE THERE'S A SMALL CHANCE YOUR YOUTUBE/GOOGLE ACCOUNT COULD GET BANNED.
  4. Enable "Get cookies.txt LOCALLY" for Private tabs on the Extensions menu by pressing the 3-dots menu icon > Extensions > Find and tap "Get cookies.txt LOCALLY" > Enable "Run in private browsing". Then, click Permissions > Enable "Allow for all sites" to effectively activate the extension.
  5. While on the same YouTube private tab with the logged in account, click "Get cookies.txt LOCALLY" from the same Extensions menu from step 4 then press "Copy".
  6. In Termux, run nano ~/yt-dlp/.youtube.com_cookies.txt and hold-tap the Termux screen then Press Paste. Afterwards, Press Ctrl+X > Press Y > Press Enter to save the file.
  7. Disable "Get cookies.txt LOCALLY" under Extensions Manager from the same Extensions menu in step 4 > Find and click "Get cookies.txt LOCALLY" > Toggle Enabled. (This is not mandatory but still a great security practice in case the extension gets compromised)

yt-dlp should be working fine now if you setup the cookies correctly.

Usage

From the YouTube app or any app, click Share > More > Termux and it should give you an option to download the shared link via MP3 or Video from the Termux app.

(For the YouTube app, if the More button is not visible, scroll the app icons list horizontally to the right.)

The downloaded MP3 files are stored in the Music folder on your internal storage, and the videos are stored on the Movies folder.

Notices

  • If you keep getting Permission denied errors, just grant the Storage permission again for the Termux app manually on the app info page. Running termux-setup-storage again if you already ran the command once wipes your entire internal storage. You can also disable Pause app activity if unused or an option named along those lines in Termux's app info page, so the app's storage permissions won't get revoked if you don't use it for a long time.
  • For faster fixes/updates, switch to the nightly channel instead by running these commands:
# Change to nightly branch
yt-dlp --update-to nightly

# Update everyday/whenever you encounter issues
yt-dlp -U

About

My personal termux-url-opener script with yt-dlp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages