sitemap based feed.

This commit is contained in:
Jason Schwarzenberger
2020-11-03 16:00:03 +13:00
parent de80389ed0
commit 76f1d57702
3 changed files with 120 additions and 1 deletions
+9 -1
View File
@@ -7,7 +7,7 @@ import requests
import time
from bs4 import BeautifulSoup
from feeds import hackernews, reddit, tildes, substack, manual
from feeds import hackernews, reddit, tildes, substack, manual, sitemap
OUTLINE_API = 'https://api.outline.com/v3/parse_article'
READ_API = 'http://127.0.0.1:33843'
@@ -17,11 +17,15 @@ TWO_DAYS = 60*60*24*2
webworm = substack.Publication("https://www.webworm.co")
bulletin = substack.Publication("https://thespinoff.substack.com")
stuff = sitemap.Sitemap("https://www.stuff.co.nz/sitemap.xml")
nzherald = sitemap.Sitemap("https://www.nzherald.co.nz/arcio/news-sitemap/")
def list():
feed = []
feed += [(x, 'hackernews') for x in hackernews.feed()[:10]]
feed += [(x, 'tildes') for x in tildes.feed()[:10]]
feed += [(x, 'stuff') for x in stuff.feed()[:10]]
feed += [(x, 'nzherald') for x in nzherald.feed()[:10]]
feed += [(x, 'substack') for x in substack.top.feed()[:15]]
feed += [(x, 'reddit') for x in reddit.feed()[:15]]
feed += [(x, 'webworm') for x in webworm.feed()[:15]]
@@ -89,6 +93,10 @@ def update_story(story, is_manual=False):
res = bulletin.story(story['ref'])
elif story['source'] == 'substack':
res = substack.top.story(story['ref'])
elif story['source'] == 'stuff':
res = stuff.story(story['ref'])
elif story['source'] == 'nzherald':
res = nzherald.story(story['ref'])
elif story['source'] == 'manual':
res = manual.story(story['ref'])