Skip to content

Resolve Reddit share links (/r/<sub>/s/<token>) #9

Description

@soxoj

Users report that Reddit share links of the form https://www.reddit.com/r/<subreddit>/s/<token> are not handled.

These 302-redirect to the canonical post. Follow the redirect, then read the resolved post's comments.json to get the author.

Extracts: post author username, subreddit, canonical post URL, post title.

Where the code goes

  • New module sharetrace/modules/reddit.py — one function, returns {"data": {...}} or {"error": "..."}.
  • Register it in router.py: URL pattern plus an entry in PARSERS.
  • Add output labels in output.py.
  • Unit test in tests/test_unit_modules.py — copy the shape of TestTelegram. Mock both the redirect and the JSON response.
  • Add a row to the supported-sources table in README.md.

How you verify it — no credentials, no network

pytest tests/ --ignore=tests/test_integration.py

Unit tests mock requests at the module level, so this runs fully offline. tests/test_integration.py hits the live network and is excluded on purpose.

Note: this repository has no CI. Run that command yourself before opening the PR — nothing will run it for you.

Done when

A share link resolves to its canonical post and returns the author; the unit test covers both the redirect and the JSON parsing; README row added.

Out of scope

Comment authors, user profiles, anything needing Reddit API credentials.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions