forked from indymedia/epicyon
Handle different rss date formats
parent
e6b66d5cb5
commit
e0162738d4
11
session.py
11
session.py
|
@ -119,12 +119,23 @@ def xml2StrToDict(xmlStr: str) -> {}:
|
||||||
link = link.split('</link>')[0]
|
link = link.split('</link>')[0]
|
||||||
pubDate = rssItem.split('<pubDate>')[1]
|
pubDate = rssItem.split('<pubDate>')[1]
|
||||||
pubDate = pubDate.split('</pubDate>')[0]
|
pubDate = pubDate.split('</pubDate>')[0]
|
||||||
|
parsed = False
|
||||||
try:
|
try:
|
||||||
publishedDate = \
|
publishedDate = \
|
||||||
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S %z")
|
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S %z")
|
||||||
result[str(publishedDate)] = [title, link]
|
result[str(publishedDate)] = [title, link]
|
||||||
|
parsed = True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
if not parsed:
|
||||||
|
try:
|
||||||
|
publishedDate = \
|
||||||
|
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S UT")
|
||||||
|
result[str(publishedDate)] = [title, link]
|
||||||
|
parsed = True
|
||||||
|
except BaseException:
|
||||||
|
print('WARN: unrecognized RSS date format: ' + pubDate)
|
||||||
|
pass
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue