sigvt / masterchat Goto Github PK
View Code? Open in Web Editor NEW💬 Get full access to YouTube Live Chat
Home Page: https://holodata.github.io/masterchat/
License: Apache License 2.0
💬 Get full access to YouTube Live Chat
Home Page: https://holodata.github.io/masterchat/
License: Apache License 2.0
This example won't do anything since the async iterator doesn't do iterations eagerly as arrays do and method like .toArray()
may help to do all the iterations.
import { Masterchat } from "masterchat";
import { appendFile, writeFile, readFile } from "node:fs/promises";
const mc = await Masterchat.init("<videoId>");
await mc
.iter()
.filter((action) => action.type === "addChatItemAction") // only chat events
.map((chat) => JSON.stringify(chat) + "\n") // convert to JSONL
.map((jsonl) => appendFile("./chats.jsonl", jsonl)); // append to the file
Incorrect durationText
parsing lead to error while running durationToSeconds
Seem to caused by the .slice(1)
Code:
masterchat/src/chat/actions/addChatItemAction.ts
Lines 268 to 272 in 02d6240
Example payload from https://www.youtube.com/watch?v=oSGkmRhur0Y
{
"id": "Ci8KLUNNV2F4WVA5cF9zQ0ZTSXZzd0FkQ3JvSF93LUxveU1lc0lELTMzNDEzOTU3Ng%3D%3D",
"timestampUsec": "1670697881347497",
"authorExternalChannelId": "UCQRNmDmpBneN3fKlcuMLHZQ",
"headerPrimaryText": {
"runs": [
{
"text": "Member for 1 month"
}
]
},
"headerSubtext": {
"simpleText": "Bachelor"
},
"message": {
"runs": [
{
"text": "WE MISSED YOU TOO VESPER! We understand what you need to do!"
}
]
},
"authorName": {
"simpleText": "Chelsea Rose"
},
"authorPhoto": {
"thumbnails": [
{
"url": "https://yt4.ggpht.com/P9mNI29I_xVBKxDmtjUjPecjV94zpQ4K4lsfyHse6XY1Kb1bexrgR5Dp8UKFmbUF0AbTrLMImA=s32-c-k-c0x00ffffff-no-rj",
"width": 32,
"height": 32
},
{
"url": "https://yt4.ggpht.com/P9mNI29I_xVBKxDmtjUjPecjV94zpQ4K4lsfyHse6XY1Kb1bexrgR5Dp8UKFmbUF0AbTrLMImA=s64-c-k-c0x00ffffff-no-rj",
"width": 64,
"height": 64
}
]
},
"authorBadges": [
{
"liveChatAuthorBadgeRenderer": {
"customThumbnail": {
"thumbnails": [
{
"url": "https://yt3.ggpht.com/N2Cpdqu4kPhdc6jS1KLQMOzhk24cBRyj2-S71GEGwrIzJRDxbDWPMlqXBKasCCVzqyctv2lY=s16-c-k",
"width": 16,
"height": 16
},
{
"url": "https://yt3.ggpht.com/N2Cpdqu4kPhdc6jS1KLQMOzhk24cBRyj2-S71GEGwrIzJRDxbDWPMlqXBKasCCVzqyctv2lY=s32-c-k",
"width": 32,
"height": 32
}
]
},
"tooltip": "Member (1 month)",
"accessibility": {
"accessibilityData": {
"label": "Member (1 month)"
}
}
}
}
],
"contextMenuEndpoint": {
"clickTrackingParams": "CAYQ4f0GIhMIwef3ztrv-wIVT_A4Bh1fXgMP",
"commandMetadata": {
"webCommandMetadata": {
"ignoreNavigation": true
}
},
"liveChatItemContextMenuEndpoint": {
"params": "Q2pFS0x3b3RRMDFYWVhoWlVEbHdYM05EUmxOSmRuTjNRV1JEY205SVgzY3RURzk1VFdWelNVUXRNek0wTVRNNU5UYzJHaWtxSndvWVZVTkVVbGRUVHpJNE1XSkpTRmxXYVMxUFZqTnBSbGxCRWd0dlUwZHJiVkpvZFhJd1dTQUJLQUV5R2dvWVZVTlJVazV0Ukcxd1FtNWxUak5tUzJ4amRVMU1TRnBST0FKSUFGQVg="
}
},
"contextMenuAccessibility": {
"accessibilityData": {
"label": "Chat actions"
}
},
"trackingParams": "CAYQ4f0GIhMIwef3ztrv-wIVT_A4Bh1fXgMP"
}
There's new content type liveChatProductItemRenderer
in the payload of parseAddBannerToLiveChatCommand
.
I want to add more features to the lib like seeking the chat to a given time offset etc.
I want to make a pull request but the test does not pass.
Will this code be complete?
git clone https://github.com/holodata/masterchat
cd masterchat
git switch dev
yarn install
yarn build
yarn test
How to set the token acquired by extra/credential-fetcher into Masterchat?
const credentialsB64 = token_acquired_by_credential_fetcher;
const credentials = credentialsB64
? JSON.parse(Buffer.from(credentialsB64, "base64").toString())
: undefined;
await Masterchat.init(id!, { credentials });
Is it okay to look like this?
I referenced this url.
This works flawlessly but I was wondering why the timeout is so long between messages? I manually set the delay to 1 second and it seems to work fine.
if (this.isLive ?? true) { const timeoutMs = continuation.timeoutMs; await delay(1000, signal); }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.