Fixed small error, so it won't finish with one or fewer notes or one and fewer reactions.

This commit is contained in:
Fotoente 2022-02-26 07:43:48 +01:00
parent f627a70b4d
commit 9402ce3c28

View file

@ -98,8 +98,11 @@ while True:
formerTimestamp = lastTimestamp formerTimestamp = lastTimestamp
lastTime = noteList[len(noteList) - 1]["createdAt"] if not len(noteList) <= 1: # If there is one or less notes, then break the while loop
lastTimestamp = int(datetime.timestamp(datetime.strptime(lastTime, '%Y-%m-%dT%H:%M:%S.%f%z')) * 1000) lastTime = noteList[len(noteList) - 1]["createdAt"]
lastTimestamp = int(datetime.timestamp(datetime.strptime(lastTime, '%Y-%m-%dT%H:%M:%S.%f%z')) * 1000)
else:
break
for element in noteList: for element in noteList:
if element["text"] is None: # Skip Notes without text if element["text"] is None: # Skip Notes without text
@ -116,7 +119,8 @@ for element in noteList:
if emojis is not None: if emojis is not None:
for emoji in emojis: for emoji in emojis:
if emoji["name"].find("@") == -1: # Only emojis from the own instance, because reactions will be in "emojis" if emoji["name"].find(
"@") == -1: # Only emojis from the own instance, because reactions will be in "emojis"
# too # too
if not emoji["name"] in doubleList: if not emoji["name"] in doubleList:
doubleList.append(emoji["name"]) # Easy way to prevent a double emoji in the list. doubleList.append(emoji["name"]) # Easy way to prevent a double emoji in the list.
@ -132,7 +136,7 @@ for element in noteList:
if element["cw"] is not None: if element["cw"] is not None:
emojiList[index]["count"] += element["cw"].count(emojiList[index]["emoji"]) # Count those Emojis, that emojiList[index]["count"] += element["cw"].count(emojiList[index]["emoji"]) # Count those Emojis, that
# are in this note CW text # are in this note CW text
# Process UTF8 Emojis # Process UTF8 Emojis
if element["cw"] is not None: if element["cw"] is not None:
UTF8text = element["text"] + " " + element["cw"] UTF8text = element["text"] + " " + element["cw"]
@ -181,9 +185,11 @@ if getReactions:
reactionList.append(jsonObj) reactionList.append(jsonObj)
formerTimestamp = lastTimestamp formerTimestamp = lastTimestamp
if not len(reactionList) <=1:
lastTime = reactionList[len(reactionList) - 1]["createdAt"] lastTime = reactionList[len(reactionList) - 1]["createdAt"]
lastTimestamp = int(datetime.timestamp(datetime.strptime(lastTime, '%Y-%m-%dT%H:%M:%S.%f%z')) * 1000) lastTimestamp = int(datetime.timestamp(datetime.strptime(lastTime, '%Y-%m-%dT%H:%M:%S.%f%z')) * 1000)
else:
break
react = "" react = ""
index = None index = None
@ -246,4 +252,4 @@ try:
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError as err: except requests.exceptions.HTTPError as err:
print("Couldn't create Posts! " + str(err)) print("Couldn't create Posts! " + str(err))
sys.exit(1) sys.exit(1)