-1

Using the method mentioned here: Using Pytube to download playlist from YouTube using replit I keep encountering the following error:

import re from pytube import Playlist

YOUTUBE_STREAM_AUDIO = '140' # modify the value to download a different stream DOWNLOAD_DIR = 'D:\\Users\\Jean-Pierre\\Downloads'

playlist = Playlist('https://www.youtube.com/playlist?list=PLzwWSJNcZTMSW-v1x6MhHFKkwrGaEgQ-L')

# this fixes the empty playlist.videos list playlist._video_regex = re.compile(r"\"url\":\"(/watch\?v=[\w-]*)")

print(len(playlist.video_urls))

for url in playlist.video_urls:
    print(url)

# physically downloading the audio track for video in playlist.videos:
    audioStream = video.streams.get_by_itag(YOUTUBE_STREAM_AUDIO)
    audioStream.download(output_path=DOWNLOAD_DIR)

I keep getting the following error:

Traceback (most recent call last):
  File "main.py", line 18, in <module>
    for video in playlist.videos:
  File "/home/runner/FlippantFrankHashmaps/venv/lib/python3.10/site-packages/pytube/contrib/playlist.py", line 144, in videos
    yield from (YouTube(url) for url in self.video_urls)
  File "/home/runner/FlippantFrankHashmaps/venv/lib/python3.10/site-packages/pytube/contrib/playlist.py", line 144, in <genexpr>
    yield from (YouTube(url) for url in self.video_urls)
  File "/home/runner/FlippantFrankHashmaps/venv/lib/python3.10/site-packages/pytube/__main__.py", line 91, in __init__
    self.prefetch()
...
 line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 410: Gone
Elicon
  • 206
  • 1
  • 11
  • Downvoted because: [It's not working](https://idownvotedbecau.se/itsnotworking), [No code](https://idownvotedbecau.se/nocode), [Missing exception details](https://idownvotedbecau.se/noexceptiondetails), [Unclear what you're asking](https://idownvotedbecau.se/unclearquestion), Please look at [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) and take a tour through [How to ask?](https://stackoverflow.com/help/how-to-ask) – Clasherkasten Aug 14 '23 at 12:39
  • Not previously, as the code was missing, but i'll take it as resolved (same for nocode and unclearquestion). – Clasherkasten Aug 14 '23 at 12:47
  • I agree, but just posting this one line of error has hidden from which line of your **own** code the error comes. – Clasherkasten Aug 14 '23 at 12:54

0 Answers0