aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/yourlesbians.py
blob: 5e14f6e04c84321221a0d8d97ba9eabfbc3af03d (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
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-

# Copyright 2025 Mike Fährmann
#
# 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://yourlesbians.com/"""

from .common import GalleryExtractor
from .. import text

BASE_PATTERN = r"(?:https?://)?(?:www\.)?yourlesbians\.com"


class YourlesbiansAlbumExtractor(GalleryExtractor):
    category = "yourlesbians"
    subcategory = "album"
    root = "https://yourlesbians.com"
    directory_fmt = ("{category}", "{title}")
    filename_fmt = "{num:>03} {filename}.{extension}"
    archive_fmt = "{title}/{num}"
    pattern = BASE_PATTERN + r"(/album/([^/?#]+)/?)"
    example = "https://yourlesbians.com/album/SLUG/"

    def metadata(self, page):
        extr = text.extract_from(page)
        data = {
            "album_url": extr('property="og:url" content="', '"'),
            "title": text.unescape(extr(
                'property="og:title" content="', '"')[:-8].rstrip()),
            "album_thumbnail": extr('property="og:image" content="', '"'),
            "description": extr('property="og:description" content="', '"'),
            "tags": text.split_html(extr('tags-row', '</div>'))[1:],
        }
        if data["description"].endswith(", right after."):
            data["description"] = ""
        self.album = extr('class="album-inner', "</div>")
        return data

    def images(self, _):
        results = []
        for url in text.extract_iter(self.album, '<a href="', '"'):
            fn, _, ext = url.rsplit("/", 2)[1].rpartition(".")
            results.append((url, {
                "filename" : fn,
                "extension": ext,
            }))
        return results