Debian Codegraph @

gallery_dl/extractor/shareimage.py

raw
1 # -*- coding: utf-8 -*-
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License version 2 as
5 # published by the Free Software Foundation.
6
7 """Extractors for https://www.share-image.com/"""
8
9 from .common import GalleryExtractor
10 from .. import text
11
12
13 class ShareimageGalleryExtractor(GalleryExtractor):
14 """Extractor for image galleries from share-image.com"""
15 category = "shareimage"
16 root = "https://www.share-image.com"
17 pattern = r"(?:https?://)?(?:www\.)?share-image\.com(/(\d+)[^/?#]*)"
18 example = "https://www.share-image.com/12345-TITLE"
19
20 def metadata(self, page):
21 self.schema = schema = self._extract_jsonld(page)
22 return {
23 "gallery_id" : text.parse_int(self.groups[1]),
24 "gallery_url": schema.get("url"),
25 "title" : schema.get("name"),
26 }
27
28 def images(self, page):
29 return [(url, None) for url in self.schema["image"]]