diff options
author | Wolfgang Müller | 2024-11-14 16:49:53 +0100 |
---|---|---|
committer | Wolfgang Müller | 2024-11-14 20:44:52 +0100 |
commit | bddbb684fd8a5d6992f5b1fc809e1629ccb841c1 (patch) | |
tree | 7bff666056003c485f96bee65cc5e83a113320da | |
parent | c212191bbf288b4362d0a64eae0df2afcb76d82c (diff) | |
download | hircine-bddbb684fd8a5d6992f5b1fc809e1629ccb841c1.tar.gz |
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
-rw-r--r-- | src/hircine/plugins/scrapers/anchira.py | 13 |
1 files changed, 2 insertions, 11 deletions
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) |