|
|
@ -1,7 +1,8 @@ |
|
|
|
import feedparser |
|
|
|
from simpledatabase import SimpleDatabase |
|
|
|
import json |
|
|
|
from datetime import date, timedelta |
|
|
|
from datetime import datetime, date, timedelta |
|
|
|
from backports.zoneinfo import ZoneInfo |
|
|
|
|
|
|
|
def update(): |
|
|
|
""" Update all feeds """ |
|
|
@ -14,6 +15,7 @@ def update(): |
|
|
|
|
|
|
|
for x, feed in enumerate(feeds): |
|
|
|
parsed = feedparser.parse(feed) |
|
|
|
# print(parsed) |
|
|
|
x = str(x) |
|
|
|
|
|
|
|
tmp['feeds'][x] = {} |
|
|
@ -26,7 +28,7 @@ def update(): |
|
|
|
year = post['published_parsed'][0] |
|
|
|
month = post['published_parsed'][1] |
|
|
|
day = post['published_parsed'][2] |
|
|
|
post_date = date(year, month, day) |
|
|
|
post_date = datetime(year, month, day, tzinfo=ZoneInfo("Europe/Amsterdam")) |
|
|
|
|
|
|
|
if not str(post_date) in tmp['all_posts_sorted']: |
|
|
|
tmp['all_posts_sorted'][str(post_date)] = [] |
|
|
@ -82,7 +84,7 @@ def today(): |
|
|
|
return request |
|
|
|
|
|
|
|
def past(days): |
|
|
|
""" Collect posts from this week """ |
|
|
|
""" Collect posts from a number of past <days> """ |
|
|
|
db = load() |
|
|
|
point_in_the_past = date.today() - timedelta(int(days)) |
|
|
|
request = [] |
|
|
|