import json from hircine.scraper import Scraper from hircine.scraper.types import Artist, Character, Tag, Title from hircine.scraper.utils import open_archive_file, parse_dict class MyScraper(Scraper): name = "Example scraper" source = "example" def __init__(self, comic): super().__init__(comic) self.data = self.load() if self.data: self.is_available = True def load(self): try: with open_archive_file(self.comic.archive, "metadata.json") as jif: return json.load(jif) except Exception: return {} def scrape(self): parsers = { "title": Title, "tags": { "artists": Artist, "misc": Tag.from_string, "characters": Character, }, } yield from parse_dict(parsers, self.data)