mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-10-24 07:18:54 -04:00
Update NYTimes
Now they apparently are incapable of generating valid JSON even. Sigh.
This commit is contained in:
parent
cff6497bec
commit
921d82e63f
@ -267,7 +267,7 @@ def preloaded_data(soup):
|
||||
raw = clean_js_json(raw)
|
||||
# with open('/t/raw.json', 'w') as f:
|
||||
# f.write(raw)
|
||||
return json.loads(raw)['initialState']
|
||||
return json.JSONDecoder(strict=False).raw_decode(raw)[0]['initialState']
|
||||
|
||||
|
||||
def asset_to_article(asset):
|
||||
|
||||
@ -267,7 +267,7 @@ def preloaded_data(soup):
|
||||
raw = clean_js_json(raw)
|
||||
# with open('/t/raw.json', 'w') as f:
|
||||
# f.write(raw)
|
||||
return json.loads(raw)['initialState']
|
||||
return json.JSONDecoder(strict=False).raw_decode(raw)[0]['initialState']
|
||||
|
||||
|
||||
def asset_to_article(asset):
|
||||
|
||||
@ -132,7 +132,7 @@ def preloaded_data(soup):
|
||||
script = str(script)
|
||||
raw = script[script.find('{') : script.rfind(';')].strip().rstrip(';') # }
|
||||
raw = clean_js_json(raw)
|
||||
return json.loads(raw)['initialState']
|
||||
return json.JSONDecoder(strict=False).raw_decode(raw)[0]['initialState']
|
||||
|
||||
|
||||
def parse_toc(soup):
|
||||
|
||||
@ -9,7 +9,7 @@ from xml.sax.saxutils import escape, quoteattr
|
||||
|
||||
from calibre.utils.iso8601 import parse_iso8601
|
||||
|
||||
module_version = 13 # needed for live updates
|
||||
module_version = 14 # needed for live updates
|
||||
pprint
|
||||
|
||||
|
||||
@ -207,7 +207,7 @@ def clean_js_json(text):
|
||||
|
||||
|
||||
def json_to_html(raw):
|
||||
data = json.loads(clean_js_json(raw))
|
||||
data = json.JSONDecoder(strict=False).raw_decode(raw)[0]
|
||||
# open('/t/raw.json', 'w').write(json.dumps(data, indent=2))
|
||||
try:
|
||||
data = data['initialData']['data']
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user