set 'extension' keyword whenever possible

This commit is contained in:
Mike Fährmann
2016-10-07 15:11:58 +02:00
parent be73af551e
commit f7c993d952
4 changed files with 12 additions and 6 deletions

View File

@@ -36,13 +36,18 @@ class ChanThreadExtractor(Extractor):
for post in posts:
if "filename" not in post:
continue
post.update(self.metadata)
self.update(post)
yield Message.Url, self.file_url.format_map(post), post
if "extra_files" in post:
for file in post["extra_files"]:
post.update(file)
self.update(post, file)
yield Message.Url, self.file_url.format_map(post), post
def update(self, post, data=None):
"""Update keyword dictionary"""
post.update(data or self.metadata)
post["extension"] = post["ext"][1:]
@staticmethod
def get_thread_title(post):
"""Return thread title from first post"""