From bddbb684fd8a5d6992f5b1fc809e1629ccb841c1 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Thu, 14 Nov 2024 16:49:53 +0100 Subject: backend/plugins: Have anchira scraper use parse_dict from scraper utils This cuts down on code duplication and also fixes B023 [1]. [1] https://docs.astral.sh/ruff/rules/function-uses-loop-variable/#function-uses-loop-variable-b023 --- src/hircine/plugins/scrapers/anchira.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/hircine/plugins/scrapers/anchira.py b/src/hircine/plugins/scrapers/anchira.py index aa224b9..baee4bd 100644 --- a/src/hircine/plugins/scrapers/anchira.py +++ b/src/hircine/plugins/scrapers/anchira.py @@ -17,7 +17,7 @@ from hircine.scraper.types import ( Title, World, ) -from hircine.scraper.utils import open_archive_file +from hircine.scraper.utils import open_archive_file, parse_dict URL_REGEX = re.compile(r"^https?://anchira\.to/g/") @@ -66,16 +66,7 @@ class AnchiraYamlScraper(Scraper): "Tags": self.parse_tag, } - for field, parser in parsers.items(): - if field not in self.data: - continue - - value = self.data[field] - - if isinstance(value, list): - yield from [lambda i=x: parser(i) for x in value] - else: - yield lambda: parser(value) + yield from parse_dict(parsers, self.data) yield Language(enums.Language.EN) yield Direction(enums.Direction.RIGHT_TO_LEFT) -- cgit v1.2.3-2-gb3c3