# -*- coding: utf-8 -*- # Copyright 2026 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://lefty.pictures/""" from . import booru from .. import text BASE_PATTERN = r"(?:https?://)?lefty\.pictures" class LeftybooruExtractor(booru.BooruExtractor): """Base class for leftybooru extractors""" category = "leftybooru" basecategory = "shimmie2" root = "https://lefty.pictures" archive_fmt = "{id}" page_start = 1 per_page = 24 def _prepare(self, post): post["id"] = text.parse_int(post["id"]) post["width"] = text.parse_int(post["width"]) post["height"] = text.parse_int(post["height"]) class LeftybooruPostExtractor(LeftybooruExtractor): subcategory = "post" pattern = BASE_PATTERN + r"/post/view/(\d+)" example = "https://lefty.pictures/post/view/12345" def posts(self): post_id = self.groups[0] url = f"{self.root}/post/view/{post_id}" extr = text.extract_from(self.request(url).text) post = { "id" : post_id, "tags" : text.unescape(extr( "name='keywords' content='", "'")).split(", "), "file_url": extr("property='og:image' content='", "'"), "width" : extr("property='og:image:width' content='", "'"), "height" : extr("property='og:image:height' content='", "'"), "md5" : extr("/_images/", "/"), "uploader": extr(">Uploader: Size: ", "B")), "type" : extr(">Type: ", "<"), "duration": extr(">Length: ", "<"), "rating" : extr(">Rating: ", "")[34:35].lower(), "score" : extr(">Post Score: ", "<"), "source" : text.remove_html(extr( ">Source