Download videos using youtube-dl and Termux

Share and discuss your flows and ideas with other users.

Moderator: Martin

Post Reply
anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Download videos using youtube-dl and Termux

Post by anuraag » 24 Apr 2019 09:34

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
Last edited by anuraag on 07 Mar 2020 12:17, edited 9 times in total.

ariloc
Posts: 109
Joined: 05 Jun 2016 21:36

Re: Download videos using youtube-dl and Termux

Post by ariloc » 24 Apr 2019 15:55

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.

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Download videos using youtube-dl and Termux

Post by anuraag » 25 Apr 2019 13:55

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
    

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Download videos using youtube-dl and Termux

Post by anuraag » 08 Feb 2020 07:39

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
    
Last edited by anuraag on 16 Mar 2020 03:15, edited 1 time in total.

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Download videos using youtube-dl and Termux

Post by anuraag » 07 Mar 2020 09:38

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.
Attachments
youtube-dl.zip
(5.93 KiB) Downloaded 1394 times

Post Reply