[Python] pytube not working even after upgrading pytube and pip

Discussão em 'Python' iniciado por Stack, Outubro 24, 2024.

  1. Stack

    Stack Membro Participativo

    I was trying to download audio of youtube video using pytube library but it's not working anymore tried to update pytube still not working.

    from pytube import YouTube
    YouTube('https://www.youtube.com/watch?v=HL9j8xuQ6Wc').streams.first().download()


    The error I am getting

    Traceback (most recent call last):
    File "/home/ideapoke/Documents/financial_analysis/youtube_to_audio.py", line 31, in <module>
    YouTube('https://www.youtube.com/watch?v=HL9j8xuQ6Wc').streams.first().download()
    File "/home/ideapoke/.local/lib/python3.10/site-packages/pytube/__main__.py", line 91, in __init__
    self.prefetch()
    File "/home/ideapoke/.local/lib/python3.10/site-packages/pytube/__main__.py", line 181, in prefetch
    self.vid_info_raw = request.get(self.vid_info_url)
    File "/home/ideapoke/.local/lib/python3.10/site-packages/pytube/request.py", line 36, in get
    return _execute_request(url).read().decode("utf-8")
    File "/home/ideapoke/.local/lib/python3.10/site-packages/pytube/request.py", line 24, in _execute_request
    return urlopen(request) # nosec
    File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
    File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
    File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
    File "/usr/lib/python3.10/urllib/request.py", line 557, in error
    result = self._call_chain(*args)
    File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
    File "/usr/lib/python3.10/urllib/request.py", line 749, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
    File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
    File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
    File "/usr/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
    File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
    File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 410: Gone

    Continue reading...

Compartilhe esta Página