Update the date in the Google consent cookie

This commit is contained in:
Kovid Goyal 2023-11-15 08:23:25 +05:30
parent 4c68fafd41
commit c67412e1cf
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 4 deletions

View File

@ -46,7 +46,7 @@ def imgurl_from_id(raw, tbnid):
class GoogleImages(Source):
name = 'Google Images'
version = (1, 0, 4)
version = (1, 0, 5)
minimum_calibre_version = (2, 80, 0)
description = _('Downloads covers from a Google Image search. Useful to find larger/alternate covers.')
capabilities = frozenset(['cover'])
@ -107,7 +107,11 @@ class GoogleImages(Source):
log('Search URL: ' + url)
# See https://github.com/benbusby/whoogle-search/pull/1054 for cookies
br.set_simple_cookie('CONSENT', 'PENDING+987', '.google.com', path='/')
br.set_simple_cookie('SOCS','CAESHAgBEhJnd3NfMjAyMzA4MTAtMF9SQzIaAmRlIAEaBgiAo_CmBg', '.google.com', path='/')
template = b'\x08\x01\x128\x08\x14\x12+boq_identityfrontenduiserver_20231107.05_p0\x1a\x05en-US \x03\x1a\x06\x08\x80\xf1\xca\xaa\x06'
from datetime import date
from base64 import standard_b64encode
template.replace(b'20231107', date.today().strftime('%Y%m%d').encode('ascii'))
br.set_simple_cookie('SOCS', standard_b64encode(template).decode('ascii').rstrip('='), '.google.com', path='/')
# br.set_debug_http(True)
raw = clean_ascii_chars(br.open(url).read().decode('utf-8'))
# with open('/t/raw.html', 'w') as f:

View File

@ -27,7 +27,7 @@ from calibre.ebooks.chardet import xml_to_unicode
from calibre.utils.lock import ExclusiveFile
from calibre.utils.random_ua import accept_header_for_ua
current_version = (1, 2, 3)
current_version = (1, 2, 4)
minimum_calibre_version = (2, 80, 0)
webcache = {}
webcache_lock = Lock()
@ -370,7 +370,11 @@ def google_specialize_browser(br):
if not hasattr(br, 'google_consent_cookie_added'):
# See https://github.com/benbusby/whoogle-search/pull/1054 for cookies
br.set_simple_cookie('CONSENT', 'PENDING+987', '.google.com', path='/')
br.set_simple_cookie('SOCS','CAESHAgBEhJnd3NfMjAyMzA4MTAtMF9SQzIaAmRlIAEaBgiAo_CmBg', '.google.com', path='/')
template = b'\x08\x01\x128\x08\x14\x12+boq_identityfrontenduiserver_20231107.05_p0\x1a\x05en-US \x03\x1a\x06\x08\x80\xf1\xca\xaa\x06'
from datetime import date
from base64 import standard_b64encode
template.replace(b'20231107', date.today().strftime('%Y%m%d').encode('ascii'))
br.set_simple_cookie('SOCS', standard_b64encode(template).decode('ascii').rstrip('='), '.google.com', path='/')
br.google_consent_cookie_added = True
return br