MCPcopy
hub / github.com/mikf/gallery-dl / _extract_files

Method _extract_files

gallery_dl/extractor/xfolio.py:86–131  ·  view source on GitHub ↗
(self, html, work)

Source from the content-addressed store, hash-verified

84 }
85
86 def _extract_files(self, html, work):
87 work_id = work["work_id"]
88
89 if self._logged_in and self.config("fullsize", True) and \
90 (pos := html.find("-fullscale_download_")) >= 0 and \
91 text.extract(html, 'data-is-purchased="', '"', pos)[0] == "1":
92 return ({
93 "url": (f"{self.root}/user_asset.php"
94 f"?id={work_id}&type=work_zip"),
95 "extension": "zip",
96 "image_id" : 0,
97 },)
98
99 files = []
100 for img in text.extract_iter(
101 html, 'class="article__wrap_img', "</div>"):
102 if image_id := text.extr(img, "/fullscale_image?image_id=", "&"):
103 ext = "jpg"
104 url = (f"{self.root}/user_asset.php?id={image_id}"
105 f"&work_id={work_id}&work_image_id={image_id}"
106 f"&type=work_image")
107 headers = {"Referer": (
108 f"{self.root}/fullscale_image"
109 f"?image_id={image_id}&work_id={work_id}")},
110 elif url := text.extr(img, ' src="', '"'):
111 image_id = url.split("/", 5)[-2]
112 url = text.unescape(url)
113 ext = text.ext_from_url(url)
114 headers = {
115 "Referer" : self.root + "/",
116 "Sec-Fetch-Dest": "image",
117 "Sec-Fetch-Mode": "no-cors",
118 "Sec-Fetch-Site": "same-site",
119 }
120 else:
121 self.log.debug(html)
122 self.log.warning("%s: Failed to find image", work_id)
123 continue
124
125 files.append({
126 "image_id" : image_id,
127 "url" : url,
128 "extension": ext,
129 "_http_headers": headers,
130 })
131 return files
132
133
134class XfolioUserExtractor(XfolioExtractor):

Callers 1

itemsMethod · 0.95

Calls 3

configMethod · 0.45
debugMethod · 0.45
warningMethod · 0.45

Tested by

no test coverage detected