1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

store 'match' and 'groups' in Extractor objects

This commit is contained in:
Mike Fährmann 2024-03-31 23:25:05 +02:00
parent cf36c576d0
commit 0c17884673
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -45,6 +45,8 @@ class Extractor():
def __init__(self, match):
self.log = logging.getLogger(self.category)
self.url = match.string
self.match = match
self.groups = match.groups()
self._cfgpath = ("extractor", self.category, self.subcategory)
self._parentdir = ""
@ -599,7 +601,7 @@ class GalleryExtractor(Extractor):
def __init__(self, match, url=None):
Extractor.__init__(self, match)
self.gallery_url = self.root + match.group(1) if url is None else url
self.gallery_url = self.root + self.groups[0] if url is None else url
def items(self):
self.login()
@ -674,7 +676,7 @@ class MangaExtractor(Extractor):
def __init__(self, match, url=None):
Extractor.__init__(self, match)
self.manga_url = url or self.root + match.group(1)
self.manga_url = self.root + self.groups[0] if url is None else url
if self.config("chapter-reverse", False):
self.reverse = not self.reverse
@ -736,17 +738,17 @@ class BaseExtractor(Extractor):
instances = ()
def __init__(self, match):
if not self.category:
self._init_category(match)
Extractor.__init__(self, match)
if not self.category:
self._init_category()
def _init_category(self, match):
for index, group in enumerate(match.groups()):
def _init_category(self):
for index, group in enumerate(self.groups):
if group is not None:
if index:
self.category, self.root, info = self.instances[index-1]
if not self.root:
self.root = text.root_from_url(match.group(0))
self.root = text.root_from_url(self.match.group(0))
self.config_instance = info.get
else:
self.root = group