Debian Codegraph @

gallery_dl/extractor/pornstarstube.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://pornstars.tube/"""
8
9 from .common import GalleryExtractor
10 from .. import text
11
12
13 class PornstarstubeGalleryExtractor(GalleryExtractor):
14 """Extractor for image galleries from pornstars.tube"""
15 category = "pornstarstube"
16 root = "https://pornstars.tube"
17 pattern = (r"(?:https?://)?(?:www\.)?pornstars\.tube"
18 r"/albums/(\d+)(?:/([\w-]+))?")
19 example = "https://pornstars.tube/albums/12345/SLUG/"
20
21 def __init__(self, match):
22 url = f"{self.root}/albums/{match[1]}/{match[2] or 'a'}/"
23 GalleryExtractor.__init__(self, match, url)
24
25 def metadata(self, page):
26 gid, slug = self.groups
27 return {
28 "gallery_id": text.parse_int(gid),
29 "slug" : slug or "",
30 "title" : text.unescape(text.extr(
31 page, "<title>", " - PORNSTARS.TUBE</title>")),
32 "description": text.unescape(text.extr(
33 page, 'name="description" content="', '"')),
34 "tags": text.extr(
35 page, 'name="keywords" content="', '"').split(", "),
36 }
37
38 def images(self, page):
39 album = text.extr(page, 'class="block-album"', "\n</div>")
40 return [
41 (url, None)
42 for url in text.extract_iter(album, ' href="', '"')
43 ]