I need a python script that takes link to a single youtube playlist and then gives out a list containing the links to individual videos in the playlist.
I realize that same question was asked few years ago, but it was asked for python2.x and the codes in the answer don't work properly. They are very weird, they work sometimes but give empty output once in a while(maybe some of the packages used there have been updated, I don't know). I've included one of those code below.
If any of you don't believe, run this code several times you'll receive empty list once in a while, but most of the time it does the job of breaking down a playlist.
from bs4 import BeautifulSoup as bsimport requestsr = requests.get('https://www.youtube.com/playlist?list=PL3D7BFF1DDBDAAFE5')page = r.textsoup=bs(page,'html.parser')res=soup.find_all('a',{'class':'pl-video-title-link'})for l in res: print(l.get("href"))In case of some playlists the code just doesn't work at all.
Also, if beautifulsoup can't do the job, any other popular python library will do.