mirror of https://gitlab.com/bashrc2/epicyon
Rss version
parent
ec87fbf4f8
commit
f94f242d38
11
newswire.py
11
newswire.py
|
@ -328,7 +328,7 @@ def xml2StrToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
if postCtr > 0:
|
if postCtr > 0:
|
||||||
print('Added ' + str(postCtr) + ' rss feed items to newswire')
|
print('Added ' + str(postCtr) + ' rss 2.0 feed items to newswire')
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -340,7 +340,8 @@ def xml1StrToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
"""Converts an xml RSS 1.0 string to a dictionary
|
"""Converts an xml RSS 1.0 string to a dictionary
|
||||||
https://validator.w3.org/feed/docs/rss1.html
|
https://validator.w3.org/feed/docs/rss1.html
|
||||||
"""
|
"""
|
||||||
if '<item' not in xmlStr:
|
itemStr = '<item'
|
||||||
|
if itemStr not in xmlStr:
|
||||||
return {}
|
return {}
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
@ -350,14 +351,16 @@ def xml1StrToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
maxCategoriesFeedItemSizeKb)
|
maxCategoriesFeedItemSizeKb)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
rssItems = xmlStr.split('<item')
|
rssItems = xmlStr.split(itemStr)
|
||||||
postCtr = 0
|
postCtr = 0
|
||||||
maxBytes = maxFeedItemSizeKb * 1024
|
maxBytes = maxFeedItemSizeKb * 1024
|
||||||
for rssItem in rssItems:
|
for rssItem in rssItems:
|
||||||
if not rssItem:
|
if not rssItem:
|
||||||
continue
|
continue
|
||||||
if len(rssItem) > maxBytes:
|
if len(rssItem) > maxBytes:
|
||||||
print('WARN: rss feed item is too big')
|
print('WARN: rss 1.0 feed item is too big')
|
||||||
|
continue
|
||||||
|
if rssItem.startswith('s>'):
|
||||||
continue
|
continue
|
||||||
if '<title>' not in rssItem:
|
if '<title>' not in rssItem:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue