mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 18:53:21 +01:00
[patreon] refactor _extract_bootstrap()
This commit is contained in:
parent
28ada11cba
commit
4730de163f
@ -249,14 +249,23 @@ class PatreonExtractor(Extractor):
|
||||
return [genmap[ft] for ft in filetypes]
|
||||
|
||||
def _extract_bootstrap(self, page):
|
||||
if "window.patreon.bootstrap," in page:
|
||||
return util.json_loads(text.extr(
|
||||
page, "window.patreon.bootstrap,", "});") + "}")
|
||||
elif 'window.patreon = {"bootstrap":' in page:
|
||||
return util.json_loads(text.extr(
|
||||
page, 'window.patreon = {"bootstrap":', '},"apiServer"') + "}")
|
||||
else:
|
||||
raise Exception("unknown HTML and JS structure")
|
||||
bootstrap = text.extr(
|
||||
page, 'window.patreon = {"bootstrap":', '},"apiServer"')
|
||||
if bootstrap:
|
||||
return util.json_loads(bootstrap + "}")
|
||||
|
||||
bootstrap = text.extr(page, "window.patreon.bootstrap,", "});")
|
||||
if bootstrap:
|
||||
return util.json_loads(bootstrap + "}")
|
||||
|
||||
data = text.extr(page, "window.patreon = {", "};\n")
|
||||
if data:
|
||||
try:
|
||||
return util.json_loads("{" + data + "}")["bootstrap"]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
raise exception.StopExtraction("Unable to extract bootstrap data")
|
||||
|
||||
|
||||
class PatreonCreatorExtractor(PatreonExtractor):
|
||||
|
Loading…
Reference in New Issue
Block a user