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

[imgbb] Fix user extraction, add displayname #4626

Merged
merged 1 commit into from
Oct 9, 2023
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
22 changes: 14 additions & 8 deletions gallery_dl/extractor/imgbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ def __init__(self, match):
self.page_url = "https://ibb.co/album/" + self.album_id

def metadata(self, page):
album, pos = text.extract(page, '"og:title" content="', '"')
user , pos = text.extract(page, 'rel="author">', '<', pos)
album , pos = text.extract(page, '"og:title" content="', '"')
user , pos = text.extract(page, ',"username":"', '"', pos)
displayname, pos = text.extract(page, '"user":{"name":"', '"')
return {
"album_id" : self.album_id,
"album_name": text.unescape(album),
"user" : user.lower() if user else "",
"album_id" : self.album_id,
"album_name" : text.unescape(album),
"user" : user.lower() if user else "",
"displayname": displayname if displayname else "",
}

def images(self, page):
Expand Down Expand Up @@ -158,7 +160,11 @@ def __init__(self, match):
self.page_url = "https://{}.imgbb.com/".format(self.user)

def metadata(self, page):
return {"user": self.user}
displayname, pos = text.extract(page, '"user":{"name":"', '"')
return {
"user" : self.user,
"displayname": displayname if displayname else "",
}

def images(self, page):
user = text.extr(page, '.obj.resource={"id":"', '"')
Expand All @@ -185,11 +191,11 @@ def items(self):

image = {
"id" : self.image_id,
"title" : text.unescape(extr('"og:title" content="', '"')),
"title" : text.unescape(extr('"og:title" content="', ' hosted at ImgBB"')),
"url" : extr('"og:image" content="', '"'),
"width" : text.parse_int(extr('"og:image:width" content="', '"')),
"height": text.parse_int(extr('"og:image:height" content="', '"')),
"user" : extr('rel="author">', '<').lower(),
"user" : extr(',"username":"', '"').lower(),
}
image["extension"] = text.ext_from_url(image["url"])

Expand Down
Loading