Skip to content

fix(sources): twitter/youtube connector follow-ups (session config, rate limits, docs) - #180

Merged
joshpanka merged 1 commit into
mainfrom
fix/twitter-connector-followups
Sep 1, 2026
Merged

fix(sources): twitter/youtube connector follow-ups (session config, rate limits, docs)#180
joshpanka merged 1 commit into
mainfrom
fix/twitter-connector-followups

Conversation

@joshpanka

Copy link
Copy Markdown
Contributor

Follow-ups on the X/Twitter and YouTube connectors after running both live, plus a shared cleanup. Split into reviewable commits.

Twitter

  • Settings-based session config, resolved per call. TWITTER_COOKIES_JSON / TWITTER_COOKIES_FILE were documented but never read from the env; all session config now flows through conf/settings (mirroring YOUTUBE_COOKIES_FILE) and resolves per search call, so a rotated cookie export applies on the next poll without a restart. TWITTER_CREDENTIALS_DIR now defaults to an absolute path instead of a CWD-relative one (which resolved differently under runserver vs gunicorn --chdir).
  • Skip timestamp-less tweets instead of minting now(). from_tweet stamped datetime.now() on a tweet with no created_at, which advances the source watermark past every older-but-new tweet and strands them. Such a tweet is malformed; the connector now skips just that one with a warning.
  • Honor X's rate-limit reset. Mirrors the Reddit connector's 429 loop: on a rate_limited error the client waits until X's window resets and retries, ticking the poll-lease heartbeat through the wait, rather than failing the source and burning a cycle. X sends x-rate-limit-reset as an absolute epoch (not Reddit's relative seconds), handled accordingly.
  • Pin twikit to the rev uv.lock already resolved (the fork's default branch floats and this code handles auth).

Shared

  • Promote sleep_with_heartbeat to base so the Reddit and Twitter backoff loops share one definition.

Docs

  • Per-connector credential directory (apps/core/credentials/<connector>/, gitignored) with a README covering how to generate the Twitter and YouTube cookie exports, and the ToS caveat.
  • README Connectors section replacing the fork's changelog-style "What we've done" (test counts, the Twenty socialEvent contract, per-branch framing) with a durable per-connector reference in the project's voice.

Both connectors verified live end to end (feed → watch → judge). Full core suite, ruff, and ty green.

Builds on the connector work from #175 (@matthewdonsemail-lab) and #177.

…ate limits, docs)

Follow-ups on the X/Twitter (#175) and YouTube (#177) connectors after running
both live, plus a shared cleanup.

Twitter:
- Session config (cookies/proxy/credentials dir) flows through Django settings
  (TWITTER_COOKIES_JSON / COOKIE_AUTH_TOKEN / COOKIE_CT0 / COOKIES_FILE /
  CREDENTIALS_DIR / PROXY), resolved per search call so a rotated cookie export
  applies without a restart; the documented-but-unwired JSON/file routes now
  work. CREDENTIALS_DIR defaults to an absolute path.
- Skip timestamp-less tweets instead of minting now() (which would poison the
  watermark and strand every older-but-new tweet).
- Honor X's rate-limit reset with an in-cycle retry loop (mirrors Reddit's 429
  loop; X's x-rate-limit-reset is an absolute epoch), ticking the poll-lease
  heartbeat through the wait.
- Watermark filter uses strict < not <= (same-second tweets were lost).
- Pin twikit to the locked rev.

Shared:
- Promote sleep_with_heartbeat and rate_limit_delay to connectors/base so
  Reddit and Twitter share one definition each.
- Rename ListenerError -> TwitterError (mirrors YouTubeError; drops the
  'Listener' name AGENTS.md reserves).

Docs/examples:
- Twitter starter (feed + watch); list twitter + youtube in the examples README.
- Per-connector credentials/ directory convention (gitignored) with a guide for
  generating the Twitter and YouTube cookie exports.
- README: product mentions in 'What it does', YouTube in the listeners + diagram,
  and the changelog-style section replaced by a credentials/changelog pointer.

Both connectors verified live end to end (feed -> watch -> judge). Full core
suite, ruff, and ty green; reviewed via /review-pr with findings addressed.
@joshpanka
joshpanka force-pushed the fix/twitter-connector-followups branch from b065b50 to c2d83b6 Compare September 1, 2026 18:17
@joshpanka
joshpanka merged commit c08bcae into main Sep 1, 2026
4 checks passed
@joshpanka
joshpanka deleted the fix/twitter-connector-followups branch September 1, 2026 18:19
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