Created
October 19, 2024 15:16
-
-
Save sskanishk/2a13cad03afc73635253578f0699c80e to your computer and use it in GitHub Desktop.
Extract youtube video caption from its API response!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As per Oct 2024 | |
// On click of caption icon on youtube player, a API (https://www.youtube.com/api/timedtext) will get trigger, check in network tab. | |
// Get the response and pass that payload in below javascript function | |
// **payload and API might get change in future. | |
function getCaption(payload) { | |
const concatenatedString = payload.events | |
.flatMap(event => event.segs ? event.segs.map(seg => seg.utf8) : []) | |
.join(''); | |
console.log("concatenatedString ====> \n", concatenatedString) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment