DEV Community

Cover image for Download a whole YouTube Playlist at one go

Download a whole YouTube Playlist at one go

Trideep Barik on May 24, 2020

Note:This post is just for educational purpose to show the use of Webscraping. Have you ever been in a situation like, you are having you final e...
Collapse
 
highcenburg profile image
Vicente G. Reyes

Cool post! If you're on a mac, you can easily copy the link of a youtube video or a playlist and use youtube-dl, a command line tool to download videos on youtube.

Collapse
 
spaceghost profile image
Johnneylee Jack Rollins • Edited

Very cool exercise! Have you heard of the venerable youtube-dl project? It already supports playlists and many others. It’s written with python to boot!

ytdl-org.github.io/youtube-dl/inde...

Collapse
 
dstri26 profile image
Trideep Barik • Edited

Yep, that's a great-one. But pytube helps in understanding Webscraping better,so tried this approach.

Collapse
 
shaijut profile image
Shaiju T

Is downloading YouTube videos Legal ?

Collapse
 
dstri26 profile image
Trideep Barik • Edited

Although the post is for educational purpose, just to show Webscraping use,in the copyright infringement that surrounds certain YouTube videos, it is the uploader who is technically the copyright violator because he/she is publishing. So if you try to own a video that's illegal. Works fine till you keep things to yourself and that's too illegal. But YouTube hasn't taken any actions till date about it.

Collapse
 
tochepa profile image
𝙿𝚊𝚝𝚛𝚒𝚌𝚎 𝚁𝚒𝚌𝚊𝚛𝚍 🚴

Thanks for this tutorial Trideep! Any reason why you used BeautifuSoup instead of Scrapy?

Collapse
 
dstri26 profile image
Trideep Barik • Edited

Just because this post was for beginners just to make them acquainted with Webscraping and also that Beautiful Soup does the work in few lines and easier to understand.

Collapse
 
akmish profile image
akmish

Really good post, thanks Trideep. Will definitely try it.

~Akshat

Collapse
 
dstri26 profile image
Trideep Barik

Thank you :)

Collapse
 
detinsley1s profile image
Daniel Tinsley

Just so you know, it's actually spelled "web scraping," not "web scrapping."

Collapse
 
dstri26 profile image
Trideep Barik • Edited

So sorry about that and Thanks a lot.

Collapse
 
detinsley1s profile image
Daniel Tinsley

No big deal. I'm just trying to help you out. You wrote a great article, so thank you for writing it.

Collapse
 
adoezema profile image
adoezema

Cool alternative to youtube-dl. Thanks for creating this, will have to explore this down the road.

Collapse
 
dstri26 profile image
Trideep Barik

:) Thank you. Surely this could be improved in so many better ways.

Collapse
 
akashdeepdas profile image
AkashdeepDas

Hey. Is this still working? I don't know how you are using beautifulsoup to a playlist which depends upon javascript to form its page. I tried your code upto part-2 and it doesn't work.

Collapse
 
dstri26 profile image
Trideep Barik

Works for me. Javascript generates playlist but in the end every website is built with HTML files. You can go for the repository mentioned in the end.

Collapse
 
akashdeepdas profile image
AkashdeepDas • Edited

Well look at the image I attached then. Also pytube isn't properly functional either. Its not updated and have multiple issues. A beginner might get more frustrated trying to debug.
dev-to-uploads.s3.amazonaws.com/i/...

Collapse
 
haze profile image
Haze

You can also use a program called YouTube-DLG

Collapse
 
dstri26 profile image
Trideep Barik • Edited

That's a good choice. But I wanted to show the use of Webscraping in a project for beginners so I preffered pytube.

Collapse
 
shaijut profile image
Shaiju T

There is difference between, Browser downloading and You downloading manually using some software or code. :)

Collapse
 
chetanam profile image
Chetan

You can use this tool omkar.cloud/tools/youtube-playlist...
which does the same job

Collapse
 
blank1611 profile image
Nikhil Prakash Patil

Really liked this tutorial, I was searching for something like this.
One question though, why are there duplicates in the "playlist" list?

Collapse
 
dstri26 profile image
Trideep Barik

You might have observed, that you can open a video by clicking the thumbnail or by clicking the title of the video. So there are two same links for each video. The scraper scraps both the links and thus that has a duplicate link in the "playlist". Later that can be corrected by just converting list to set. :)

Collapse
 
blank1611 profile image
Nikhil Prakash Patil

Oh! Thanks for clearing that up.

Collapse
 
dstri26 profile image
Trideep Barik

Never knew that. Thanks for the information.