mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-04-11 03:31:58 -04:00
Make CodeQL happy
This commit is contained in:
parent
f2c8596d56
commit
bfb2f527f9
@ -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:])
|
||||
|
||||
# }}}
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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'):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user