Downloading Youtube videos in a text file...?

45,211

Solution 1

Rather than piping it in, you could use functionality provided by youtube-dl - it has a parameter that allows you to point at a text file containing a list of URLs - one per line.

-a, --batch-file FILE

File containing URLs to download (- for stdin), one URL per line. Lines starting with #, ; or ] are considered as comments and ignored.

In your situation you'd use:

youtube-dl -f best -a list.txt

Solution 2

You can just use youtube-dl -a yourList.txt where yourList is a file containing URL's delimited by linebreaks.

Solution 3

Youtube-dl allow downloading multiple URL at once, so here is a simple solution:

youtube-dl $(cat my-links.txt | xargs)
Share:
45,211

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    If you are familiar to Linux, see the following script...

    I have a text file with a (list.txt) of Youtube URLs separated by new line... and I use

    cat list.txt | youtube-dl -f best 
    

    to download all in the list

    This works fine but I want to emulate it on a Windows Batch file..

    set /p data=<list.txt
    youtube-dl -f best %data%
    

    This works too.. BUT it downloads only the first video on the list.

    A Simple solution w.r.t coding would be preferred.

    PS:Also it is certain that I'm not looking for solutions using youtube-dl commands

    • Attie
      Attie over 5 years
      Why don't you just use youtube-dl -a list.txt?
    • Admin
      Admin over 5 years
      @Attie Okay, you may write it as an answer.
    • Attie
      Attie over 5 years
      What did you mean "not looking for solutions using youtube-dl commands"?
  • 猫IT
    猫IT over 5 years
    This seems to me as being the best answer for it uses the original tool to do the same and there is a Windows version too. So basically all you need to do is reformat your command according to the answer provided by Attie and just put it in a folder with a batch script and relevant list file. Then all you'll have to do is edit your list file and run your script. Otherwise, though I don't know it properly, I'd suggest looking on PowerShell side. From what I saw it seems they at last included a lot of nice features and commands.
  • lbutlr
    lbutlr about 4 years
    when I try to use a batch-file I always get [youtube] xxxxxx: Downloading webpage ERROR: unable to download video data: HTTP Error 403: Forbidden where xxxxxx is the video in https://www.youtube.com/watch?v=xxxxxx
  • Vertisan
    Vertisan about 4 years
    @lbutlr It looks like the video is private.
  • lbutlr
    lbutlr about 4 years
    No, as it works fine when I do not try to use a batch file.
  • Attie
    Attie about 4 years
    This discussion isn't really supposed to be conducted in comments... but, 1) Have you updated youtube-dl?, 2) Can you share the full link so we can try?
  • ssi-anik
    ssi-anik over 3 years
    if someone is getting 'requested format not available' error, try -f bestvideo+bestaudio flag
  • bobpaul
    bobpaul over 2 years
    The subshell is unnecessary. xargs will append whatever it gets on standard input to the end of the commandline. So just do cat my-links.txt | xargs youtube-dl -f best.
  • Community
    Community over 2 years
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
  • whatspoppin
    whatspoppin about 2 years
    thats event better, thanks