r/pythonhelp • u/ViridianGuy • Feb 22 '22
Issue with URL pasting in Python
Hey there, so recently I've been trying to make a Youtube Video Downloader, and for some reason when I input a FULL url it shows an error that goes something like: File "c:\Users\User\OneDrive\Desktop\The Youtube Video Downloader.py", line 10, in <module> video = YouTube(url)
Anyways Here Is The Script:
from pytube import YouTube
import time
print("The Youtube Video Downloader")
time.sleep(0.2)
print("\nBy: ViridianTelamon.")
time.sleep(0.2)
#url = input("\nInput The Full Url For The Youtube Video That You Want To Download (Shortened Urls Will Not Work): ")
url = input("\nInput The Url For The Video: ")
#print(f"Url Inputted: {url}")
#print(url)
video = YouTube(url)
time.sleep(0.2)
print("\n----------Video Title----------")
time.sleep(0.2)
print(video.title)
time.sleep(0.2)
print("\n----------Video Thumbnail Url----------")
time.sleep(0.2)
print(video.thumbnail_url)
time.sleep(2)
print("\n----------Video Download----------")
time.sleep(0.2)
video = video.streams.get_highest_resolution
video.download()
print("\nVideo Successful Downloaded In The Same Directory As This Script.")
1
u/ViridianGuy Feb 23 '22
Now I am getting this error:
File "c:\Users\User\OneDrive\Desktop\The Youtube Video Downloader.py", line 15, in <module> video = YouTube(url) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube__main__.py", line 91, in __init__ self.prefetch() File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube__main__.py", line 181, in prefetch self.vid_info_raw = request.get(self.vid_info_url) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\request.py", line 36, in get return _execute_request(url).read().decode("utf-8") File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube\request.py", line 24, in _execute_request return urlopen(request) # nosec File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen return opener.open(url, data, timeout) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open response = meth(req, response) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response response = self.parent.error( File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 557, in error result = self._call_chain(*args) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain result = func(*args) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 749, in http_error_302 return self.parent.open(new, timeout=req.timeout) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open response = meth(req, response) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response response = self.parent.error( File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 563, in error return self._call_chain(*args) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain result = func(*args) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\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