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

restructure info-parameters

This commit is contained in:
Mike Fährmann 2015-11-21 00:30:31 +01:00
parent 205ef3ca02
commit 900577b013
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 12 additions and 10 deletions

View File

@ -50,8 +50,8 @@ def find(url):
for pattern, info, klass in _list_patterns(): for pattern, info, klass in _list_patterns():
match = re.match(pattern, url) match = re.match(pattern, url)
if match: if match:
return klass(match), info return klass(match)
return None, None return None
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# internals # internals
@ -84,6 +84,6 @@ def _get_classes(module):
"""Return a list of all extractor classes in a module""" """Return a list of all extractor classes in a module"""
return [ return [
klass for klass in module.__dict__.values() if ( klass for klass in module.__dict__.values() if (
hasattr(klass, "info") and klass.__module__ == module.__name__ hasattr(klass, "pattern") and klass.__module__ == module.__name__
) )
] ]

View File

@ -14,19 +14,20 @@ from .extractor.common import Message
class DownloadJob(): class DownloadJob():
def __init__(self, url): 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: if self.extractor is None:
print(url, ": No extractor found", sep="", file=sys.stderr) print(url, ": No extractor found", sep="", file=sys.stderr)
return return
self.directory = self.get_base_directory() self.directory = self.get_base_directory()
self.downloaders = {} self.downloaders = {}
self.filename_fmt = config.get( self.filename_fmt = config.get(
("extractor", self.info["category"], "filename"), ("extractor", self.extractor.category, "filename"),
default=self.info["filename"] default=self.extractor.filename_fmt
) )
segments = config.get( segments = config.get(
("extractor", self.info["category"], "directory"), ("extractor", self.extractor.category, "directory"),
default=self.info["directory"] default=self.extractor.directory_fmt
) )
self.directory_fmt = os.path.join(*segments) self.directory_fmt = os.path.join(*segments)
@ -51,7 +52,7 @@ class DownloadJob():
elif msg[0] == Message.Version: elif msg[0] == Message.Version:
if msg[1] != 1: if msg[1] != 1:
raise "unsupported message-version ({}, {})".format( raise "unsupported message-version ({}, {})".format(
self.info.category, msg[1] self.extractor.category, msg[1]
) )
# TODO: support for multiple message versions # TODO: support for multiple message versions
@ -118,7 +119,8 @@ class DownloadJob():
class KeywordJob(): class KeywordJob():
def __init__(self, url): 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: if self.extractor is None:
print(url, ": No extractor found", sep="", file=sys.stderr) print(url, ": No extractor found", sep="", file=sys.stderr)
return return