mirror of
https://github.com/mikf/gallery-dl.git
synced 2025-01-31 11:41:35 +01:00
[imagechest] simplify code (#750)
This commit is contained in:
parent
ece73b5b2a
commit
ab11b1c896
@ -53,6 +53,7 @@ Hitomi.la https://hitomi.la/ Galleries, Tag Searches
|
||||
Hypnohub https://hypnohub.net/ Pools, Popular Images, Posts, Tag Searches
|
||||
Idol Complex https://idol.sankakucomplex.com/ Pools, Posts, Tag Searches Optional
|
||||
ImageBam http://www.imagebam.com/ Galleries, individual Images
|
||||
ImageChest https://imgchest.com/ Galleries
|
||||
ImageFap https://imagefap.com/ Galleries, individual Images, User Profiles
|
||||
ImgBB https://imgbb.com/ Albums, individual Images, User Profiles Optional
|
||||
imgbox https://imgbox.com/ Galleries, individual Images
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2014-2020 Leonid "Bepis" Pavel
|
||||
# Copyright 2020 Leonid "Bepis" Pavel
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
@ -10,15 +10,12 @@
|
||||
|
||||
from .common import GalleryExtractor
|
||||
from .. import text, exception
|
||||
import re
|
||||
|
||||
|
||||
class ImagechestGalleryExtractor(GalleryExtractor):
|
||||
"""Extractor for image galleries from imgchest.com"""
|
||||
|
||||
category = "imagechest"
|
||||
root = "https://imgchest.com"
|
||||
|
||||
pattern = r"(?:https?://)?(?:www\.)?imgchest\.com/p/([A-Za-z0-9]{11})"
|
||||
test = (
|
||||
("https://imgchest.com/p/3na7kr3by8d", {
|
||||
@ -29,38 +26,23 @@ class ImagechestGalleryExtractor(GalleryExtractor):
|
||||
)
|
||||
|
||||
def __init__(self, match):
|
||||
|
||||
self.gallery_id = match.group(1)
|
||||
url = self.root + "/p/" + self.gallery_id
|
||||
|
||||
GalleryExtractor.__init__(self, match, url)
|
||||
|
||||
def metadata(self, page):
|
||||
"""Return a dict with general metadata"""
|
||||
|
||||
if "Sorry, but the page you requested could not be found." in page:
|
||||
raise exception.NotFoundError("gallery")
|
||||
|
||||
title_match = re.search(
|
||||
r'<meta property="og:title" content="([^"]+)"/>',
|
||||
page)
|
||||
|
||||
title = title_match.group(1).strip()
|
||||
|
||||
return {
|
||||
"gallery_id": self.gallery_id,
|
||||
"title": text.unescape(title)
|
||||
"title": text.unescape(text.extract(
|
||||
page, 'property="og:title" content="', '"')[0].strip())
|
||||
}
|
||||
|
||||
def images(self, page):
|
||||
"""Return a list of all (image-url, metadata)-tuples"""
|
||||
|
||||
image_keys = re.findall(
|
||||
r'<meta property="og:image" content="([^"]+)"/>',
|
||||
page)
|
||||
|
||||
for imgurl in image_keys:
|
||||
|
||||
data = text.nameext_from_url(imgurl)
|
||||
|
||||
yield imgurl, data
|
||||
return [
|
||||
(url, None)
|
||||
for url in text.extract_iter(
|
||||
page, 'property="og:image" content="', '"')
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user