Debian Codegraph @

recipes/briefing_service.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 __license__ = 'GPL v3'
4 __copyright__ = '2026, Jordan Shelley'
5
6 import json
7
8 from calibre.web.feeds.news import BasicNewsRecipe
9
10 BASE = 'https://briefing-service.wholemind.workers.dev/v1/briefings/'
11
12 SECTIONS = (
13 ('ai', 'AI Briefing'),
14 ('labs', 'Frontier Labs'),
15 ('finance', 'Markets'),
16 ('sports', 'US Sports'),
17 ('soccer', 'European Football'),
18 ('us', 'US News'),
19 ('world', 'World News'),
20 )
21
22
23 class BriefingService(BasicNewsRecipe):
24 title = 'Briefing Service'
25 __author__ = 'Jordan Shelley'
26 description = 'Hourly LLM-ranked news briefings: AI, frontier labs, markets, US sports, European football, US and world news'
27 publisher = 'Briefing Service'
28 category = 'news, ai, finance, sports'
29 language = 'en'
30 publication_type = 'newspaper'
31 oldest_article = 1
32 max_articles_per_feed = 30
33 no_stylesheets = True
34 timefmt = ''
35 auto_cleanup = True
36 use_embedded_content = False
37 remove_empty_feeds = True
38 ignore_duplicate_articles = {'url'}
39 cover_url = BASE + 'ai/pages/0.png'
40
41 def parse_index(self):
42 feeds = []
43 for key, name in SECTIONS:
44 try:
45 raw = self.index_to_soup(BASE + key + '/summary', raw=True)
46 data = json.loads(raw)
47 except Exception as e:
48 self.log.warn('Failed to fetch section', name, ':', e)
49 continue
50 ranked_at = (data.get('ranked_at') or '')[:16].replace('T', ' ')
51 items = []
52 if data.get('lead'):
53 items.append(data['lead'])
54 items.extend(data.get('stories') or [])
55 items.extend(data.get('research') or [])
56 articles = []
57 for story in items:
58 url = story.get('link')
59 if not url:
60 continue
61 desc = story.get('summary') or ''
62 src = story.get('source')
63 if src:
64 desc = '{} [{}]'.format(desc, src).strip()
65 articles.append({
66 'title': story.get('headline') or url,
67 'url': url,
68 'date': story.get('published') or ranked_at,
69 'description': desc,
70 })
71 if articles:
72 title = data.get('name') or name
73 if ranked_at:
74 title = '{} ({} UTC)'.format(title, ranked_at)
75 feeds.append((title, articles))
76 return feeds