question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not work with channelId but it works liveId

See original GitHub issue

it does not work when i put my channel id:

//const liveChat = new LiveChat({ liveId: "0cWertczhs0" })
const liveChat = new LiveChat({ channelId: "UC8v86z0UWlgIg-foURD1Lyw" })

const ok = liveChat.start()

// Emit at start of observation chat.
// liveId: string
liveChat.on("start", (liveId) => {
    /* Your code here! */
    console.log("1");
})

// Emit at end of observation chat.
// reason: string?
liveChat.on("end", (reason) => {
    /* Your code here! */
    console.log("2");
})

// Emit at receive chat.
// chat: ChatItem
liveChat.on("chat", (chatItem) => {
    /* Your code here! */
    console.log("3");
})

// Emit when an error occurs
// err: Error or any
liveChat.on("error", (err) => {
    /* Your code here! */
    console.log("4");
})

// Start fetch loop

if (!ok) {
    console.log("Failed to start, check emitted error")
}

error:

D:\999 - OS\Documents\LoquendoBotV2\node_modules\axios\lib\adapters\xhr.js:210 GET https://consent.youtube.com/m?continue=https%3A%2F%2Fwww.youtube.com%2Fchannel%2FUC8v86z0UWlgIg-foURD1Lyw%2Flive&gl=NL&m=0&pc=yt&uxe=23983171&hl=en&src=1 403

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

2reactions
neverclear86commented, Dec 11, 2021

I see… I didn’t notice it because there is no dialog in Japan. 😞 I have a plan to replace axios with another library, so I’m sorry, but I’ll think about it a bit.

1reaction
kireitacommented, Dec 8, 2021

I figured it out:

in my country you need to confirm a dialog before opening youtube: image

i tried it with postman and these are the headers i need to send:

'cache-control': 'no-cache',
Connection: 'keep-alive',
Cookie: 'CONSENT=YES+42',
Host: 'www.youtube.com',
'Postman-Token': '22881d06-be4b-4ff5-9e91-67ce106f8379,151619c9-a51e-4f11-9318-2961809b2fa4',
'Cache-Control': 'no-cache',
Accept: '*/*',
'User-Agent': 'PostmanRuntime/7.17.1',

but if i try to send these headers with the npm package axios i get this:

const axiosConfig = {
headers: {
	'content-Type': 'application/json',
	Accept: '/',
	'cache-control': 'no-cache',
	Connection: 'keep-alive',
	Cookie: 'CONSENT=YES+42',
	Host: 'www.youtube.com',
	'Postman-Token': '22881d06-be4b-4ff5-9e91-67ce106f8379,151619c9-a51e-4f11-9318-2961809b2fa4',
	'Cache-Control': 'no-cache',
	'User-Agent': 'PostmanRuntime/7.17.1',
},
credentials: 'same-origin',
};
axios.defaults.withCredentials = true;
axios.get(
`https://www.youtube.com/channel/${channelId}/live`,
axiosConfig,
)
.then((res) => {
// Some result here
	console.log(res);
})
.catch((err) => {
	console.log(err);
});

image

and when i do it with npm package request it is a success:

	const options = {
		method: 'GET',
		url: `https://www.youtube.com/channel/${channelId}/live`,
		headers:
		{
			'cache-control': 'no-cache',
			Connection: 'keep-alive',
			Cookie: 'CONSENT=YES+42',
			Host: 'www.youtube.com',
			'Postman-Token': '22881d06-be4b-4ff5-9e91-67ce106f8379,151619c9-a51e-4f11-9318-2961809b2fa4',
			'Cache-Control': 'no-cache',
			Accept: '*/*',
			'User-Agent': 'PostmanRuntime/7.17.1',
		},
	};

	request(options, (error, response, body) => {
		if (error) throw new Error(error);

		const soup = new JsSoup(body, false);

		const livestreamLink = soup.findAll('link', { rel: 'canonical' });
		console.log(livestreamLink);

	});
}

you can close the case if you want but if other people use your package it will need to get updated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Telethon doesn't work with channel ID but works with username
But i don't understand why work only if use username in channelID, i want use ID because some channel are private.
Read more >
File picker - OneDrive dev center - Microsoft Learn
The picker is designed to work with either OneDrive OR SharePoint in a given instance and only one of the entry sections should...
Read more >
Microsoft365 – Mohamed Ashiq Faleel
This example delivers messages only on the Team channel and not to the users directly so you can choose the service URL based...
Read more >
Hass.io Add-on: Xbox One - Home Assistant OS
I fixed it by changing the version number in the custom_component. Now it works flawlessly and I do not have any problems with...
Read more >
Use Content ID matching on live streams - YouTube Help
However, matching can only be turned on and managed by the individual channel ... Track policies will not work for Content ID matching...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found