Fix dashboard news feed

This commit is contained in:
Arnaud Vergnet 2020-08-08 15:34:44 +02:00
parent 5eb7bcf7b4
commit 77c4bb01d8
2 changed files with 4 additions and 9 deletions

View file

@ -30,12 +30,7 @@ def get_news_feed():
print("Waiting for Facebook lock")
try:
with open(FACEBOOK_FILE) as f:
data = json.load(f)
if 'data' in data and len(data['data']) > 15:
del data['data'][14:]
else:
data = {'data': []}
return data
return json.load(f)
except FileNotFoundError:
print("Could not find " + FACEBOOK_FILE)
return {'data': []}

View file

@ -9,9 +9,9 @@ def scrape_data():
for post in facebook_scraper.get_posts('amicale.deseleves', pages=3):
print(post)
cleaned_post = {
"post_id": post["post_id"],
"post_text": post["post_text"],
"post_url": post["post_url"],
"id": post["post_id"],
"message": post["post_text"],
"url": post["post_url"],
"image": post["image"],
"video": post["video"],
"link": post["link"],