mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
add a few docstrings
This commit is contained in:
parent
30b9db43a0
commit
7c8d787077
@ -34,6 +34,7 @@ class DownloadManager():
|
|||||||
return module
|
return module
|
||||||
|
|
||||||
def get_base_directory(self):
|
def get_base_directory(self):
|
||||||
|
"""Return the base-destination-directory for downloads"""
|
||||||
if self.opts.dest:
|
if self.opts.dest:
|
||||||
return self.opts.dest
|
return self.opts.dest
|
||||||
else:
|
else:
|
||||||
@ -122,15 +123,18 @@ class DownloadJob():
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def print_start(path):
|
def print_start(path):
|
||||||
|
"""Print a message indicating the start of a download"""
|
||||||
print(path, end="")
|
print(path, end="")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def print_skip(path):
|
def print_skip(path):
|
||||||
|
"""Print a message indicating that a download has been skipped"""
|
||||||
print("\033[2m", path, "\033[0m", sep="")
|
print("\033[2m", path, "\033[0m", sep="")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def print_success(path, tries):
|
def print_success(path, tries):
|
||||||
|
"""Print a message indicating the completion of a download"""
|
||||||
if tries == 0:
|
if tries == 0:
|
||||||
print("\r", end="")
|
print("\r", end="")
|
||||||
print("\r\033[1;32m", path, "\033[0m", sep="")
|
print("\r\033[1;32m", path, "\033[0m", sep="")
|
||||||
@ -142,6 +146,7 @@ class ExtractorFinder():
|
|||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
def get_for_url(self, url):
|
def get_for_url(self, url):
|
||||||
|
"""Get an extractor-instance suitable for 'ur'"""
|
||||||
name, match = self.find_pattern_match(url)
|
name, match = self.find_pattern_match(url)
|
||||||
if match:
|
if match:
|
||||||
module = importlib.import_module(".extractor." + name, __package__)
|
module = importlib.import_module(".extractor." + name, __package__)
|
||||||
@ -152,6 +157,7 @@ class ExtractorFinder():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def find_pattern_match(self, url):
|
def find_pattern_match(self, url):
|
||||||
|
"""Find a pattern, that matches 'url', and return the (category,match) tuple"""
|
||||||
for category in self.config:
|
for category in self.config:
|
||||||
for key, value in self.config[category].items():
|
for key, value in self.config[category].items():
|
||||||
if key.startswith("regex"):
|
if key.startswith("regex"):
|
||||||
@ -159,15 +165,16 @@ class ExtractorFinder():
|
|||||||
match = re.match(value, url)
|
match = re.match(value, url)
|
||||||
if match:
|
if match:
|
||||||
return category, match
|
return category, match
|
||||||
for name, info in self.extractor_metadata():
|
for category, info in self.extractor_metadata():
|
||||||
for pattern in info["pattern"]:
|
for pattern in info["pattern"]:
|
||||||
print(pattern)
|
print(pattern)
|
||||||
match = re.match(pattern, url)
|
match = re.match(pattern, url)
|
||||||
if match:
|
if match:
|
||||||
return name, match
|
return category, match
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def extractor_metadata(self):
|
def extractor_metadata(self):
|
||||||
|
"""Yield all extractor-name, -metadata tuples"""
|
||||||
path = os.path.join(os.path.dirname(__file__), "extractor")
|
path = os.path.join(os.path.dirname(__file__), "extractor")
|
||||||
for name in os.listdir(path):
|
for name in os.listdir(path):
|
||||||
extractor_path = os.path.join(path, name)
|
extractor_path = os.path.join(path, name)
|
||||||
@ -177,6 +184,7 @@ class ExtractorFinder():
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_info_dict(extractor_path):
|
def get_info_dict(extractor_path):
|
||||||
|
"""Get info-/metadata-dictionary for an extractor"""
|
||||||
try:
|
try:
|
||||||
with open(extractor_path) as file:
|
with open(extractor_path) as file:
|
||||||
for _ in range(30):
|
for _ in range(30):
|
||||||
|
Loading…
Reference in New Issue
Block a user