aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/sxypix.py
blob: c9a1701ac7950b977427d8a8b72736292db86188 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-

# 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
# published by the Free Software Foundation.

"""Extractors for https://sxypix.com/"""

from .common import GalleryExtractor
from .. import text


class SxypixGalleryExtractor(GalleryExtractor):
    """Extractor for image galleries from sxypix.com"""
    category = "sxypix"
    root = "https://sxypix.com"
    pattern = r"(?:https?://)?(?:www\.)?sxypix\.com(/w/(\w+))"
    example = "https://sxypix.com/w/2bbaf1b24a5863d0e73436619bbaa7ee"

    def metadata(self, page):
        return {
            "gallery_id": self.groups[1],
            "title": text.unescape(text.extr(
                page, '<meta name="keywords" content="', '"')),
        }

    def images(self, page):
        data = {
            "aid"  : text.extr(page, "data-aid='", "'"),
            "ghash": text.extr(page, "data-ghash='", "'"),
        }
        gallery = self.request_json(
            "https://sxypix.com/php/gall.php", method="POST", data=data)

        base = "https://x."
        return [
            (base + text.extr(entry, "data-src='//.", "'"), None)
            for entry in gallery["r"]
        ]