Skip to content

Refactor stream routes to JSON API responses - #23

Open
SasukeXDev wants to merge 8 commits into
mainfrom
codex/refactor-stream_routes.py-for-json-responses
Open

Refactor stream routes to JSON API responses#23
SasukeXDev wants to merge 8 commits into
mainfrom
codex/refactor-stream_routes.py-for-json-responses

Conversation

@SasukeXDev

Copy link
Copy Markdown
Owner

Motivation

  • Convert frontend-facing endpoints from server-rendered HTML to a JSON API so clients can render UI and consume metadata programmatically.
  • Keep direct streaming/download functionality intact for media delivery while removing backend template rendering responsibilities.
  • Standardize returned data shapes (serialize DB documents, include watch/download URLs, surface auth state) to simplify frontend integration.

Description

  • Replaced HTML responses with JSON across login, home, playlist, channel, search, dbsearch, and watch routes by using web.json_response(...) and returning structured payloads rather than rendered snippets.
  • Added shared helpers: _is_admin, _auth_payload, _serialize_document, and _with_watch_urls to centralize auth payloads and document serialization (including converting Mongo _id to id) and to attach watch_url/download_url to items.
  • Refactored helper generators in bot/helper/chats.py and bot/helper/index.py to return structured dictionaries/lists (with public_id, thumbnail_url, watch_url, etc.) instead of HTML strings so routes can forward JSON data directly.
  • Preserved streaming/download logic inside media_streamer() and the route GET /{chat_id}/{encoded_name}; updated watch route to return file metadata and stream/download URLs (including video metadata when available).
  • Removed the now-unused server-side renderer bot/server/render_template.py and the bot/server/template/ HTML files since API routes no longer call render_page().

Testing

  • Ran python -m compileall bot to verify modules compile after refactor, which completed successfully.
  • Ran repository searches for template rendering and HTML response patterns to confirm render_page and server templates were removed, and those checks passed (no remaining backend HTML responses in the modified routes).
  • No automated unit tests were present or modified in this change; only compilation and repository scanning were executed and succeeded.

Codex Task

@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hub360 Ready Ready Preview, Comment Jul 10, 2026 5:27pm

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant