1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 03:02:50 +01:00

[telegraph] fix extraction when images not in <figure> (#3590)

This commit is contained in:
Mike Fährmann 2023-01-31 22:09:02 +01:00
parent 0f7e6c422a
commit 489c51cecc
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -68,6 +68,21 @@ class TelegraphGalleryExtractor(GalleryExtractor):
"title": "Всё о друзьях моей сестрицы", "title": "Всё о друзьях моей сестрицы",
}, },
}), }),
("https://telegra.ph/Disharmonica---Saber-Nero-02-21", {
"pattern": r"https://telegra\.ph/file/[0-9a-f]+\.(jpg|png)",
"keyword": {
"author": "cosmos",
"caption": "",
"count": 89,
"date": "dt:2022-02-21 05:57:39",
"description": "",
"num_formatted": r"re:^\d{2}$",
"post_url": "https://telegra.ph"
"/Disharmonica---Saber-Nero-02-21",
"slug": "Disharmonica---Saber-Nero-02-21",
"title": "Disharmonica - Saber Nero",
},
}),
) )
def metadata(self, page): def metadata(self, page):
@ -89,7 +104,8 @@ class TelegraphGalleryExtractor(GalleryExtractor):
return data return data
def images(self, page): def images(self, page):
figures = tuple(text.extract_iter(page, "<figure>", "</figure>")) figures = (tuple(text.extract_iter(page, "<figure>", "</figure>")) or
tuple(text.extract_iter(page, "<img", ">")))
num_zeroes = len(str(len(figures))) num_zeroes = len(str(len(figures)))
num = 0 num = 0
@ -105,7 +121,7 @@ class TelegraphGalleryExtractor(GalleryExtractor):
result.append((url, { result.append((url, {
"url" : url, "url" : url,
"caption" : text.unescape(caption), "caption" : text.unescape(caption) if caption else "",
"num" : num, "num" : num,
"num_formatted": str(num).zfill(num_zeroes), "num_formatted": str(num).zfill(num_zeroes),
})) }))