Skip to content

Reduce YouTube API usage from offline live detection #22

Description

@Melkepakken

Context

jChat+ currently performs more YouTube Data API requests than necessary when a YouTube-enabled overlay remains open while the configured channel is offline.

While investigating API usage on August 12, 2026, Google Cloud showed roughly:

  • playlistItems.list: 592 requests
  • videos.list: 606 requests
  • search.list: 12 requests
  • channels.list: 5 requests

The majority of the traffic followed a roughly 30-second pattern.

Cloudflare logs confirmed that multiple OBS browser sources using the same YouTube handle were repeatedly requesting:

/api/youtube/live?handle=<handle>

This means the traffic was generated by normal jChat+ usage rather than external API abuse.

The current resolver caches an offline result for 30 seconds. Once that expires, an offline channel can fall back to checking the uploads playlist using playlistItems.list followed by videos.list.

Multiple browser sources can therefore multiply the amount of upstream YouTube API work even though they are resolving the same channel and no YouTube stream is live.

Required change

Reduce background YouTube API usage without making automatic live detection unreliable.

The improved resolver should:

  1. Avoid expensive YouTube Data API checks every 30 seconds while a channel remains offline
  2. Prevent multiple jChat+ browser sources resolving the same channel from unnecessarily multiplying upstream API requests
  3. Share live/offline state more effectively between clients where practical
  4. Back off discovery checks while a channel remains offline
  5. Still detect a new live stream reasonably quickly when the channel goes live
  6. Preserve existing youtube_video direct video ID behavior
  7. Preserve the current automatic handle-based live detection behavior from the user's perspective

A possible direction is shared channel state with event-driven live updates and a slower polling fallback, rather than relying on every browser source continuously performing live discovery.

Status

Root cause reproduced and identified in production.

No evidence of external API abuse was found. The excessive usage is caused by the current offline live-discovery behavior and can be amplified when several OBS/browser sources use YouTube simultaneously.

Implementation not started.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions