Page 1 of 1

Download videos using youtube-dl and Termux

Posted: 24 Apr 2019 09:34
by anuraag
I got inspired by a recent Tasker project (which was only limited for Youtube only) and created this flow.
This one will work with all sites supported by youtube-dl.

Prerequisites:
Termux
Termux:Task
Termux:API
All of them available from F-Droid freely.

Setup:
  • Install all above mentioned apps.
  • Copy youtube-dl.sh to root of your internal storage (/storage/emulated/0)
  • Open Termux
  • Run following command one by one (else you may run into error)

    Code: Select all

    termux-setup-storage
    mkdir -p .termux/tasker 
    cp /storage/emulated/0/youtube-dl.sh ~/.termux/tasker/
    chmod 755 ~/.termux/tasker/youtube-dl.sh
    mkdir /data/data/com.termux/files/home/storage/shared/youtube-dl
  • Import flow to Automagic
  • Execute "Install/update youtube-dl" flow. It will install python, ffmpeg and youtube-dl in Termux. You can use this flow to update them whenever new builds of youtube-dl releases.
I have set "Send/Share Intent Received" as trigger. So when a link is shared to Automagic's Send/Share Intent then flow will run.
Video/audio will be saved to "/storage/emulated/0/youtube-dl"
When you select a format which have only video container then youtube-dl will download best available audio for that video and merge then with ffmpeg.

Flow and youtube-dl.sh
http://automagic4android.com/forum/down ... hp?id=1892

Re: Download videos using youtube-dl and Termux

Posted: 24 Apr 2019 15:55
by ariloc
Just tried and works great! I will totally keep it for whenever I need fo download a YouTube video. Maybe a separate app weighs less, but this is much cooler :)
I don't understand much of all that it does but I think it opens up the possibilities of what you can do with AM if you know what you do.

Re: Download videos using youtube-dl and Termux

Posted: 25 Apr 2019 13:55
by anuraag
Updated flow to
Prefer m4a audio if video format is mp4, webm audio if video format is webm
Show log after download
Added format to file name

To update
  • Import flow to Automagic
  • Copy youtube-dl.sh to root of your internal storage (/storage/emulated/0)
  • Open Termux
  • Run following command

    Code: Select all

    cp /storage/emulated/0/youtube-dl.sh ~/.termux/tasker/
    chmod 755 ~/.termux/tasker/youtube-dl.sh
    

Re: Download videos using youtube-dl and Termux

Posted: 08 Feb 2020 07:39
by anuraag
Updated flow to
Fix not getting json info if json length is large
Added support for downloading Playlists.

To update
  • Import flow to Automagic
  • Copy youtube-dl.sh to root of your internal storage (/storage/emulated/0)
  • Open Termux
  • Run following command

    Code: Select all

    cp /storage/emulated/0/youtube-dl.sh ~/.termux/tasker/
    chmod 755 ~/.termux/tasker/youtube-dl.sh
    

Re: Download videos using youtube-dl and Termux

Posted: 07 Mar 2020 09:38
by anuraag
Another update
Replaced Init Variable Text File with java code to read json files larger than 1mb.
Fixed loop while downloading Playlist.
Added atomicparsley package to termux.