Getting error code when trying to download using pytube - python

Not sure what it is, but its been driving me nuts and im such a newbie I tried so many things but im not sure what it means, ive tried installing and reinstalling pytube but nothing changed.
Here's my code
from pytube import YouTube
link = input("Enter in a link: ")
video = YouTube(link)
print(video.title)
print(video.streams.filter(progressive=True))
stream = video.streams.get_by_itag(22)
stream.download()
print("Video downloaded")
The entire error message:
Traceback (most recent call last):
- File "c:\PytubeDownloader\YoutubeDownloader2.py", line 5, in <module>
video = YouTube(link)
- File "C:\Python\lib\site-packages\pytube\__main__.py", line 91, in __init__
self.prefetch()
- File "C:\Python\lib\site-packages\pytube\__main__.py", line 181, in prefetch
self.vid_info_raw = request.get(self.vid_info_url)
- File "C:\Python\lib\site-packages\pytube\request.py", line 36, in get
return _execute_request(url).read().decode("utf-8")
- File "C:\Python\lib\site-packages\pytube\request.py", line 24, in _execute_request
return urlopen(request) # nosec
- File "C:\Python\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
- File "C:\Python\lib\urllib\request.py", line 525, in open
response = meth(req, response)
- File "C:\Python\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
- File "C:\Python\lib\urllib\request.py", line 557, in error
result = self._call_chain(*args)
- File "C:\Python\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
- File "C:\Python\lib\urllib\request.py", line 749, in http_error_302
return self.parent.open(new, timeout=req.timeout)
- File "C:\Python\lib\urllib\request.py", line 525, in open
response = meth(req, response)
- File "C:\Python\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
- File "C:\Python\lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
- File "C:\Python\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
- File "C:\Python\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
Ok so I did what was recommended in Pytube: urllib.error.HTTPError: HTTP Error 410: Gone and now im getting a completely different error
Traceback (most recent call last):
File "c:\PytubeDownloader\YoutubeDownloader2.py", line 9, in
print(video.streams.filter(progressive=True))
File "C:\Python\lib\site-packages\pytube_main_.py", line 292, in streams
return StreamQuery(self.fmt_streams)
File "C:\Python\lib\site-packages\pytube_main_.py", line 184, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "C:\Python\lib\site-packages\pytube\extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "C:\Python\lib\site-packages\pytube\cipher.py", line 33, in init
raise RegexMatchError(
pytube.exceptions.RegexMatchError: init: could not find match for ^\w+\W

Experienced same error. In cipher.py replace the regexs in pattern in get_initial_function_name with:
r'\bc\s*&&\s*d\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\('.

Related

instagram_private_api.errors.ClientError: Not Found

I am trying to use Osintgram to get reconnaissance on target but I am getting error
This was done on a newly created Instagram account
Does anybody know why this doesn't work
This is the error below
Attempt to login...
Error parsing error response: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/instagram_private_api/client.py", line 523, in _call_api
response = self.opener.open(req, timeout=self.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 404: Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/kali/Osintgram/main.py", line 121, in <module>
api = Osintgram(args.id, args.file, args.json, args.command, args.output, args.cookies)
File "/home/kali/Osintgram/src/Osintgram.py", line 48, in __init__
self.setTarget(target)
File "/home/kali/Osintgram/src/Osintgram.py", line 61, in setTarget
self.following = self.check_following()
File "/home/kali/Osintgram/src/Osintgram.py", line 1159, in check_following
return self.api._call_api(endpoint)['user_detail']['user']['friendship_status']['following']
File "/usr/local/lib/python3.10/dist-packages/instagram_private_api/client.py", line 527, in _call_api
ErrorHandler.process(e, error_response)
File "/usr/local/lib/python3.10/dist-packages/instagram_private_api/errors.py", line 135, in process
raise ClientError(error_msg, http_error.code, error_response)
instagram_private_api.errors.ClientError: Not Found
python3 Osintgram <target>
I expected a successful login

Receiving error downloading with urllib via url

Using the code below, this should have downloaded ~14,000 images. I know the call works for the cards because I ran this without the image download.
A blob file showed up in my downloads, but then was deleted. No files to be found.
Where is the potential error? When this is successful - where would they potentially download to?
Traceback (most recent call last):
File "c:\Users\toril\OneDrive\Documents\Pokemon AI\image download.py", line 28, in <module>
urllib.request.urlretrieve("https://images.pokemontcg.io/sm75/1_hires.png", "sm75-1.jpg")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 241, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
fields = ['card', 'c_image']
Cards = Card.all()
with open ('pokemontest3.csv', 'w', newline='', encoding='utf-8') as csv_file:
csvwriter = csv.writer(csv_file)
csvwriter.writerow(fields)
for card in Cards:
card = (card.name, card.images.small)
rows = card
csvwriter.writerow(rows)
urllib.request.urlretrieve("https://images.pokemontcg.io/sm75/1_hires.png", "sm75-1.jpg")
Why all the CSV-code, if it's a problem with image-fetching?
Why downloading the same image is within a loop?
It looks like your traceback is truncated, and it's a simple "403 Forbidden" error:
>> urllib.request.urlretrieve("https://images.pokemontcg.io/sm75/1_hires.png", "/tmp/sm75-1.jpg")
Traceback (most recent call last):
File "<input>", line 1, in <module>
urllib.request.urlretrieve("https://images.pokemontcg.io/sm75/1_hires.png", "/tmp/sm75-1.jpg")
File "/usr/local/Cellar/python#3.10/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request
.py", line 241, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/usr/local/Cellar/python#3.10/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request
.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/Cellar/python#3.10/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request
.py", line 525, in open
response = meth(req, response)
File "/usr/local/Cellar/python#3.10/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request
.py", line 634, in http_response
response = self.parent.error(
File "/usr/local/Cellar/python#3.10/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request
.py", line 563, in error
return self._call_chain(*args)
File "/usr/local/Cellar/python#3.10/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request
.py", line 496, in _call_chain
result = func(*args)
File "/usr/local/Cellar/python#3.10/3.10.4/Frameworks/Python.framework/Versions/3.10/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 403: Forbidden

Pytube module title not giving

I am trying to get Youtube video title using pytube module
But it giving error . I have tried this code :
import pytube
from pytube import YouTube
video = YouTube('https://www.youtube.com/watch?v=Srqs4CitU2U')
print(video.title)
But it Giving Me This Error :
PS D:\Programming> & "C:/Users/Offensive Tech/AppData/Local/Programs/Python/Python39/python.exe" d:/Programming/youtube_video.py
Traceback (most recent call last):
File "d:\Programming\youtube_video.py", line 4, in <module>
video = YouTube('https://www.youtube.com/watch?v=Srqs4CitU2U')
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 91, in __init__
self.prefetch()
File "C:\Users\Offensive Tech\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\Offensive Tech\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\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\request.py", line 24, in _execute_request
return urlopen(request) # nosec
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
response = meth(req, response)
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
response = self.parent.error(
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 555, in error
result = self._call_chain(*args)
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
result = func(*args)
File "C:\Users\Offensive Tech\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\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
response = meth(req, response)
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
response = self.parent.error(
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 561, in error
return self._call_chain(*args)
File "C:\Users\Offensive Tech\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
result = func(*args)
File "C:\Users\Offensive Tech\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
PS D:\Programming>
Please tell me the solution that error can solved.
You get 410 Error, it's said the page remove from the web. i think is happened because who publish the video remove it from YouTube. I check the code now, and it is work.

Pytube HTTPError: HTTP Error 429: Too Many Requests

I was going to download youtube video so wrote a code in python using pytube module.
I tried pip install pytube and pip install pytube3 .
Only pytube3 worked for me .
from pytube import YouTube
url = 'https://www.youtube.com/watch?v=lJ08IGp5ulA&t=23s'
yt = YouTube(url)
videos = yt.streams.all()
print(videos)
I used this code but got error like
Traceback (most recent call last):
File "c:\Users\ASUS\Desktop\utube\sunil.py", line 5, in <module>
yt = YouTube(url)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytube\__main__.py", line 91, in __init__
self.prefetch()
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytube\__main__.py", line 162, in prefetch
self.watch_html = request.get(url=self.watch_url)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytube\request.py", line 36, in get
return _execute_request(url).read().decode("utf-8")
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytube\request.py", line 24, in _execute_request
return urlopen(request) # nosec
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 640, in http_response
response = self.parent.error(
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 563, in error
result = self._call_chain(*args)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 755, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 640, in http_response
response = self.parent.error(
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 429: Too Many Requests
So help me to fix this.

yahoo_finance api throws 404. urllib2.HTTPError: HTTP Error 400: Bad Request

$ pip install yahoo-finance
$ python
Then in python console,
>>> from yahoo_finance import Share
>>> yahoo = Share('YHOO')
Traceback (most recent call last): File "", line 1, in File
"/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 178, in init
self.refresh() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 142, in refresh
self.data_set = self._fetch() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 181, in _fetch
data = super(Share, self)._fetch() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 134, in _fetch
data = self._request(query) File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 118, in _request
response = yql.YQLQuery().execute(query) File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/yql.py",
line 61, in execute
'env': DATATABLES_URL File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 435, in open
response = meth(req, response) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 473, in error
return self._call_chain(*args) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 400: Bad Request

Categories