BETA: Chrome Capture for Channels

Reboot?

From what I can tell, we need to pass a button press to the stream to unmute the
audio.

Something like "button.playback-button[aria-label=Unmute Sound]"
Not sure if that is something we can inject into the chromecast request?

@tmm1 any thoughts on how to get the audio unmuted for Peacock live channels?

Update the code in main.js to do what you need

if (document.host == "peacock.com") {
  document.querySelector("button.playback-button[...]").click()
}
1 Like

How can we do this if we're just running the Mac executable file on a Mac Mini?

1 Like

You will need to install node.js on the Mac, and then run "node main.js" after editing the main.js file. At least, that's what I did for Windows, so assuming it's the same for Mac.

Gave that a try but getting a reference error:

[2024/01/03 13:46:01.212] failed to stream https://www.peacocktv.com/watch/playback/live/8782376954583476117/ ReferenceError: document is not defined
at C:\Users\WMC\Documents\chrome-capture-for-channels\main.js:323:1
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

1 Like

I figured out how to get main.js running and added the code and I'm not getting the same error you are, but it's also still not unmuting the audio...

1 Like

@tmm got this error:
if (document.host == "peacock.com") {
^

ReferenceError: document is not defined
at Object. (/Users/jerryhuster/main.js:354:1)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49

Node.js v20.10.0

1 Like

Sorry I cannot teach coding here. Use ChatGPT

1 Like

All I did was provide some feedback, as I thought this was the "Playground" area. I used your code as given. (EDIT: This is moot now, but I did take offense at the reply to use ChatGPT, as I see you as the expert @tmm :slight_smile: and hold you in high regard) That is the absolutely most unprofessional response you could have given someone who's been a subscriber for 5+ years. You, sir, will never see another dime of my money. Wow.

1 Like

It was not meant to be offensive. My hand is injured and I cannot type easily.

My suggestion was an example of pseudo code. It has to be tweaked and what matters is where it is inserted. ChatGPT is very good at taking a starting point and helping integrate.

3 Likes

I appreciate the clarification and I'm sorry to hear your thumb/hand is injured. I hope you can see how I took that as dismissive and rude... I am genuinely excited to get this working specifically because Peacock carries some channels that aren't offered on other streaming solutions (and certainly not ones that are easily accessible). I'll play around with Chat GPT... I thought maybe you had a solution in place, I didn't know it was a starter. Once I got main.js up and running (I was just using the basic executable), I will see what can be done and share what I find.

1 Like

Investigating this a bit using ChatGPT... and it suggested creating a separate clientScript.js with the following code:

if (window.location.host === "www.peacocktv.com") {
const playbackButton = document.querySelector("button.playback-button");

if (playbackButton) {
playbackButton.click();
} else {
console.error("Playback button not found.");
}

Then, adding the following to main.js:

async function main() {
// ... (existing code)

const browser = await getCurrentBrowser();

browser.on('targetcreated', async target => {
if (target.type() === 'page') {
const page = await target.page();
await page.addScriptTag({ path: path.join(__dirname, 'clientScript.js') });
}
});

// ... (existing code)

const server = app.listen(5589, () => {
console.log('Chrome Capture server listening on port 5589');
});
}

main();

I don't get any errors upon running node main.js, however, the mute button still remains unclicked. I'm guessing Peacock is purposely making this tricky likely to avoid this very scenario. Again, just a guess/assumption since I'm still poking around and seeing if any changes make a difference.

With the help of ChatGPT I was able to get this to work. Add the following code to line 321:

// Check if the page is peacocktv.com
    if (page.url().includes('peacocktv.com')) {
        await page.waitForSelector('.playback-button-icon.volume-muted', { visible: true }); // Wait for the element to be visible

        await page.evaluate(() => {
            const svgElement = document.querySelector('.playback-button-icon.volume-muted');
            if (svgElement) {
                svgElement.dispatchEvent(new MouseEvent('click', { bubbles: true })); // Dispatch a click event on the SVG element
            } else {
                console.error('SVG element not found');
            }
        });
    }
3 Likes

Yes but one should also put a script to reload the page after so long so that the video loads. I hear the video stops after so long.

Holy cow! You did it! That code works... Peacock plays with audio using that code. Perhaps you can sometime share what you asked ChatGPT to get that. I tried a bunch of different ways but none of its solutions quite worked. This one is great!

2 Likes

I think this should all be made into a PR on github for the rest to use...

God knows I might as Peacock has some channels I want to pipe in

1 Like

This is a little more specific to my use case, but I setup the NBC Sports California station and it works. However since this channel covers are large region the main broadcast doesn't show Sacramento Kings games. I have to navigate to it directly in the app and they use URLs such as:

https://www.nbc.com/watch/nba/toronto-raptors-vs-sacramento-kings/4504536

Is anyone able to figure out if there is a standard URL that will take you directly to the local Sacramento feed of NBC Sports California or directly to the live Kings games stream?

2 Likes

Would someone who has Sling setup share how they did it? I have this working fine with the default channels, but even after reading hundreds of posts here I just can't seem to get the Sling URLs figured out.
Thank you.

I'm not using Sling anymore, but I'm the one who originally figured out the URL structure for use with ah4c (formerly androidhdmi-for-channels). Here's the post in that thread talking about it:

Using the same example from that thread, an M3U entry in this project should look something like this:

#EXTINF:-1 channel-id="SHOCSHD" tvc-guide-stationid="61001",Showtime Showcase HD
chrome://localhost:5589/stream?url=https://watch.sling.com/1/channel/b24b20f009e94eb1ad2441a19f98b7ff/watch

And here's the sling.m3u I used in ah4c, which would give you the unique identifier and matching station ID for numerous channels:

#EXTM3U
#EXTINF:-1 channel-id="STZHD" tvc-guide-stationid="34941",Starz HD
http://{{ .IPADDRESS }}/play/tuner/1a3c345b84b149918e0bad8f797df70a
#EXTINF:-1 channel-id="STZHDP" tvc-guide-stationid="34949",Starz HD West
http://{{ .IPADDRESS }}/play/tuner/8a84458592844ff5849712ef7766fb4e
#EXTINF:-1 channel-id="STZKHD" tvc-guide-stationid="57581",Starz Kids & Family HD
http://{{ .IPADDRESS }}/play/tuner/148a1e391db94edf96bf25e25beb307d
#EXTINF:-1 channel-id="STZCHD" tvc-guide-stationid="57569",Starz Comedy HD
http://{{ .IPADDRESS }}/play/tuner/d96b102ac5c54967bf56b8b57e20c84e
#EXTINF:-1 channel-id="STZEHD" tvc-guide-stationid="57573",Starz Edge HD
http://{{ .IPADDRESS }}/play/tuner/1535e572f07348159d8924d58200690e
#EXTINF:-1 channel-id="STRZIBH" tvc-guide-stationid="67235",Starz in Black HD
http://{{ .IPADDRESS }}/play/tuner/23a6ea3c163a47f390f73900ccc76bc1
#EXTINF:-1 channel-id="STRZCIH" tvc-guide-stationid="67236",Starz Cinema HD
http://{{ .IPADDRESS }}/play/tuner/0eedb59656d243da914fef990a8db903
#EXTINF:-1 channel-id="STZENHD" tvc-guide-stationid="36225",Starz Encore HD
http://{{ .IPADDRESS }}/play/tuner/ed5d0f85928f45249f8a67c9746a80b7
#EXTINF:-1 channel-id="STZENCP" tvc-guide-stationid="17125",Starz Encore West
http://{{ .IPADDRESS }}/play/tuner/a0515fde0c074dc389981e8881874aae
#EXTINF:-1 channel-id="STZENCL" tvc-guide-stationid="14764",Starz Encore Classic
http://{{ .IPADDRESS }}/play/tuner/2230d31d16d541c08e654d4a11863d2c
#EXTINF:-1 channel-id="STZEWSS" tvc-guide-stationid="102906",Starz Encore Westerns
http://{{ .IPADDRESS }}/play/tuner/73ab11e5664241a9811e7e22602bfda9
#EXTINF:-1 channel-id="STZENSU" tvc-guide-stationid="14766",Starz Encore Suspense
http://{{ .IPADDRESS }}/play/tuner/04e4a4f1e0ec4dfba961414197e57d7f
#EXTINF:-1 channel-id="STZENBK" tvc-guide-stationid="14870",Starz Encore Black
http://{{ .IPADDRESS }}/play/tuner/1ec67d324b564a528f6901ed8e09334e
#EXTINF:-1 channel-id="SZEAHD" tvc-guide-stationid="72015",Starz Encore Action HD
http://{{ .IPADDRESS }}/play/tuner/8aed8223a6104b53b24f03555fc933a9
#EXTINF:-1 channel-id="STZENFS" tvc-guide-stationid="102903",Starz Encore Family
http://{{ .IPADDRESS }}/play/tuner/22076462a8124832967e30e0f9f92213
#EXTINF:-1 channel-id="SHOWHD" tvc-guide-stationid="21868",Showtime HD
http://{{ .IPADDRESS }}/play/tuner/7f5f5993457648d68db2fa5d5103cbcc
#EXTINF:-1 channel-id="SHOWHDP" tvc-guide-stationid="22532",Showtime HD West
http://{{ .IPADDRESS }}/play/tuner/f8ee74606d2a47ec8ca14842b2762b9b
#EXTINF:-1 channel-id="SHO2HD" tvc-guide-stationid="58533",Showtime 2 HD
http://{{ .IPADDRESS }}/play/tuner/30b674a6204f4d9b8ec053e0f6381a28
#EXTINF:-1 channel-id="SHOBETH" tvc-guide-stationid="68340",Showtime BET HD
http://{{ .IPADDRESS }}/play/tuner/df9f6f06051d4681938a627be72a4cf9
#EXTINF:-1 channel-id="SHOXHD" tvc-guide-stationid="60947",Showtime Extreme HD
http://{{ .IPADDRESS }}/play/tuner/ea47544f20394a4b83a2c0678c078d66
#EXTINF:-1 channel-id="SHOCSHD" tvc-guide-stationid="61001",Showtime Showcase HD
http://{{ .IPADDRESS }}/play/tuner/b24b20f009e94eb1ad2441a19f98b7ff
#EXTINF:-1 channel-id="NEXTHD" tvc-guide-stationid="68342",Showtime NextHD
http://{{ .IPADDRESS }}/play/tuner/b5540f5fb9b542aeb0f253d9854c174f
#EXTINF:-1 channel-id="FAMZHD" tvc-guide-stationid="103892",Showtime Familyzone HD
http://{{ .IPADDRESS }}/play/tuner/7b21fc1766304e268ef4757d56b3ac44
#EXTINF:-1 channel-id="WOMNHD" tvc-guide-stationid="68338",Showtime Women
http://{{ .IPADDRESS }}/play/tuner/1157b0988f29416485ce768e33f3c396
#EXTINF:-1 channel-id="INDIEHD" tvc-guide-stationid="65795",IndiePlex HD
http://{{ .IPADDRESS }}/play/tuner/7a17fd0c15754658885b368a0b273565
#EXTINF:-1 channel-id="RETROHD" tvc-guide-stationid="65791",RetroPlex HD
http://{{ .IPADDRESS }}/play/tuner/9ad3916eb22d4c169c7713afa5ee0f2b
#EXTINF:-1 channel-id="MPLEXHD" tvc-guide-stationid="83075",MoviePlex HD
http://{{ .IPADDRESS }}/play/tuner/deba2421b6ff44478320b2c60051f1d7
1 Like