aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/pornstarstube.py
blob: 82519a0e33979f74f182a922aa48407ea27f36d1 (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
40
41
42
43
# -*- 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://pornstars.tube/"""

from .common import GalleryExtractor
from .. import text


class PornstarstubeGalleryExtractor(GalleryExtractor):
    """Extractor for image galleries from pornstars.tube"""
    category = "pornstarstube"
    root = "https://pornstars.tube"
    pattern = (r"(?:https?://)?(?:www\.)?pornstars\.tube"
               r"/albums/(\d+)(?:/([\w-]+))?")
    example = "https://pornstars.tube/albums/12345/SLUG/"

    def __init__(self, match):
        url = f"{self.root}/albums/{match[1]}/{match[2] or 'a'}/"
        GalleryExtractor.__init__(self, match, url)

    def metadata(self, page):
        gid, slug = self.groups
        return {
            "gallery_id": text.parse_int(gid),
            "slug"      : slug or "",
            "title"     : text.unescape(text.extr(
                page, "<title>", " - PORNSTARS.TUBE</title>")),
            "description": text.unescape(text.extr(
                page, 'name="description" content="', '"')),
            "tags": text.extr(
                page, 'name="keywords" content="', '"').split(", "),
        }

    def images(self, page):
        album = text.extr(page, 'class="block-album"', "\n</div>")
        return [
            (url, None)
            for url in text.extract_iter(album, ' href="', '"')
        ]