Fixes a traceback when adding an unsupported post to db. Closes #15

This commit is contained in:
Manuel Cortez 2018-12-31 11:50:11 -06:00
parent a51a1458be
commit a531e8ee19

View File

@ -20,7 +20,7 @@ sessions = {}
identifiers = ["aid", "gid", "uid", "pid", "id", "post_id", "nid", "date"] identifiers = ["aid", "gid", "uid", "pid", "id", "post_id", "nid", "date"]
# Different VK post types, present in the newsfeed buffer. This is useful for filtering by post and remove deleted posts. # Different VK post types, present in the newsfeed buffer. This is useful for filtering by post and remove deleted posts.
post_types = dict(audio="audio", friend="friends", video="video", post="post_type") post_types = dict(audio="audio", friend="friends", video="video", post="post_type", audio_playlist="audio_playlist")
def find_item(list, item): def find_item(list, item):
""" Find an item in a list by taking an identifier. """ Find an item in a list by taking an identifier.
@ -65,9 +65,9 @@ class vkSession(object):
# Example of this behaviour is when you upload an audio and inmediately delete the audio, VK still sends the post stating that you uploaded an audio file, # Example of this behaviour is when you upload an audio and inmediately delete the audio, VK still sends the post stating that you uploaded an audio file,
# But without the audio data, making socializer to render an empty post. # But without the audio data, making socializer to render an empty post.
# Here we check if the post contains data of the type it advertises. # Here we check if the post contains data of the type it advertises.
if "type" in i and post_types[i["type"]] not in i: if i.get("type") != None and post_types.get(i["type"]) not in i:
log.error("Detected empty post. Skipping...") log.error("Detected invalid or unsupported post. Skipping...")
print i log.error(i)
continue continue
if find_item(self.db[name]["items"], i) == False: if find_item(self.db[name]["items"], i) == False:
# if i not in self.db[name]["items"]: # if i not in self.db[name]["items"]: