# -*- coding: utf-8 -*- # Copyright 2020 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 Moebooru based sites""" from .common import generate_extractors from .booru import BooruExtractor from .. import text import collections import datetime import re class MoebooruExtractor(BooruExtractor): """Base class for Moebooru extractors""" basecategory = "moebooru" filename_fmt = "{category}_{id}_{md5}.{extension}" page_start = 1 def _prepare_post(self, post, extended_tags=False): url = post["file_url"] if extended_tags: self._fetch_extended_tags(post) post["date"] = text.parse_timestamp(post["created_at"]) return url def _fetch_extended_tags(self, post): url = "{}/post/show/{}".format(self.root, post["id"]) page = self.request(url).text html = text.extract(page, '