mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
add KeywordJob class
This commit is contained in:
parent
db113bd87d
commit
edf3f7b69f
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user