Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mikf
GitHub Repository: mikf/gallery-dl
Path: blob/master/gallery_dl/extractor/comedywildlifephoto.py
8950 views
1
# -*- coding: utf-8 -*-
2
3
# Copyright 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.comedywildlifephoto.com/"""
10
11
from .common import GalleryExtractor
12
from .. import text
13
14
15
class ComedywildlifephotoGalleryExtractor(GalleryExtractor):
16
"""Extractor for comedywildlifephoto galleries"""
17
category = "comedywildlifephoto"
18
root = "https://www.comedywildlifephoto.com"
19
directory_fmt = ("{category}", "{section}", "{title}")
20
filename_fmt = "{num:>03} {filename}.{extension}"
21
archive_fmt = "{section}/{title}/{num}"
22
pattern = (r"(?:https?://)?(?:www\.)?comedywildlifephoto\.com"
23
r"(/gallery/[^/?#]+/[^/?#]+\.php)")
24
example = "https://www.comedywildlifephoto.com/gallery/SECTION/TITLE.php"
25
26
def metadata(self, page):
27
extr = text.extract_from(page)
28
29
return {
30
"section": extr("<h1>", "<").strip(),
31
"title" : extr(">", "<"),
32
"description": text.unescape(extr(
33
'class="c1 np">', "<div")),
34
}
35
36
def images(self, page):
37
results = []
38
39
for fig in text.extract_iter(page, "<figure", "</figure>"):
40
width, _, height = text.extr(
41
fig, 'data-size="', '"').partition("x")
42
results.append((
43
self.root + text.extr(fig, 'href="', '"'), {
44
"width" : text.parse_int(width),
45
"height" : text.parse_int(height),
46
"caption": text.unescape(text.extr(
47
fig, "<figcaption>", "<")),
48
}
49
))
50
51
return results
52
53