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

add KeywordJob class

This commit is contained in:
Mike Fährmann 2015-11-13 01:02:49 +01:00
parent db113bd87d
commit edf3f7b69f
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -113,3 +113,32 @@ class DownloadJob():
if tries == 0:
print("\r", end="")
print("\r\033[1;32m", path, "\033[0m", sep="")
class KeywordJob():
def __init__(self, url):
self.extractor, self.info = extractor.find(url)
if self.extractor is None:
print(url, ": No extractor found", sep="", file=sys.stderr)
return
def run(self):
"""Execute/Run the download job"""
if self.extractor is None:
return
for msg in self.extractor:
if msg[0] == Message.Url:
print("Keywords for filenames:")
self.print_keywords(msg[2])
return
elif msg[0] == Message.Directory:
print("Keywords for directory names:")
self.print_keywords(msg[1])
@staticmethod
def print_keywords(keywords):
offset = max(map(len, keywords.keys())) + 1
for key, value in sorted(keywords.items()):
print(key, ":", " "*(offset-len(key)), value, sep="")
print()