README.md

viewercount

Just a small executable I made for myself using
rust-nostr to update the viewer count on
zap.stream live streams.

If you self-host your own stream (by providing a m3u8 URL), then by default,
zap.stream always shows '0 viewers' because the stream is not hosted by
zap.stream's servers, so they can't possibly know the number of viewers by
themselves.

Fortunately, nostr NIP53 Live Activies
replaceable events
may contain a special current_participants tag that signals to nostr clients
the number of live stream viewers.

There was no previously existing software that allowed to change that tag.

I made viewercount so that you can run it on the same machine that is hosting
the m3u8 live stream and periodically update the current_participants tag of
your live stream NIP53 events.

Install

cargo install viewercount

The viewercount binary will be in ~/.cargo/bin/viewercount

Or manually:

git clone https://github.com/sommerfelddev/viewercount
cd viewercount
cargo build --release

The viewercount binary will be in target/release/viewercount.

Usage

Usage: viewercount [OPTIONS] [NADDRS]...

Arguments:
  [NADDRS]...  specific naddrs of Live Events to update, if none, all user authored Live Events that are 'live' will be updated

Options:
  -i, --interval <INTERVAL>  watch interval in seconds [default: 60]
      --reset-nip46          remove previously cached NIP46 signer credentials and ask for new ones
      --use-nsecbunker       use an externally provided nsecbunker URI instead of generating a nostrconnectURI by default
  -h, --help                 Print help
  -V, --version              Print version

You can just run it without any arguments. It will provide you with a in-client
auto generated
NIP46 nostrconnect URI
which you can use to login remotely using Amber,
Keystache,
nsec.app or nsecbunker.com. If
the app does not have good support for generated nostrconnect:// URIs, you can
pass --use-nsecbunker and paste a nsecbunker URI instead of scanning a QR
code.

You just need to copy paste the URI on the first run, and it will then use your
NIP65 outbox relays
in combination with zap.stream's default relays.

The daemon will measure the number of live stream HLS connections by checking
for system TCP sockets on source port 443 with an established state that lasts
longer than 1 second.

Repository Details

name / identifier

viewercount

nostr clone url

nostr://npub16r0tl8a39hhcrapa03559xahsjqj4s0y6t2n5gpdk64v06jtgekqdkz5pl/nos.lol/viewercount
just install ngit and run
git clone nostr://...

description

Updates nostr Live Events with the number of HLS connections

grasp servers

none

git servers

https://git.sommerfeld.dev/viewercount
https://github.com/sommerfelddev/viewercount

maintainers

earliest unique commit

not specified

gitworkshop.dev logo GitWorkshop.dev