summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hircine/plugins/scrapers/handlers/dynastyscans.py10
-rw-r--r--src/hircine/plugins/scrapers/handlers/e621.py6
-rw-r--r--src/hircine/plugins/scrapers/handlers/exhentai.py11
-rw-r--r--src/hircine/plugins/scrapers/handlers/mangadex.py10
4 files changed, 5 insertions, 32 deletions
diff --git a/src/hircine/plugins/scrapers/handlers/dynastyscans.py b/src/hircine/plugins/scrapers/handlers/dynastyscans.py
index ded015b..fd9bf42 100644
--- a/src/hircine/plugins/scrapers/handlers/dynastyscans.py
+++ b/src/hircine/plugins/scrapers/handlers/dynastyscans.py
@@ -1,5 +1,3 @@
-import hircine.enums as enums
-from hircine.scraper import ScrapeWarning
from hircine.scraper.types import (
Artist,
Circle,
@@ -16,7 +14,7 @@ class DynastyScansHandler:
def scrape(self, data):
parsers = {
"date": Date.from_iso,
- "lang": self.parse_language,
+ "lang": Language.from_iso_639_3,
"author": Artist,
"group": Circle,
}
@@ -33,9 +31,3 @@ class DynastyScansHandler:
title = title + f": {subtitle}"
yield Title(title)
-
- def parse_language(self, input):
- try:
- return Language(value=enums.Language[input.upper()])
- except (KeyError, ValueError) as e:
- raise ScrapeWarning(f"Could not parse language: '{input}'") from e
diff --git a/src/hircine/plugins/scrapers/handlers/e621.py b/src/hircine/plugins/scrapers/handlers/e621.py
index 6b798fd..b7cd83a 100644
--- a/src/hircine/plugins/scrapers/handlers/e621.py
+++ b/src/hircine/plugins/scrapers/handlers/e621.py
@@ -1,5 +1,4 @@
import hircine.enums as enums
-from hircine.scraper import ScrapeWarning
from hircine.scraper.types import (
URL,
Artist,
@@ -75,7 +74,4 @@ class E621Handler:
if input.endswith("_text"):
lang, _ = input.split("_text", 1)
- try:
- return Language(value=enums.Language(lang.capitalize()))
- except ValueError as e:
- raise ScrapeWarning(f"Could not parse language: '{input}'") from e
+ return Language.from_name(lang)
diff --git a/src/hircine/plugins/scrapers/handlers/exhentai.py b/src/hircine/plugins/scrapers/handlers/exhentai.py
index 12c22d7..33733be 100644
--- a/src/hircine/plugins/scrapers/handlers/exhentai.py
+++ b/src/hircine/plugins/scrapers/handlers/exhentai.py
@@ -1,7 +1,6 @@
import re
import hircine.enums as enums
-from hircine.scraper import ScrapeWarning
from hircine.scraper.types import (
URL,
Artist,
@@ -39,7 +38,7 @@ class ExHentaiHandler:
category_field: self.parse_category,
"posted": Date.from_timestamp,
"date": Date.from_iso,
- "lang": self.parse_language,
+ "lang": Language.from_iso_639_3,
"tags": self.parse_tag,
"title": lambda t: Title(sanitize(t, split=True)),
"title_jpn": lambda t: OriginalTitle(sanitize(t)),
@@ -130,10 +129,4 @@ class ExHentaiHandler:
if not input or input in ["translated", "speechless", "N/A"]:
return
- try:
- if from_value:
- return Language(value=enums.Language(input.capitalize()))
- else:
- return Language(value=enums.Language[input.upper()])
- except (KeyError, ValueError) as e:
- raise ScrapeWarning(f"Could not parse language: '{input}'") from e
+ return Language.from_name(input)
diff --git a/src/hircine/plugins/scrapers/handlers/mangadex.py b/src/hircine/plugins/scrapers/handlers/mangadex.py
index bb93538..4a8d5fd 100644
--- a/src/hircine/plugins/scrapers/handlers/mangadex.py
+++ b/src/hircine/plugins/scrapers/handlers/mangadex.py
@@ -1,5 +1,3 @@
-import hircine.enums as enums
-from hircine.scraper import ScrapeWarning
from hircine.scraper.types import (
URL,
Artist,
@@ -18,7 +16,7 @@ class MangadexHandler:
def scrape(self, data):
parsers = {
"date": Date.from_iso,
- "lang": self.parse_language,
+ "lang": Language.from_iso_639_3,
"tags": Tag.from_string,
"artist": Artist,
"author": Artist,
@@ -46,9 +44,3 @@ class MangadexHandler:
title = title + f": {subtitle}"
yield Title(title)
-
- def parse_language(self, input):
- try:
- return Language(value=enums.Language[input.upper()])
- except (KeyError, ValueError) as e:
- raise ScrapeWarning(f"Could not parse language: '{input}'") from e