Record the time when rss posts arrived

main
Bob Mottram 2020-10-09 11:05:01 +01:00
parent b79ce4321f
commit 105daa49e8
1 changed files with 9 additions and 0 deletions

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os
import time
import datetime
from collections import OrderedDict
from newswire import getDictFromNewswire
from posts import createNewsPost
@ -53,6 +54,7 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str,
if not os.path.isdir(basePath):
os.mkdir(basePath)
# oldest items first
newswireReverse = \
OrderedDict(sorted(newswire.items(), reverse=False))
@ -62,6 +64,8 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str,
dateStr = dateStr.replace(' ', 'T')
dateStr = dateStr.replace('+00:00', 'Z')
# pubDate = datetime.strptime(dateStr, "%Y-%m-%dT%H:%M:%SZ")
statusNumber, published = getStatusNumber(dateStr)
newPostId = \
httpPrefix + '://' + domain + \
@ -107,6 +111,11 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str,
httpPrefix + '://' + domain + '/users/news' + \
'/statuses/' + statusNumber + '/replies'
blog['news'] = True
# note the time of arrival
currTime = datetime.datetime.utcnow()
blog['object']['arrived'] = currTime.strftime("%Y-%m-%dT%H:%M:%SZ")
blog['object']['replies']['id'] = idStr
blog['object']['replies']['first']['partOf'] = idStr