[fansly] add 'previews' option (#8686)
This commit is contained in:
@@ -25,6 +25,7 @@ class FanslyExtractor(Extractor):
|
||||
|
||||
def _init(self):
|
||||
self.api = FanslyAPI(self)
|
||||
self.previews = self.config("previews", True)
|
||||
|
||||
if fmts := self.config("formats"):
|
||||
self.formats = set(fmts)
|
||||
@@ -88,8 +89,8 @@ class FanslyExtractor(Extractor):
|
||||
exc.__class__.__name__, exc)
|
||||
return files
|
||||
|
||||
def _extract_attachment(self, files, post, attachment):
|
||||
media = attachment["media"]
|
||||
def _extract_attachment(self, files, post, attachment, preview=False):
|
||||
media = attachment["preview" if preview else "media"]
|
||||
|
||||
variants = media.pop("variants") or []
|
||||
if media.get("locations"):
|
||||
@@ -107,6 +108,10 @@ class FanslyExtractor(Extractor):
|
||||
try:
|
||||
variant = max(formats)[-1]
|
||||
except Exception:
|
||||
if self.previews and "preview" in attachment and not preview:
|
||||
self.log.info("%s/%s: Downloading Preview",
|
||||
post["id"], attachment["id"])
|
||||
return self._extract_attachment(files, post, attachment, True)
|
||||
return self.log.warning("%s/%s: No format available",
|
||||
post["id"], attachment["id"])
|
||||
|
||||
@@ -120,6 +125,7 @@ class FanslyExtractor(Extractor):
|
||||
|
||||
file = {
|
||||
**variant,
|
||||
"preview": preview,
|
||||
"format": variant["type"],
|
||||
"date": self.parse_timestamp(media["createdAt"]),
|
||||
"date_updated": self.parse_timestamp(media["updatedAt"]),
|
||||
|
||||
Reference in New Issue
Block a user