Skip to content

fix(news): derive titles from URL slug for MSN/aggregator articles#61

Merged
nullhack merged 1 commit into
mainfrom
fix/msn-news-titles
Jul 24, 2026
Merged

fix(news): derive titles from URL slug for MSN/aggregator articles#61
nullhack merged 1 commit into
mainfrom
fix/msn-news-titles

Conversation

@nullhack

Copy link
Copy Markdown
Owner

Problem

155 of ~1700 stored news items have title: MSN — the single most common title. MSN.com is a JS SPA whose server-side <title> tag is literally "MSN". Both DDG and trafilatura return this generic site name instead of the actual headline. Also 3 items have title: Client Challenge (Cloudflare bot-detection pages overwriting good DDG titles during enrichment).

Root cause

Neither a capture failure nor a wrong-field issue — the headline exists only in the URL slug (e.g. .../venezuela-quakes-caused-196-billion-in-damage/...), never in any title metadata field.

Fix

  1. ddg_news.py: derive_title_from_slug(url) extracts the headline slug from MSN-style URLs (/slug/ar-XXX or /slug/vi-XXX) and converts to title case. is_generic_title(title) detects known bad titles (MSN, Client Challenge, etc.).
  2. pipeline.py:_enrich_one: rewritten title resolution — prefers good fetched title, rejects generic fetched titles (won't overwrite a good DDG title with 'Client Challenge'), derives from slug when both DDG and fetched titles are generic.
  3. backfill_news_titles.py: one-shot backfill script for the 156 existing MSN-titled YAML files.

Samples (before → after)

Before After
MSN Venezuela Quakes Caused 196 Billion In Damage World Bank Report Shows
MSN Kanlaon Volcano Erupts In Philippines Sending Ash 9840 Feet Into The Sky
MSN Death Toll From Venezuela Twin Earthquakes Rises To 5069
MSN Ebola Response Worker Who Traveled From Drc To France Is First In Outbreak To Test Positive Outside Of Africa

Known imperfections: decimals flatten (7.3→73), currency drops ($5M→5m), proper nouns lose casing (DRC→Drc). Still far more informative than 'MSN'.

Tests

7 new tests (3 derive_title_from_slug + 4 is_generic_title). All gates green: ruff, pyright, mypy.stubtest, full suite.

MSN.com pages are JS SPAs whose server-side HTML <title> is literally 'MSN'.
Both DDG and trafilatura return 'MSN' as the title for all msn.com articles.

Changes:
- ddg_news.py: add derive_title_from_slug() + is_generic_title() helpers
- pipeline.py: _enrich_one now guards against generic fetched titles
  (Client Challenge, MSN, etc.) — won't overwrite a good DDG title with a
  bad fetched one, and derives from URL slug when both are generic
- backfill_news_titles.py: one-shot script to fix 156 existing MSN titles

The URL slug is the only source of the real headline for MSN articles
(e.g. 'venezuela-quakes-caused-196-billion' -> 'Venezuela Quakes Caused
196 Billion'). Imperfect formatting but far more informative than 'MSN'.
@nullhack
nullhack merged commit acf1310 into main Jul 24, 2026
1 check passed
@nullhack
nullhack deleted the fix/msn-news-titles branch July 24, 2026 08:15
nullhack added a commit that referenced this pull request Jul 24, 2026
Dashboard data regenerated with fixed news titles. 156 MSN-titled
articles now show headline derived from URL slug instead of 'MSN'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant