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