summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/cohost.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2024-12-22 05:45:18 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2024-12-22 05:45:18 -0500
commitbb8260277ab7483652c6c1526a15d62da92acc96 (patch)
tree02959c9d5aceb66f4429e0be1bc927921e01bbdc /gallery_dl/extractor/cohost.py
parentf6877087773089220d68288d055276fca6c556d4 (diff)
New upstream version 1.28.2.upstream/1.28.2
Diffstat (limited to 'gallery_dl/extractor/cohost.py')
-rw-r--r--gallery_dl/extractor/cohost.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/gallery_dl/extractor/cohost.py b/gallery_dl/extractor/cohost.py
index 0524239..6a43224 100644
--- a/gallery_dl/extractor/cohost.py
+++ b/gallery_dl/extractor/cohost.py
@@ -19,7 +19,7 @@ class CohostExtractor(Extractor):
category = "cohost"
root = "https://cohost.org"
directory_fmt = ("{category}", "{postingProject[handle]}")
- filename_fmt = ("{postId}_{headline:?/_/[b:200]}{num}.{extension}")
+ filename_fmt = ("{postId}{headline:?_//[b:200]}{num:?_//}.{extension}")
archive_fmt = "{postId}_{num}"
def _init(self):
@@ -28,6 +28,14 @@ class CohostExtractor(Extractor):
self.shares = self.config("shares", False)
self.asks = self.config("asks", True)
+ self.avatar = self.config("avatar", False)
+ if self.avatar:
+ self._urls_avatar = {None, ""}
+
+ self.background = self.config("background", False)
+ if self.background:
+ self._urls_background = {None, ""}
+
def items(self):
for post in self.posts():
reason = post.get("limitedVisibilityReason")
@@ -43,6 +51,26 @@ class CohostExtractor(Extractor):
post["publishedAt"], "%Y-%m-%dT%H:%M:%S.%fZ")
yield Message.Directory, post
+
+ project = post["postingProject"]
+ if self.avatar:
+ url = project.get("avatarURL")
+ if url not in self._urls_avatar:
+ self._urls_avatar.add(url)
+ p = post.copy()
+ p["postId"] = p["kind"] = "avatar"
+ p["headline"] = p["num"] = ""
+ yield Message.Url, url, text.nameext_from_url(url, p)
+
+ if self.background:
+ url = project.get("headerURL")
+ if url not in self._urls_background:
+ self._urls_background.add(url)
+ p = post.copy()
+ p["postId"] = p["kind"] = "background"
+ p["headline"] = p["num"] = ""
+ yield Message.Url, url, text.nameext_from_url(url, p)
+
for post["num"], file in enumerate(files, 1):
url = file["fileURL"]
post.update(file)