how can I write this shell script in python?

How do you write a python script to download all videos in a youtube playlist in a single run?

  • e.g     http://www.youtube.com/playlist?list=PL210C2267A8922854 this is the link of a youtube playlist. one way to download all these videos is download 1 by 1 or use some third party software. (I dont want that but if you have information about some kind of browser plugin then tell me, like before we had BYtube downloader plugin for firefox which does the same work) but would be better if you tell me about some kind of script that will automatically download all the videos 1by1. some people  have already written script for downloding photos from a facebook page or some other website . so i think that can be done for youtube also. basically it will extract link of videos in a page (e.g. in given link) and will download one-by-one. PS: that is the main part of the program. but if it is possible to specify video quality (e.g. 240p, 720p , 360p etc) and extension (e.g. flv, mp4. etc) then extend your program for same .   like by command line argument we can pass the quality and extension. >> python http://file_name.py 360 mp4.

  • Answer:

    Install youtube-dl from http://rg3.github.io/youtube-dl/. And in your Python Script just write: import os os.system("youtube-dl -citk --max-quality FORMAT <Youtube playlist_URL>") It will work for you. It is good practice to use --max-quality instead of specifying a particular buffer size. But if you want to download a particular buffer-size then replace --max-quality by --buffer-size SIZE EDIT1: There is no use of writing Python script for download only. If you are worried about download only then plainly use following command: youtube-dl -citk --max-quality FORMAT <Youtube playlist_URL>

Mohit Singh at Quora Visit the source

Was this solution helpful to you?

Other answers

https://github.com/rg3/youtube-dl/  is really great for this. check out their homepage for all the options. In a nutshell. download the youtube-dl.exe from here https://yt-dl.org/latest/youtube-dl.exe Open a command prompt and navigate to the folder where the exe is and run youtube-dl.exe "playlist url" The videos will be downloaded 1 by 1 in the same folder as the exe.Hope this helps.

Mrityunjay Sharma

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.