Skip to content

Commit

Permalink
[imgbb] Fix user extraction, add displayname
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrxn authored Oct 5, 2023
1 parent 85357c1 commit b846f56
Showing 1 changed file with 14 additions and 8 deletions.
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

0 comments on commit b846f56

Please sign in to comment.