-1

I am facing this error while making a program to download YouTube Videos using GUI (Tkinter ttk) Please somebody help me :( I tried so many stackoverflow queries but nothing helped me and even i copied the initial code from Github but error persist in my system however the code was running properly at the reference person Maybe its connection error or something and one things that i have 2 chrome extensions: 1.Touch Vpn 2.Meta Mask

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "f:\Sumant\Python\YouTube Downloader\yt.py", line 25, in download
    yt = YouTube(url)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 91, in __init__
    self.prefetch()
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 181, in prefetch
    self.vid_info_raw = request.get(self.vid_info_url)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\request.py", line 36, in get
    return _execute_request(url).read().decode("utf-8")
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\request.py", line 24, in _execute_request
    return urlopen(request)  # nosec
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
    response = meth(req, response)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
    response = self.parent.error(
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 555, in error
    result = self._call_chain(*args)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
    result = func(*args)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
    response = meth(req, response)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
    response = self.parent.error(
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 561, in error
    return self._call_chain(*args)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
    result = func(*args)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 410: Gone

Code

def download():
    url = ent_link.get()
    res = var.get()

    if len(url) < 1:
        messagebox.showerror("Error", "URL cannot be Empty")
 
    yt = YouTube(url)
    try:
        if var.get() == 0:
             reso_select = yt.streams.get_highest_resolution()
        elif var.get() == 1:
            reso_select = yt.streams.get_lowest_resolution()
        elif var.get() == 2:
            reso_select = yt.streams.filter(only_audio=True).first()
        else:
            reso_select = yt.streams.get_highest_resolution()
        try:
            reso_select.download(path1)
            messagebox.showinfo("Sucess", "Video Downloaded!")
        except:
            messagebox.showerror("Error", "Download Failed")
    except:
        messagebox.showerror("Error","Please try again")

Maybe there is error at line yt = YouTube(url)

Full Code GitHub Repository

  • 1
    "HTTP Error 410: Gone" means that that resource has been deleted from their server. Unless they're sending this to mess with scrapers, this means that this isn't a problem with your code. You're attempting to get a video that doesn't exist anymore. – Carcigenicate Aug 08 '21 at 15:44
  • Also this isn't a `RuntimeError`. It's a `urllib.error.HTTPError`. So please remove the `runtime-error` tag on the question. – TheLizzard Aug 08 '21 at 15:45
  • And also, don't use `except:`. That doesn't appear to be your problem right now, but bare `except` cases like that will bite you at some point. Always specify the exception to want to catch. – Carcigenicate Aug 08 '21 at 15:45
  • @Carcigenicate https://www.youtube.com/watch?v=Lynx3vZz5Ao&t=1s checkout video is there can you please use the GitHub link and use the code to download anyting from YT – Sumant Dusane Aug 08 '21 at 16:48
  • The code works fine with the youtube link using pytube 11.0.0 and Python 3.8.10. – acw1668 Aug 10 '21 at 05:07
  • @acw1668 Have you tried my code? – Sumant Dusane Aug 11 '21 at 16:45
  • Yes I have tried your code with pytube 11.0.0 and Python 3.8.10 as I said in my past comment. – acw1668 Aug 12 '21 at 04:22
  • Does this answer your question? [How do I download YouTube videos with Python?](https://stackoverflow.com/questions/68606981/how-do-i-download-youtube-videos-with-python) – acw1668 Aug 12 '21 at 04:28
  • @acw1668 Thank you very much . This means my code download the youtube stuffs – Sumant Dusane Aug 12 '21 at 06:22

2 Answers2

0

My Error has been resolved it was pytube module who was having error If anybody sees HTTP error with any code use 2 testcases:

  1. Check the Link properly
  2. reinstall pytube (if pytube dosen't work install pytube3 but after uninstalling pytube)

Thank you everyone !

0

This is a bug with pytube, it has happened previously and got fixed but looks like it may have been reintroduced.You could always look into another library e.g. youtube_dl or ytpy

Akash Sharma
  • 134
  • 1
  • 3
  • 13