The simplest chat logger for streams on Odysee (NodeJS, without auth) – Mikulski
Site Overlay

The simplest chat logger for streams on Odysee (NodeJS, without auth)

DISCLAIMER:
I am not a programmer, but only an enthusiastic copy-paster who shares what he could figure out. It is possible that knowledgeable experts may find some points or formulations erroneous or ridiculous.
This material is for informational purposes only.

Coolstory

This article will demonstrate and describe in detail a very simple JS script that I used to log a stream chat on the Odysee site. Where I broadcast Mikulski_Radio for a short time. I decided to share it, so to speak, for the sake of history and with little faith that it will be useful to someone else.

Nuances

The chat is connected via a websocket using the WS library.
Unfortunately, I have not been able to find an automated way to get the correct wss link with the required ids. Therefore, you will have to extract it manually through the browser inspector.
However, this did not bother me much, since my use was in the context of a round-the-clock stream: I set it up once and forgot. And I don’t remember exactly anymore, but it’s likely that Odyssey uses a permanent broadcast key and the chat id is assigned to it forever. But I haven’t experimented with this and I could be wrong.
In addition to messages, you can also catch donations with “LBC credits” (the internal currency of the site, such as bits on Twitch), as well as the current number of viewers. “Follow”-events is not coming.

How to use

Since this is javascript, you need node js and npm installed. Create a folder and a file in it with the .js-extension.
Being inside the newly created directory, you need to install the WS repository:

npm i ws

You need to paste the copied code into the js file, which will go further.
Now to find the right connection link:
open the page with the stream in the browser -> open the inspector (F12) -> Network tab -> WS -> Refresh the page (F5 or Ctrl+R) -> click on the line where there is the word "commentron" -> Headers -> there will be a Request URL line with with the link, copy it.
The resulting link must be substituted in the script with the line const link = "" and enclosed in quotation marks.

Script

const WebSocket = require("ws");

const link = "insert wss-url here";

const chat = new WebSocket(link);

chat.on("error", console.error);

chat.addEventListener('open', function (event) {
    console.log("ODYSEE IS CONNECTED")
  });

chat.addEventListener('message', function (event) {
    let comment=JSON.parse(event.data);        
    let msg = comment.data.comment?.comment;
    let channel_name = comment.data.comment?.channel_name;
    let nickname = channel_name?.substring(1);
    let credits = comment.data.comment?.support_amount;

/// VIEWERS COUNT    
if (comment.type === 'viewers') {  
    return console.log(`[Odysee | Current Viewers : ${comment.data.connected} ]`)
}  

/// CHAT LOG
if (comment.type === 'delta') {  
   console.log(`[Odysee | ${nickname}] ${msg}`)

/// SUPPORT EVENT - LBC CREDITS
if (credits > 0) {  
    console.log(`[Odysee]: ${nickname} gives ${credits} LBC`)
    }   
}
});  

chat.on("close", () => {
  console.log("ODYSEE IS DISCONNECTED");
  process.exit(0);
});

If this material is useful to you and you have the opportunity,
then support the author and the site with a small tip:
https://hipolink.me/mikulski/tips
Thanks💛


0 comments
Inline Feedbacks
View all comments