# -*- 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://www.comicartfans.com/""" from .common import Extractor, Message from .. import text, util BASE_PATTERN = r"(?i)(?:https?://)?(?:www\.)?comicartfans\.com" class ComicartfansExtractor(Extractor): """Base class for comicartfans extractors""" category = "comicartfans" root = "https://www.comicartfans.com" page_start = 1 per_page = 54 parent = True browser = "chrome" # cloudflare def items(self): data = {"_extractor": ComicartfansArtworkExtractor} base = self.root + "/" for path in self.works(): yield Message.Queue, base + path, data def skip_children(self, num): pages = num // self.per_page self.page_start += pages return pages * self.per_page def _pagination(self, url, params): if "pm" in params: params["pm"] = self.page_start + text.parse_int(params["pm"], 1)-1 else: params["pm"] = self.page_start needle = """\
Next »") if pos < 0 or page[pos-2] in '"#': break params["pm"] += 1 class ComicartfansArtworkExtractor(ComicartfansExtractor): subcategory = "artwork" directory_fmt = ("{category}", "{owner}") filename_fmt = "{id}{num:?_//} {title}.{extension}" archive_fmt = "{id}_{num}" pattern = BASE_PATTERN + r"/gallerypiece\.asp\?piece=(\d+)" example = "https://www.comicartfans.com/gallerypiece.asp?piece=12345" def items(self): iid = self.groups[0] url = f"{self.root}/gallerypiece.asp?piece={iid}" extr = text.extract_from(self.request(url, encoding="utf-8").text) work = { "id" : text.parse_int(iid), "views" : text.parse_int(extr('id="likecount-load">', "&")), "comments": text.parse_int(extr("- ", "&")), "likes" : text.parse_int(extr("- ", "&")), "file_url": extr('Additional Images", '
'), "location": text.unescape(extr( "Location:", "
").rpartition(">")[2]), "title" : text.unescape(extr("Title:", "<").strip()), "artist" : text.split_html(extr( "Artist:", "
").replace(" ", " "))[::2], "media_type" : extr("Media Type:", "<").lstrip(), "art_type": extr("Art Type:", "<").lstrip(), "sale_status": extr("For Sale Status:", "<").lstrip(), "date" : self.parse_datetime(extr( "Added to Site:", "<").lstrip(), "%m/%d/%Y"), "description": text.unescape(extr( 'content description-box">', "
").strip()), "owner_id": text.parse_int(extr( '>\n", "<").replace(" ", " ")).strip(), "owner_date" : self.parse_datetime(extr( "Member Since:", "<").lstrip(), "%B %Y"), "owner_website": extr("Website: Country:', '"'), ">", "<").capitalize(), } if additional := work.pop("additional", None): additional = additional.split('