Debian Codegraph @

gallery_dl/extractor/adultempire.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright 2019-2025 Mike Fährmann
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation.
8
9 """Extractors for https://www.adultempire.com/"""
10
11 from .common import GalleryExtractor
12 from .. import text
13
14
15 class AdultempireGalleryExtractor(GalleryExtractor):
16 """Extractor for image galleries from www.adultempire.com"""
17 category = "adultempire"
18 root = "https://www.adultempire.com"
19 pattern = (r"(?:https?://)?(?:www\.)?adult(?:dvd)?empire\.com"
20 r"(/(\d+)/gallery\.html)")
21 example = "https://www.adultempire.com/12345/gallery.html"
22
23 def __init__(self, match):
24 GalleryExtractor.__init__(self, match)
25 self.gallery_id = match[2]
26
27 def _init(self):
28 self.cookies.set("ageConfirmed", "true", domain="www.adultempire.com")
29
30 def metadata(self, page):
31 extr = text.extract_from(page, page.index('<div id="content">'))
32 return {
33 "gallery_id": text.parse_int(self.gallery_id),
34 "title" : text.unescape(extr('title="', '"')),
35 "studio" : extr(">studio</small>", "<").strip(),
36 "date" : self.parse_datetime(extr(
37 ">released</small>", "<").strip(), "%m/%d/%Y"),
38 "actors" : sorted(text.split_html(extr(
39 '<ul class="item-details item-cast-list ', '</ul>'))[1:]),
40 }
41
42 def images(self, page):
43 params = {"page": 1}
44 while True:
45 urls = list(text.extract_iter(page, 'rel="L"><img src="', '"'))
46 for url in urls:
47 yield url.replace("_200.", "_9600."), None
48 if len(urls) < 24:
49 return
50 params["page"] += 1
51 page = self.request(self.page_url, params=params).text