# -*- coding: utf-8 -*- # Copyright 2014-2021 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.imagebam.com/""" from .common import Extractor, Message from .. import text, exception class ImagebamExtractor(Extractor): """Base class for imagebam extractors""" category = "imagebam" root = "https://www.imagebam.com" cookies = None def __init__(self, match): Extractor.__init__(self, match) self.key = match.group(1) if self.cookies: self.session.cookies = self.cookies def get_image_data(self, data): page_url = "{}/image/{}".format(self.root, data["image_key"]) page = self.request(page_url).text image_url, pos = text.extract(page, '', '<')[0] return {"title": text.unescape(title.strip())} def get_image_keys(self, page): """Return a list of all image keys""" keys = [] while True: keys.extend(text.extract_iter( page, '