Warn when solving captcha
This commit is contained in:
parent
c11eec9555
commit
e028ee929c
@ -464,7 +464,8 @@ def get_live_urls(urls):
|
||||
def watch():
|
||||
id = request.args.get('v', None)
|
||||
info = ytwatch.extract_info(id, False, playlist_id=None, index=None)
|
||||
|
||||
if info == 'Captcha':
|
||||
return render_template('captcha.html', origin=request.referrer)
|
||||
retry = 3
|
||||
while retry != 0 and info['playability_error'] == 'Could not find player':
|
||||
info=ytwatch.extract_info(id, False, playlist_id=None, index=None)
|
||||
|
18
app/templates/captcha.html
Normal file
18
app/templates/captcha.html
Normal file
@ -0,0 +1,18 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="ui text container center aligned centered">
|
||||
<div class="ui icon negative message">
|
||||
<i class="meh outline icon"></i>
|
||||
<div class="content">
|
||||
<div class="header">
|
||||
Ahh... Here we go again!
|
||||
</div>
|
||||
<p>Google is asking to solve a Captcha. As we don't want you to do it, we'll do it for you.</p>
|
||||
<p>Try again in a few seconds.</p>
|
||||
<a href="{{origin}}"> Click here to reload </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{%endblock%}
|
@ -200,6 +200,7 @@ def fetch_url_response(url, headers=(), timeout=15, data=None,
|
||||
# If there's a captcha, bypass it.
|
||||
if string_de in response.text or string_en in response.text:
|
||||
bypass_captcha(session, response, url)
|
||||
return "Captcha", "Captcha"
|
||||
|
||||
if max_redirects:
|
||||
retries = urllib3.Retry(3 + max_redirects, redirect=max_redirects)
|
||||
@ -226,8 +227,10 @@ def fetch_url(url, headers=(), timeout=15, report_text=None, data=None,
|
||||
cookiejar_send=cookiejar_send, cookiejar_receive=cookiejar_receive,
|
||||
use_tor=use_tor)
|
||||
print(response)
|
||||
response_time = time.time()
|
||||
|
||||
if response == "Captcha":
|
||||
return "Captcha"
|
||||
response_time = time.time()
|
||||
content = response.read()
|
||||
read_finish = time.time()
|
||||
cleanup_func(response) # release_connection for urllib3
|
||||
|
@ -171,6 +171,11 @@ def extract_info(video_id, use_invidious, playlist_id=None, index=None):
|
||||
if index:
|
||||
url += '&index=' + index
|
||||
polymer_json = util.fetch_url(url, headers=headers, debug_name='watch')
|
||||
|
||||
# If there's a captcha... Return word Captcha
|
||||
if polymer_json == 'Captcha':
|
||||
return 'Captcha'
|
||||
|
||||
polymer_json = polymer_json.decode('utf-8')
|
||||
# TODO: Decide whether this should be done in yt_data_extract.extract_watch_info
|
||||
try:
|
||||
|
Reference in New Issue
Block a user