diff options
| author | 2024-12-22 05:45:25 -0500 | |
|---|---|---|
| committer | 2024-12-22 05:45:25 -0500 | |
| commit | 68cc5921fab97c0c3609b78838f269e6883af35b (patch) | |
| tree | f427342e95ddf535e9465c5a5b87e3567a96faaf /gallery_dl/extractor/cohost.py | |
| parent | 2a5605e9f5348fe08b246ccd5c78c43c890c8896 (diff) | |
| parent | bb8260277ab7483652c6c1526a15d62da92acc96 (diff) | |
Update upstream source from tag 'upstream/1.28.2'
Update to upstream version '1.28.2'
with Debian dir fd5292656afeea7f61ec976dd10e1aab9da1dd13
Diffstat (limited to 'gallery_dl/extractor/cohost.py')
| -rw-r--r-- | gallery_dl/extractor/cohost.py | 30 |
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) |
