Improve post checking when constructing timelines

master
Bob Mottram 2019-08-25 18:12:48 +01:00
parent f35d589f1c
commit 2236306f11
1 changed files with 25 additions and 13 deletions

View File

@ -1735,10 +1735,21 @@ def createBoxBase(baseDir: str,boxname: str, \
filePath = postFilename filePath = postFilename
try: try:
if os.path.isfile(filePath): if os.path.isfile(filePath):
if currPage == pageNumber and postsOnPageCtr <= itemsPerPage: # is this a valid timeline post?
# get the post as json isPost=False
with open(filePath, 'r') as fp: # must be a "Note" or "Announce" type
p=commentjson.load(fp) with open(filePath, 'r') as file:
postStr = file.read()
if '"Note"' in postStr or '"Announce"' in postStr:
isPost=True
if boxname=='dm':
if '#Public' in postStr or '/followers' in postStr:
isPost=False
if isPost:
if currPage == pageNumber and postsOnPageCtr <= itemsPerPage:
# get the post as json
p = json.loads(postStr)
if boxname!='dm' or \ if boxname!='dm' or \
(boxname=='dm' and isDM(p)): (boxname=='dm' and isDM(p)):
@ -1766,15 +1777,16 @@ def createBoxBase(baseDir: str,boxname: str, \
httpPrefix+'://'+domain+'/users/'+ \ httpPrefix+'://'+domain+'/users/'+ \
nickname+'/'+boxname+'?max_id='+ \ nickname+'/'+boxname+'?max_id='+ \
postId+'&page=true' postId+'&page=true'
# remember the last post filename for use with prev
prevPostFilename = postFilename # remember the last post filename for use with prev
if postsOnPageCtr >= itemsPerPage: prevPostFilename = postFilename
break if postsOnPageCtr >= itemsPerPage:
# count the pages break
postsCtr += 1 # count the pages
if postsCtr >= itemsPerPage: postsCtr += 1
postsCtr = 0 if postsCtr >= itemsPerPage:
currPage += 1 postsCtr = 0
currPage += 1
except Exception as e: except Exception as e:
print(e) print(e)
if headerOnly: if headerOnly: