Debian Codegraph @

gallery_dl/extractor/okporn.py

raw symbols SCIP
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://ok.porn/"""
8
9 from .common import GalleryExtractor
10 from .. import text
11
12
13 class OkpornGalleryExtractor(GalleryExtractor):
14 """Extractor for image galleries from ok.porn"""
15 category = "okporn"
16 root = "https://ok.porn"
17 pattern = r"(?:https?://)?(?:www\.)?ok\.porn/albums/(\d+)"
18 example = "https://ok.porn/albums/12345/"
19
20 def __init__(self, match):
21 url = f"{self.root}/albums/{match[1]}/"
22 GalleryExtractor.__init__(self, match, url)
23
24 def metadata(self, page):
25 return {
26 "gallery_id" : text.parse_int(self.groups[0]),
27 "title" : text.unescape(text.extr(
28 page, "h1 class=title>", "</h1>")),
29 "description": text.unescape(text.extr(
30 page, 'name="description" content="', '"')),
31 "tags": text.extr(
32 page, 'name="keywords" content="', '"').split(", "),
33 }
34
35 def images(self, page):
36 return [
37 (url, None)
38 for url in text.extract_iter(page, 'data-original="', '"')
39 ]