add 'config_instance' method

to allow for a more streamlined access to BaseExtractor instance options
This commit is contained in:
Mike Fährmann
2024-01-18 03:20:36 +01:00
parent 34a7afdbc1
commit 89066844f4
8 changed files with 26 additions and 49 deletions

View File

@@ -15,7 +15,7 @@ class UrlshortenerExtractor(BaseExtractor):
basecategory = "urlshortener"
INSTANCES = {
BASE_PATTERN = UrlshortenerExtractor.update({
"bitly": {
"root": "https://bit.ly",
"pattern": r"bit\.ly",
@@ -26,9 +26,7 @@ INSTANCES = {
"root": "https://t.co",
"pattern": r"t\.co",
},
}
BASE_PATTERN = UrlshortenerExtractor.update(INSTANCES)
})
class UrlshortenerLinkExtractor(UrlshortenerExtractor):
@@ -42,10 +40,7 @@ class UrlshortenerLinkExtractor(UrlshortenerExtractor):
self.id = match.group(match.lastindex)
def _init(self):
try:
self.headers = INSTANCES[self.category]["headers"]
except Exception:
self.headers = None
self.headers = self.config_instance("headers")
def items(self):
response = self.request(