Skip to content

Commit

Permalink
merge #4738: [patreon] parse new bootstrap data format (#4736)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 29, 2023
2 parents e46efbd + 4730de1 commit ca1d5c2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions gallery_dl/extractor/patreon.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,23 @@ def _build_file_generators(self, filetypes):
return [genmap[ft] for ft in filetypes]

def _extract_bootstrap(self, page):
return util.json_loads(text.extr(
page, "window.patreon.bootstrap,", "});") + "}")
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):
Expand Down

0 comments on commit ca1d5c2

Please sign in to comment.