Thursday 6 October 2016

How to download a you tube video with python script !!

Now downloading a you tube video is very easy we can do it by using any of the you tube down loaders or idm.

But why to install down loaders we can directly use python to do this job.

In this Post i am going to tell you about how to download videos from You tube:

Python module required to do this task:

youtube-dl

Module installation:

            pip install youtube-dl

Now to download a You tube video you require the url of it and then use the following code to download it:

import youtube_dl

a = {}

with youtube_dl.YoutubeDL(a) as y:
   y.download(['https://www.youtube.com/watch?v=lJD38DjY1Cg'])



This download the video present in the above mentioned url:
https://www.youtube.com/watch?v=lJD38DjY1Cg

to your current working directory.


You can see your current working directory by using following commands:

import os
cwd = os.getcwd()


Also you can change the save location of the videos by changing the location of current working directory by using following commands:

os.chdir(<path>)


Note:

Keep checking my blog for further post on how to download all videos in a playlist and a youtube channel and many more.

3 comments:

  1. Great work!! Tested...working....keep updating...

    ReplyDelete
  2. Informative blog. Keep Updating and sharing these types of information. Data Science Classes in Nagpur Thank You...

    ReplyDelete
  3. Java is a high-demanding and easy-to-learn programming language. Students can learn Java programming language in a simple way from the IT Education Centre. Now students can learn Java Courses in Kolhapur

    You can learn Java programming language from the IT Education Centre at your nearby locations.

    IT Education Centre available localities-

    Pune Region

    java course in Pune
    java training in Pune
    online java training in Pune
    java developer classes in Pune
    best java classes in Pune
    best java classes in Pune with placement
    java course fees Pune
    best java training institute in Pune
    full stack java developer course in Pune
    java course fees in Pune
    java course in Pune fees
    java full stack developer course in Pune


    Kolhapur Region

    Java Classes in Kolhapur

    Java course in Kolhapur

    Java Training in Kolhapur

    ReplyDelete