Skip to content

Instantly share code, notes, and snippets.

@North-West-Wind
Created August 13, 2025 12:49
Show Gist options
  • Select an option

  • Save North-West-Wind/a49197c304fe00cd60d39dad6e6c8a7e to your computer and use it in GitHub Desktop.

Select an option

Save North-West-Wind/a49197c304fe00cd60d39dad6e6c8a7e to your computer and use it in GitHub Desktop.
An example of rendering PeerTube livestream view count as a browser source for OBS
<html>
<title>PeerTube Viewer Count</title>
<body>
<div id="count">Connecting...</div>
<script>
const UPDATE_INTERVAL = 30000;
const INSTANCE_URL = "peertube.wtf"; // Replace with your instance
const VIDEO_ID = "gfZSSxtmpKJ3GSzSh6epoq"; // Replace with your livestream video ID
const div = document.getElementById("count");
const update = () => {
fetch(`https://${INSTANCE_URL}/api/v1/videos/${VIDEO_ID}`).then(async res => {
if (!res.ok) return;
div.innerHTML = (await res.json()).viewers;
});
};
update();
setInterval(update, UPDATE_INTERVAL);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment