mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
restructure info-parameters
This commit is contained in:
parent
205ef3ca02
commit
900577b013
@ -50,8 +50,8 @@ def find(url):
|
||||
for pattern, info, klass in _list_patterns():
|
||||
match = re.match(pattern, url)
|
||||
if match:
|
||||
return klass(match), info
|
||||
return None, None
|
||||
return klass(match)
|
||||
return None
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# internals
|
||||
@ -84,6 +84,6 @@ def _get_classes(module):
|
||||
"""Return a list of all extractor classes in a module"""
|
||||
return [
|
||||
klass for klass in module.__dict__.values() if (
|
||||
hasattr(klass, "info") and klass.__module__ == module.__name__
|
||||
hasattr(klass, "pattern") and klass.__module__ == module.__name__
|
||||
)
|
||||
]
|
||||
|
@ -14,19 +14,20 @@ from .extractor.common import Message
|
||||
class DownloadJob():
|
||||
|
||||
def __init__(self, url):
|
||||
self.extractor, self.info = extractor.find(url)
|
||||
# self.extractor, self.info = extractor.find(url)
|
||||
self.extractor = extractor.find(url)
|
||||
if self.extractor is None:
|
||||
print(url, ": No extractor found", sep="", file=sys.stderr)
|
||||
return
|
||||
self.directory = self.get_base_directory()
|
||||
self.downloaders = {}
|
||||
self.filename_fmt = config.get(
|
||||
("extractor", self.info["category"], "filename"),
|
||||
default=self.info["filename"]
|
||||
("extractor", self.extractor.category, "filename"),
|
||||
default=self.extractor.filename_fmt
|
||||
)
|
||||
segments = config.get(
|
||||
("extractor", self.info["category"], "directory"),
|
||||
default=self.info["directory"]
|
||||
("extractor", self.extractor.category, "directory"),
|
||||
default=self.extractor.directory_fmt
|
||||
)
|
||||
self.directory_fmt = os.path.join(*segments)
|
||||
|
||||
@ -51,7 +52,7 @@ class DownloadJob():
|
||||
elif msg[0] == Message.Version:
|
||||
if msg[1] != 1:
|
||||
raise "unsupported message-version ({}, {})".format(
|
||||
self.info.category, msg[1]
|
||||
self.extractor.category, msg[1]
|
||||
)
|
||||
# TODO: support for multiple message versions
|
||||
|
||||
@ -118,7 +119,8 @@ class DownloadJob():
|
||||
class KeywordJob():
|
||||
|
||||
def __init__(self, url):
|
||||
self.extractor, self.info = extractor.find(url)
|
||||
# self.extractor, self.info = extractor.find(url)
|
||||
self.extractor = extractor.find(url)
|
||||
if self.extractor is None:
|
||||
print(url, ": No extractor found", sep="", file=sys.stderr)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user