settings config of sitemap/substack publications.

master
Jason Schwarzenberger 4 years ago
parent 5f98a2e76a
commit 244d416f6e
  1. 37
      apiserver/feed.py
  2. 14
      apiserver/settings.py.example

@ -16,10 +16,12 @@ READ_API = 'http://127.0.0.1:33843'
INVALID_DOMAINS = ['youtube.com', 'bloomberg.com', 'wsj.com'] INVALID_DOMAINS = ['youtube.com', 'bloomberg.com', 'wsj.com']
TWO_DAYS = 60*60*24*2 TWO_DAYS = 60*60*24*2
webworm = substack.Publication("https://www.webworm.co") substacks = {}
bulletin = substack.Publication("https://thespinoff.substack.com") for key, value in settings.SUBSTACK.values():
stuff = sitemap.Sitemap("https://www.stuff.co.nz/sitemap.xml") substacks[key] = substack.Publication(value['url'])
nzherald = sitemap.Sitemap("https://www.nzherald.co.nz/arcio/news-sitemap/") sitemaps = {}
for key, value in settings.SITEMAP.values():
sitemaps[key] = sitemap.Sitemap(value['url'])
def list(): def list():
feed = [] feed = []
@ -35,17 +37,14 @@ def list():
if settings.NUM_SUBSTACK: if settings.NUM_SUBSTACK:
feed += [(x, 'substack') for x in substack.top.feed()[:settings.NUM_SUBSTACK]] feed += [(x, 'substack') for x in substack.top.feed()[:settings.NUM_SUBSTACK]]
if settings.NUM_STUFF: for key, publication in substacks.values():
feed += [(x, 'stuff') for x in stuff.feed()[:settings.NUM_STUFF]] count = settings.SUBSTACK[key].count
feed += [(x, key) for x in publication.feed()[:count]]
if settings.NUM_NZHERALD: for key, sites in sitemaps.values():
feed += [(x, 'nzherald') for x in nzherald.feed()[:settings.NUM_NZHERALD]] count = settings.SITEMAP[key].count
feed += [(x, key) for x in sites.feed()[:count]]
if settings.NUM_WEBWORM:
feed += [(x, 'webworm') for x in webworm.feed()[:settings.NUM_WEBWORM]]
if settings.NUM_BULLETIN:
feed += [(x, 'the bulletin') for x in bulletin.feed()[:settings.NUM_BULLETIN]]
return feed return feed
@ -104,16 +103,12 @@ def update_story(story, is_manual=False):
res = reddit.story(story['ref']) res = reddit.story(story['ref'])
elif story['source'] == 'tildes': elif story['source'] == 'tildes':
res = tildes.story(story['ref']) res = tildes.story(story['ref'])
elif story['source'] == 'webworm':
res = webworm.story(story['ref'])
elif story['source'] == 'the bulletin':
res = bulletin.story(story['ref'])
elif story['source'] == 'substack': elif story['source'] == 'substack':
res = substack.top.story(story['ref']) res = substack.top.story(story['ref'])
elif story['source'] == 'stuff': elif story['source'] in sitemaps.keys():
res = stuff.story(story['ref']) res = sitemaps[story['source']].story(story['ref'])
elif story['source'] == 'nzherald': elif story['source'] in substacks.keys():
res = nzherald.story(story['ref']) res = substacks[story['source']].story(story['ref'])
elif story['source'] == 'manual': elif story['source'] == 'manual':
res = manual.story(story['ref']) res = manual.story(story['ref'])

@ -8,10 +8,16 @@ NUM_HACKERNEWS = 15
NUM_REDDIT = 10 NUM_REDDIT = 10
NUM_TILDES = 5 NUM_TILDES = 5
NUM_SUBSTACK = 10 NUM_SUBSTACK = 10
NUM_WEBWORM = 0
NUM_NZHERALD = 0 # SITEMAP = {
NUM_STUFF = 0 # 'nzherald': { 'url': "https://www.nzherald.co.nz/arcio/news-sitemap/", 'count': 10},
NUM_BULLETIN = 0 # 'stuff': { 'url': "https://www.stuff.co.nz/sitemap.xml", 'count': 10},
# }
# SUBSTACK = {
# 'webworm': { 'url': "https://www.webworm.co", 'count': 10},
# 'the bulletin': { 'url': "https://thespinoff.substack.com", 'count': 10},
# }
# Reddit account info # Reddit account info
# leave blank if not using Reddit # leave blank if not using Reddit

Loading…
Cancel
Save