1
0
Fork 0

Dvach's stickers handling.

This commit is contained in:
Alexander Andreev 2021-04-28 02:48:36 +04:00
parent 6022c9929a
commit 93e442939a
Signed by: Arav
GPG Key ID: 610DF2574456329F
1 changed files with 13 additions and 7 deletions

View File

@ -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