Make CodeQL happy

This commit is contained in:
Kovid Goyal 2025-09-15 14:00:31 +05:30
parent f2c8596d56
commit bfb2f527f9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 13 additions and 7 deletions

View File

@ -202,7 +202,7 @@ def to_metadata(browser, log, entry_, timeout, running_a_test=False): # {{{
class GoogleBooks(Source):
name = 'Google'
version = (1, 1, 2)
version = (1, 1, 3)
minimum_calibre_version = (2, 80, 0)
description = _('Downloads metadata and covers from Google Books')
@ -447,7 +447,7 @@ class GoogleBooks(Source):
purl = urlparse(q.url)
except Exception:
continue
if not purl.hostname.startswith('https://books.google'):
if not purl.hostname.startswith('books.google'):
continue
google_ids.append(m.group(1))
@ -586,6 +586,6 @@ if __name__ == '__main__': # tests {{{
]),
]
test_identify_plugin(GoogleBooks.name, tests[:])
test_identify_plugin(GoogleBooks.name, tests[-1:])
# }}}

View File

@ -323,7 +323,7 @@ class Worker:
s.settimeout(5)
try:
if self.uses_ssl:
s = ssl.wrap_socket(s)
s = ssl.create_default_context().wrap_socket(s)
s.connect(('localhost', self.port))
return
except OSError:

View File

@ -9,7 +9,7 @@ from xml.sax.saxutils import escape, quoteattr
from calibre.utils.iso8601 import parse_iso8601
module_version = 15 # needed for live updates
module_version = 16 # needed for live updates
pprint
@ -52,9 +52,15 @@ def parse_vid(v):
yield f'<div class="cap">{v["promotionalSummary"]}</div>'
def get_data_wrapper(html: str | None) -> str:
m = re.search(r'datawrapper.dwcdn.net/(.{5})', html or '')
if m is not None:
return m.group(1)
return ''
def parse_emb(e):
if e.get('html') and 'datawrapper.dwcdn.net' in e.get('html', ''):
dw = re.search(r'datawrapper.dwcdn.net/(.{5})', e['html']).group(1)
if dw := get_data_wrapper(e.get('html')):
yield f'<div><img src="https://datawrapper.dwcdn.net/{dw}/full.png"></div>'
elif e.get('promotionalMedia'):
if e.get('headline'):