mirror of https://gitlab.com/bashrc2/epicyon
Function to get a list of rss feeds from file
parent
e0162738d4
commit
36893bb208
19
session.py
19
session.py
|
@ -13,6 +13,7 @@ import json
|
||||||
from socket import error as SocketError
|
from socket import error as SocketError
|
||||||
import errno
|
import errno
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
baseDirectory = None
|
baseDirectory = None
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ def xml2StrToDict(xmlStr: str) -> {}:
|
||||||
try:
|
try:
|
||||||
publishedDate = \
|
publishedDate = \
|
||||||
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S UT")
|
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S UT")
|
||||||
result[str(publishedDate)] = [title, link]
|
result[str(publishedDate) + '+00:00'] = [title, link]
|
||||||
parsed = True
|
parsed = True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: unrecognized RSS date format: ' + pubDate)
|
print('WARN: unrecognized RSS date format: ' + pubDate)
|
||||||
|
@ -188,6 +189,22 @@ def getRSS(session, url: str) -> {}:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def getRSSFromSubscriptions(session, subscriptionsFilename: str) -> {}:
|
||||||
|
"""Gets rss feeds as a dictionary from a list of feeds stored in a file
|
||||||
|
"""
|
||||||
|
if not os.path.isfile(subscriptionsFilename):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
rssFeed = []
|
||||||
|
with open(subscriptionsFilename, 'r') as fp:
|
||||||
|
rssFeed = fp.readlines()
|
||||||
|
result = {}
|
||||||
|
for url in rssFeed:
|
||||||
|
result = dict(result.items() + getRSS(session, url).items())
|
||||||
|
sortedResult = OrderedDict(sorted(result.items(), reverse=False))
|
||||||
|
return sortedResult
|
||||||
|
|
||||||
|
|
||||||
def postJson(session, postJsonObject: {}, federationList: [],
|
def postJson(session, postJsonObject: {}, federationList: [],
|
||||||
inboxUrl: str, headers: {}) -> str:
|
inboxUrl: str, headers: {}) -> str:
|
||||||
"""Post a json message to the inbox of another person
|
"""Post a json message to the inbox of another person
|
||||||
|
|
Loading…
Reference in New Issue