From 93e442939a5709cd41824f75c03f526d035218fe Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Wed, 28 Apr 2021 02:48:36 +0400 Subject: [PATCH] Dvach's stickers handling. --- scrapthechan/parsers/dvach.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scrapthechan/parsers/dvach.py b/scrapthechan/parsers/dvach.py index f9f7076..85e30a6 100644 --- a/scrapthechan/parsers/dvach.py +++ b/scrapthechan/parsers/dvach.py @@ -36,15 +36,21 @@ class DvachParser(Parser): if not 'files' in post: return None files = [] for f in post['files']: - if 'sticker' in f: - continue - if match(r"^image\.\w+$", f['fullname']) is None: - fullname = f['fullname'] + if not 'sticker' in f: + if match(r"^image\.\w+$", f['fullname']) is None: + fullname = f['fullname'] + else: + fullname = f['name'] else: fullname = f['name'] # Here's same thing as 4chan. 2ch.hk also has md5 field, so it is # completely fine to hardcode `hash_algo`. - files.append(FileInfo(fullname, f['size'], - f"{self.__url_file_link}{f['path']}", - f['md5'], 'md5')) + if 'md5' in f: + files.append(FileInfo(fullname, f['size'], + f"{self.__url_file_link}{f['path']}", + f['md5'], 'md5')) + else: + files.append(FileInfo(fullname, f['size'], + f"{self.__url_file_link}{f['path']}", + None, None)) return files