Created
August 13, 2025 12:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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