npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flow-monitor

v1.0.5

Published

A lightweight library for monitoring live streams across multiple platforms. Make it easy to follow essential events, such as the start and end of broadcasts, with real-time notifications. The perfect solution for developers looking for a simple and effic

Downloads

482

Readme

Contributors Issues License npm version

About The Project

This library was created to facilitate the use of websocket, focused more specifically on reconnection, with it it is possible to send parameters that can be used for authentication, and if the connection is closed, when the connection is resumed, it will resend the data for authentication again

Getting Started

Installation

First install our library

npm install flow-monitor

Usage

Import the library

import { FlowMonitor } from 'flow-monitor'

instantiate the class

const fMonitor = new FlowMonitor({
  twitch: {
    headers: {
      Authorization: 'OAuth ', // Authorization to get the m3u8 url without ads if you are registered or have turbo, but not a mandatory parameter
    }, // optional http request headers,
  },
  youtube: {
    headers: {}, // optional http request headers,
    intervalChecker: 10 * 1000, // Time in milliseconds, default is 5000 = 5s
  },
})

Connect to channels

fMonitor.connect('LofiGirl', 'youtube')
fMonitor.connect('zvods', 'twitch')

Start monitoring

fMonitor.start()

Event Handling

Returns twitch request errors, such as authentication error when passing authorization

fMonitor.on('twitchError', (error, status, message) => {
  console.log(error, status, message)
})

When you call the start function and start

fMonitor.on('start', () => {
  console.log('Flow monitor started')
})

When a new channel is connected

fMonitor.on('newChannel', ({ name, platform }) => {
  console.log(name, platform)
})

Confirmation when the channel is disconnected using the disconnect function

fMonitor.on('disconnectChannel', ({ name, platform }) => {
  console.log('Channel disconnected', name, platform)
})

When the flow monitor is finished with the close function

fMonitor.on('close', () => {
  console.log('Flow monitor has been closed')
})

These upcoming events all return an object with the current stream information

livedata structure:

export type LMEventTypes = 'streamUp' | 'streamDown' | 'viewerCount' | 'title' | 'category'
export type LMPlatforms = 'twitch' | 'youtube' | 'kick'
export type LMCategory = {
  image: string
  name: string
  id: string
}

export type LMLiveData = {
  event?: LMEventTypes
  platform: LMPlatforms
  channel: string
  title: string
  category: LMCategory
  viewers: number
  thumbnail: string
  started_at: string
  vodId: string
  m3u8Url?: string
}

When the broadcast opens, if you connect the channel and it is already live, you will receive the same

fMonitor.on('streamUp', (livedata) => {
  console.log('streamUp', livedata)
})

When the transmission is finished

fMonitor.on('streamDown', (livedata) => {
  console.log('streamDown', livedata)
})

When the category is changed

fMonitor.on('category', (livedata) => {
  console.log('category', livedata)
})

Broadcast title changed

fMonitor.on('title', (livedata) => {
  console.log('title', livedata)
})

Viewer count changes

fMonitor.on('viewerCount', (livedata) => {
  console.log('viewerCount', livedata)
})

Additional Functions

  • disconnect Disconnects a channel from the flow monitor

    fMonitor.disconnect('@LofiGirl', 'youtube')
  • close Removes all channels and stops monitoring

    fMonitor.close()
  • livedata Returns transmission data if already saved

    fMonitor.livedata('LofiGirl', 'youtube')

License

Distributed under the MIT License. See LICENSE for more information.

Authors

  • ZackSB - Master's degree in life - ZackSB - Built flow-monitor

Acknowledgements