Skip to content

Commit 41a2e3e

Browse files
committed
optimize metadata extraction in youtube_meta.html
1 parent 328d88b commit 41a2e3e

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

public/youtube_meta.html

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
html, body {
1717
margin: 0;
1818
padding: 0;
19-
width: 25%;
20-
height: 25%;
19+
width: 1px;
20+
height: 1px;
2121
overflow: hidden;
2222
}
2323

2424
#player-container {
25-
width: 25%;
26-
height: 25%;
25+
width: 1px;
26+
height: 1px;
2727
position: fixed;
2828
top: 0;
2929
left: 0;
@@ -59,7 +59,7 @@
5959
modestbranding: 1, // Reduce branding
6060
enablejsapi: 1, // Enable JS API for custom controls
6161
muted: 1, //Set to play muted
62-
autoplay: 1 //Set to make it autostart
62+
autoplay: 0 //Set to make it autostart
6363
};
6464

6565
function onYouTubeIframeAPIReady() {
@@ -83,20 +83,14 @@
8383
host: 'https://www.youtube-nocookie.com',
8484
events: {
8585
onReady: () => {
86-
player.setVolume(0)
87-
},
88-
onStateChange: (event) => {
89-
if (event.data === YT.PlayerState.PLAYING) {
90-
91-
const videoData = player.getVideoData()
92-
const metadata = {
93-
title: videoData.title,
94-
isLive: videoData.isLive,
95-
duration: Math.round(player.getDuration()),
96-
};
97-
98-
console.log("METADATA:" + JSON.stringify(metadata));
99-
}
86+
const videoData = player.getVideoData();
87+
const metadata = {
88+
title: videoData.title,
89+
isLive: videoData.isLive,
90+
duration: Math.round(player.getDuration()),
91+
};
92+
93+
console.log("METADATA:" + JSON.stringify(metadata));
10094
},
10195
onError: (event) => {
10296
const YT_ERROR_CODES = {

0 commit comments

Comments
 (0)