From 0b2a7c16762a60e5010bd2334144a69ec2651630 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 28 Sep 2019 13:27:48 +0100 Subject: [PATCH] Extra media check --- posts.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/posts.py b/posts.py index 37d52382..ef0419af 100644 --- a/posts.py +++ b/posts.py @@ -1704,12 +1704,9 @@ def isImageMedia(postJsonObject: {}) -> bool: return False if not isinstance(postJsonObject['object']['attachment'], list): return False - if len(postJsonObject['object']['attachment'])==0: - return False for attach in postJsonObject['object']['attachment']: if attach.get('mediaType') and attach.get('url'): - mediaType=attach['mediaType'] - if mediaType.startswith('image/'): + if attach['mediaType'].startswith('image/'): return True return False @@ -1742,7 +1739,7 @@ def createBoxBase(baseDir: str,boxname: str, \ if boxname!='dm' and boxname!='tlreplies' and boxname!='tlmedia': boxDir = createPersonDir(nickname,domain,baseDir,boxname) else: - # extract DMs or replies from the inbox + # extract DMs or replies or media from the inbox boxDir = createPersonDir(nickname,domain,baseDir,'inbox') sharedBoxDir=None if boxname=='inbox' or boxname=='tlreplies' or boxname=='tlmedia': @@ -1889,7 +1886,7 @@ def createBoxBase(baseDir: str,boxname: str, \ if boxActor not in postStr: isPost=False elif boxname=='tlmedia': - if 'image/' not in postStr: + if 'mediaType' not in postStr or 'image/' not in postStr: isPost=False if isPost: