Search code examples
youtube-dl

How to use youtube-dl to download multiple videos in one txt file on mac?


I got a txt file with one video url per line and there're 50 urls in total. I know youtube-dl has the feature that allows you to download multiple videos with youtube-dl -a sample.txt. But I need another way to do this because I'm also using a download tool called you-get which works better on some sites. However, it doesn't support download from a txt file. Last week I find a method to convert multiple files with ffmpeg with this command for i in *.m4a; do ffmpeg -i "$i" "${i%.*}.mp3"; done. I am wondering that is there any similar one line command like this one can help me read urls from the txt file and download with youtube-dl. I am using a mac btw.


Solution

  • More generally, xargs is specific tool for that approach. Example:

    cat sample.txt | xargs --max-args=1 you-get
    takes each line from sample.txt, giving them as an argument to you-get. This ends up with 50 command lines:

    you-get url1
    you-get url2
    you-get url[...]
    

    and so on. This is a good tutorial, from tutorialspoint: https://www.tutorialspoint.com/unix_commands/xargs.htm