Skip to content

Capture username in Medium RSS schema - #243

Merged
soxoj merged 2 commits into
soxoj:masterfrom
razbenya:fix/medium-rss-username
May 14, 2026
Merged

Capture username in Medium RSS schema#243
soxoj merged 2 commits into
soxoj:masterfrom
razbenya:fix/medium-rss-username

Conversation

@razbenya

Copy link
Copy Markdown
Contributor

Summary

The Medium RSS schema currently captures fullname, image, and latest_activity_at, but leaves username empty. The username is sitting right in the channel's <link> element — adding a named-capture group for it.

Reproducer (before)

python3 -c "
from socid_extractor import extract
import urllib.request, ssl
ctx = ssl.create_default_context(); ctx.check_hostname = False; ctx.verify_mode = ssl.CERT_NONE
req = urllib.request.Request('https://medium.com/feed/@blue', headers={'User-Agent': 'Mozilla/5.0'})
body = urllib.request.urlopen(req, context=ctx).read().decode()
print(extract(body))
"
# -> {'fullname': 'Medium Staff', 'image': '...', 'latest_activity_at': '...'}  (no username)

After this patch, the same call also returns 'username': 'blue'.

Why this matters

Useful for --parse flows against a Medium URL where the username has to be discovered from the page content rather than supplied as input. The older Medium HTML schema (still present in the file, for completeness) already exposed medium_username — this restores parity for the RSS path.

Test

import re
body = open('medium_feed.xml').read()  # any user's RSS feed
m = re.search(<new regex>, body, re.MULTILINE)
assert m.groupdict() == {'fullname': '…', 'username': '…', 'image': 'https://…', 'latest_activity_at': '…'}

The Medium RSS schema captures fullname and image but the username field
is left empty. Adding a named-capture group for it from the <channel>'s
<link>https://medium.com/@USERNAME</link> element so the schema produces
the same fields the older Medium HTML schema did via medium_username.

Useful for --parse runs against a Medium URL, where the username has to
be discovered from the page content rather than supplied as input.
@soxoj

soxoj commented May 13, 2026

Copy link
Copy Markdown
Owner

Thanks 👍

@soxoj
soxoj merged commit baf32b8 into soxoj:master May 14, 2026
5 checks passed
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.

2 participants