Skip to content

Commit

Permalink
- adapt code to current code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobi823 committed Dec 10, 2023
1 parent fd06255 commit 244444b
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions gallery_dl/extractor/patreon.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,28 @@ def _build_file_generators(self, filetypes):
return [genmap[ft] for ft in filetypes]

def _extract_bootstrap(self, page):
if "window.patreon.bootstrap," in page:
content_begin = "window.patreon.bootstrap,"
content_end = "});"
json_string = text.extr(page, content_begin, content_end) + "}"
elif 'window.patreon = {"bootstrap":' in page:
content_begin = 'window.patreon = {"bootstrap":'
content_end = '},"apiServer"'
json_string = text.extr(page, content_begin, content_end) + "}"
elif 'window.patreon = wrapInProxy({"bootstrap":' in page:
content_begin = 'window.patreon = wrapInProxy({"bootstrap":'
content_end = '},"apiServer"'
json_string = text.extr(page, content_begin, content_end) + "}"
else:
raise Exception("Unknown HTML and JS structure. Page:" + page)
return util.json_loads(json_string)
bootstrap = text.extr(
page, 'window.patreon = {"bootstrap":', '},"apiServer"')
if bootstrap:
return util.json_loads(bootstrap + "}")

bootstrap = text.extr(
page, 'window.patreon = wrapInProxy({"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):
Expand Down

0 comments on commit 244444b

Please sign in to comment.