-3

Recently pytube started returning an empty playlist. What is causing this playlist to be empty?

from pytube import Playlist

link = 'https://www.youtube.com/watch? 
v=2HtaIvb61Uk&list=PLu8BgVaWowIG_0omesGRkKXK2mqWqAKXU'

print(Playlist(link))

result: []

This playlist should return several links. I don't know if it's an update issue, or an error in the code, but if anyone knows how to resolve it, I'd be super grateful :)

Life is complex
  • 15,374
  • 5
  • 29
  • 58
Jubiluleu
  • 61
  • 7

1 Answers1

0

There seems to be another issue in pytube, which is likely related to YouTube changing their code. The code below will output the number of items in the playlist.

import re
from pytube import Playlist

playlist = Playlist('https://www.youtube.com/watch?v=2HtaIvb61Uk&list=PLu8BgVaWowIG_0omesGRkKXK2mqWqAKXU')
playlist._video_regex = re.compile(r"\"url\":\"(/watch\?v=[\w-]*)")
 
print(len(playlist.video_urls))
#output 14 
Life is complex
  • 15,374
  • 5
  • 29
  • 58