1
0
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:
Mike Fährmann 2023-10-29 15:57:21 +01:00
parent 28ada11cba
commit 4730de163f
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -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):