FlowMonitor is a library dedicated to simplifying monitoring live streams across multiple platforms. With easy integration and real-time notifications, FlowMonitor offers an efficient solution for monitoring key events such as start, end and title changes, allowing you to maintain clear control over the status of your live streams. Ideal for developers looking for a hassle-free and effective approach to managing streaming data.
Explore the docs »
Report Bug
.
Request Feature
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
First install our library
npm install flow-monitor
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
},
})
fMonitor.connect('LofiGirl', 'youtube')
fMonitor.connect('zvods', 'twitch')
fMonitor.start()
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')
})
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)
})
-
disconnect
Disconnects a channel from the flow monitorfMonitor.disconnect('@LofiGirl', 'youtube')
-
close
Removes all channels and stops monitoringfMonitor.close()
-
livedata
Returns transmission data if already savedfMonitor.livedata('LofiGirl', 'youtube')
Distributed under the MIT License. See LICENSE for more information.
- ZackSB - Master's degree in life - ZackSB - Built flow-monitor