Debian Codegraph @

gallery_dl/extractor/sxypix.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://sxypix.com/"""
8
9 from .common import GalleryExtractor
10 from .. import text
11
12
13 class SxypixGalleryExtractor(GalleryExtractor):
14 """Extractor for image galleries from sxypix.com"""
15 category = "sxypix"
16 root = "https://sxypix.com"
17 pattern = r"(?:https?://)?(?:www\.)?sxypix\.com(/w/(\w+))"
18 example = "https://sxypix.com/w/2bbaf1b24a5863d0e73436619bbaa7ee"
19
20 def metadata(self, page):
21 return {
22 "gallery_id": self.groups[1],
23 "title": text.unescape(text.extr(
24 page, '<meta name="keywords" content="', '"')),
25 }
26
27 def images(self, page):
28 data = {
29 "aid" : text.extr(page, "data-aid='", "'"),
30 "ghash": text.extr(page, "data-ghash='", "'"),
31 }
32 gallery = self.request_json(
33 "https://sxypix.com/php/gall.php", method="POST", data=data)
34
35 base = "https://x."
36 return [
37 (base + text.extr(entry, "data-src='//.", "'"), None)
38 for entry in gallery["r"]
39 ]