forked from indymedia/epicyon
Change newswire link to local if post exists locally
parent
b353caceb8
commit
f9517367bb
|
@ -49,28 +49,44 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
nickname = 'feeds'
|
nickname = 'feeds'
|
||||||
|
|
||||||
for dateStr, item in newswire.items():
|
for dateStr, item in newswire.items():
|
||||||
|
# convert the date to the format used by ActivityPub
|
||||||
dateStr = dateStr.replace(' ', 'T')
|
dateStr = dateStr.replace(' ', 'T')
|
||||||
dateStr = dateStr.replace('+00:00', 'Z')
|
dateStr = dateStr.replace('+00:00', 'Z')
|
||||||
|
|
||||||
|
# file where the post is stored
|
||||||
filename = basePath + '/' + dateStr + '.json'
|
filename = basePath + '/' + dateStr + '.json'
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
|
# if a local post exists as html then change the link
|
||||||
|
# to the local one
|
||||||
|
htmlFilename = basePath + '/' + dateStr + '.html'
|
||||||
|
if os.path.isfile(htmlFilename):
|
||||||
|
item[1] = '/feeds/' + dateStr + '.html'
|
||||||
|
# don't create the post if it already exists
|
||||||
continue
|
continue
|
||||||
|
|
||||||
rssTitle = item[0]
|
rssTitle = item[0]
|
||||||
url = item[1]
|
url = item[1]
|
||||||
rssDescription = ''
|
rssDescription = ''
|
||||||
|
|
||||||
|
# get the rss description if it exists
|
||||||
if len(item) >= 5:
|
if len(item) >= 5:
|
||||||
rssDescription = item[4]
|
rssDescription = item[4]
|
||||||
|
|
||||||
|
# add the off-site link to the description
|
||||||
if rssDescription:
|
if rssDescription:
|
||||||
rssDescription += \
|
rssDescription += \
|
||||||
'\n\n' + translate['Read more...'] + '\n' + url
|
'\n\n' + translate['Read more...'] + '\n' + url
|
||||||
else:
|
else:
|
||||||
rssDescription = url
|
rssDescription = url
|
||||||
|
|
||||||
|
# create the activitypub post
|
||||||
blog = createNewsPost(baseDir,
|
blog = createNewsPost(baseDir,
|
||||||
nickname, domain, port,
|
nickname, domain, port,
|
||||||
httpPrefix, dateStr,
|
httpPrefix, dateStr,
|
||||||
rssTitle, rssDescription,
|
rssTitle, rssDescription,
|
||||||
None, None, None, False)
|
None, None, None, False)
|
||||||
|
|
||||||
|
# save the post and update the index
|
||||||
if saveJson(blog, filename):
|
if saveJson(blog, filename):
|
||||||
updateFeedsIndex(baseDir, filename)
|
updateFeedsIndex(baseDir, filename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue