Open MikrotikIT opened 1 month ago
YouTube has been working tirelessly to block third-party apps, much of the problem is happening in cloud and VPN environments.
If you are also being blocked in the browser, then your IP has been completely blocked. You can try using a proxy to change your IP.
See more at https://github.com/JuanBindez/pytubefix/issues/272
If your internet provider gives you a dynamic IP, just turn off your router and turn it on again and your IP will change
Error output Traceback (most recent call last): File "e:\upload-videos-to-youtube\upload.py", line 51, in
out_video_file = download_video(link, lesson_id, lesson_duration)
File "e:\upload-videos-to-youtube\download_youtube_video.py", line 39, in download_video
ya = yt.streams.filter(only_audio=True).order_by('abr').last()
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix__main.py", line 634, in streams
self.check_availability()
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix__main.py", line 314, in check_availability
status, messages = extract.playability_status(self.vid_info)
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix__main__.py", line 421, in vid_info
innertube.innertube_context.update(self.signature_timestamp)
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix\main.py", line 396, in signature_timestamp
'signatureTimestamp': extract.signature_timestamp(self.js)
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix\main.py", line 213, in js
if pytubefix.js_url != self.js_url:
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix__main.py", line 199, in js_url
if self.age_restricted:
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix\main.py", line 191, in age_restricted
self._age_restricted = extract.is_age_restricted(self.watch_html)
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix\main__.py", line 176, in watch_html
self._watch_html = request.get(url=self.watch_url)
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix\request.py", line 51, in get
response = _execute_request(url, headers=extra_headers, timeout=timeout)
File "e:\upload-videos-to-youtube\venv\lib\site-packages\pytubefix\request.py", line 35, in _execute_request
return urlopen(request, timeout=timeout) # nosec
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
response = meth(req, response)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
response = self.parent.error(
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 555, in error
result = self._call_chain(args)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
result = func(args)
File "C:\Users\username\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\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
response = meth(req, response)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
response = self.parent.error(
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 561, in error
return self._call_chain(args)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
result = func(args)
File "C:\Users\username\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 429: Too Many Requests
Describe the bug the bug show on use po_token and use vpn need solve CAPTCHA
token_file = { "visitorData": "CgtUY3NnY1duYV................................Q%3D%3D", "po_token": "Kr0IC0VCSDpFcnJvcjpScGMgZm...............................UuanM6Nzk4Njo3MCk=" }
Request Data request url = https://youtube.com/watch?v=sDfPX......... Request Method: GET Status Code: 429 Too Many Requests
Response Body or Data
b'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n<html>\n<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>https://youtube.com/watch?v=sDfPX.........</title></head>\n<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px; overscroll-behavior:contain;" onload="e=document.getElementById(\'captcha\');if(e){e.focus();} if(solveSimpleChallenge) {solveSimpleChallenge(,);}">\n<div style="max-width:400px;">\n<hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>\n<form id="captcha-form" action="index" method="post">\n<noscript>\n<div style="font-size:13px;">\n In order to continue, please enable javascript on your web browser.\n</div>\n</noscript>\n<script src="https://www.google.com/recaptcha/api.js" async defer></script>\n<script>var submitCallback = function(response) {document.getElementById(\'captcha-form\').submit();};</script>\n<div id="recaptcha" class="g-recaptcha" data-sitekey="6LfwuyUTAAAAAOAmoS0fdqijC2PbbdH4kjq62Y1b" data-callback="submitCallback" data-s="33JIcErJei0lWWTOVHyWJ1RxrKvbJF8lOPm_h07KR_LLrtnH1TRKe_PUMmCwz2jlDkS.....................................51rL5_qV5Cy7Efl-8_lN2jeF144dwjGTBHSEvvEvMnQL6Xl_v5e3iG7lryPYAle9JQ0B4"></div>\n\n<input type=\'hidden\' name=\'q\' value=\'EgRduslqGPiuubgGIjBtt1NSJvcEDjT9l-rLv1I44vjRKx4SXHoFUEfZzqU99kO6MDI5szn8Lsk1Ta9C_SMyAXJaAUM\'><input type="hidden" name="continue" value="https://youtube.com/watch?v=sDfPX.........">\n</form>\n<hr noshade size="1" style="color:#ccc; background-color:#ccc;">\n\n<div style="font-size:13px;">\n<b>About this page</b><br><br>\n\nOur systems have detected unusual traffic from your computer network. This page checks to see if it's really you sending the requests, and not a robot. <a href="#" onclick="document.getElementById(\'infoDiv\').style.display=\'block\';">Why did this happen?</a><br><br>\n\n<div id="infoDiv" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">\nThis page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop. In the meantime, solving the above CAPTCHA will let you continue to use our services.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests. If you share your network connection, ask your administrator for help — a different computer using the same IP address may be responsible. <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may be asked to solve the CAPTCHA if you are using advanced terms that robots are known to use, or sending requests very quickly.\n</div>\n\nIP address: 93.186.201.106<br>Time: 2024-10-15T11:52:25Z<br>URL: https://youtube.com/watch?v=sDfPX.........<br>\n</div>\n</div>\n</body>\n</html>\n'
solution need use selenium to solve the CAPTCHAcode that was used that resulted in the bug from pytubefix import YouTube from pytubefix.cli import on_progress
SAVE_PATH = "downloaded/" yt = YouTube(link, on_progress_callback = on_progress, use_po_token=True, token_file='token_file.json')
ya = yt.streams.filter(only_audio=True).order_by('abr').last() out_audio_file = ya.download(output_path=SAVE_PATH)
ys = yt.streams.get_highest_resolution(progressive=False) out_video_file = ys.download(output_path=SAVE_PATH) Desktop :
OS: Windows 11 Pro 23H2 OS Build: 22631.4317 Python Version: 3.9.9 Pytubefix Version: 8.1.1