diff --git a/src/calibre/ebooks/metadata/sources/google_images.py b/src/calibre/ebooks/metadata/sources/google_images.py index e7980c6a44..08e17546fa 100644 --- a/src/calibre/ebooks/metadata/sources/google_images.py +++ b/src/calibre/ebooks/metadata/sources/google_images.py @@ -46,7 +46,7 @@ def imgurl_from_id(raw, tbnid): class GoogleImages(Source): name = 'Google Images' - version = (1, 0, 3) + version = (1, 0, 4) minimum_calibre_version = (2, 80, 0) description = _('Downloads covers from a Google Image search. Useful to find larger/alternate covers.') capabilities = frozenset(['cover']) @@ -105,8 +105,13 @@ class GoogleImages(Source): # URL scheme url = 'https://www.google.com/search?as_st=y&tbm=isch&{}&as_epq=&as_oq=&as_eq=&cr=&as_sitesearch=&safe=images&tbs={}iar:t,ift:jpg'.format(q, sz) log('Search URL: ' + url) - br.set_simple_cookie('CONSENT', 'YES+', '.google.com', path='/') + # 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='/') + # br.set_debug_http(True) raw = clean_ascii_chars(br.open(url).read().decode('utf-8')) + # with open('/t/raw.html', 'w') as f: + # f.write(raw) root = parse_html(raw) results = root.xpath('//div/@data-tbnid') # could also use data-id # from calibre.utils.ipython import ipython @@ -135,6 +140,5 @@ def test(): authors=('Joe Abercrombie',)) print('Downloaded', rq.qsize(), 'covers') - if __name__ == '__main__': test() diff --git a/src/calibre/ebooks/metadata/sources/search_engines.py b/src/calibre/ebooks/metadata/sources/search_engines.py index f1567d4b15..856be16f74 100644 --- a/src/calibre/ebooks/metadata/sources/search_engines.py +++ b/src/calibre/ebooks/metadata/sources/search_engines.py @@ -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, 2) +current_version = (1, 2, 3) minimum_calibre_version = (2, 80, 0) webcache = {} webcache_lock = Lock() @@ -368,7 +368,9 @@ def google_parse_results(root, raw, log=prints, ignore_uncached=True): def google_specialize_browser(br): with webcache_lock: if not hasattr(br, 'google_consent_cookie_added'): - br.set_simple_cookie('CONSENT', 'YES+', '.google.com', path='/') + # 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='/') br.google_consent_cookie_added = True return br