Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skeb] add 'num' and 'count' metadata fields #5187

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions gallery_dl/extractor/skeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ def items(self):
response, post = self._get_post_data(user_name, post_num)
if metadata:
post.update(metadata)

datas = self._get_urls_from_post(response)
post["count"] = len(datas)
yield Message.Directory, post
for data in self._get_urls_from_post(response, post):
url = data["file_url"]
yield Message.Url, url, text.nameext_from_url(url, data)
for post["num"], data in enumerate(datas, 1):
post.update(data)
url = post["file_url"]
yield Message.Url, url, text.nameext_from_url(url, post)

def posts(self):
"""Return post number"""
Expand Down Expand Up @@ -105,29 +109,34 @@ def _get_post_data(self, user_name, post_num):
}
return resp, post

def _get_urls_from_post(self, resp, post):
def _get_urls_from_post(self, resp):
datas = []

if self.thumbnails and "og_image_url" in resp:
post["content_category"] = "thumb"
post["file_id"] = "thumb"
post["_file_id"] = str(resp["id"]) + "t"
post["file_url"] = resp["og_image_url"]
yield post
data = {}
data["content_category"] = "thumb"
data["file_id"] = "thumb"
data["_file_id"] = str(resp["id"]) + "t"
data["file_url"] = resp["og_image_url"]
datas.append(data)

if self.article and "article_image_url" in resp:
url = resp["article_image_url"]
if url:
post["content_category"] = "article"
post["file_id"] = "article"
post["_file_id"] = str(resp["id"]) + "a"
post["file_url"] = url
yield post
data = {}
data["content_category"] = "article"
data["file_id"] = "article"
data["_file_id"] = str(resp["id"]) + "a"
data["file_url"] = url
datas.append(data)

for preview in resp["previews"]:
post["content_category"] = "preview"
post["file_id"] = post["_file_id"] = preview["id"]
post["file_url"] = preview["url"]
data = {}
data["content_category"] = "preview"
data["file_id"] = data["_file_id"] = preview["id"]
data["file_url"] = preview["url"]
info = preview["information"]
post["original"] = {
data["original"] = {
"width" : info["width"],
"height" : info["height"],
"byte_size" : info["byte_size"],
Expand All @@ -138,7 +147,9 @@ def _get_urls_from_post(self, resp, post):
"is_movie" : info["is_movie"],
"transcoder": info["transcoder"],
}
yield post
datas.append(data)

return datas


class SkebPostExtractor(SkebExtractor):
Expand Down
Loading