Skip to content

Instantly share code, notes, and snippets.

@JacobWeisenburger
Last active September 2, 2025 16:44
Show Gist options
  • Select an option

  • Save JacobWeisenburger/f43f4635be7bfb8328823103bfaf3e5f to your computer and use it in GitHub Desktop.

Select an option

Save JacobWeisenburger/f43f4635be7bfb8328823103bfaf3e5f to your computer and use it in GitHub Desktop.
checkIfYouTubeChannelIsLive
/**
CORS blocks this request from the browser, so you will need to run this code on the server.
*/
async function checkIfYouTubeChannelIsLive ( channelId: string ) {
const liveCheckURL = `https://www.youtube.com/embed/live_stream?channel=${ channelId }`
const responseText = await fetch( liveCheckURL ).then( res => res.text() )
const isLive = responseText.indexOf( 'This video is unavailable' ) < 0
return isLive
}
@nicolasguzca
Copy link

This worked wonderfully, thank you @JacobWeisenburger !

@JacobWeisenburger
Copy link
Author

you're welcome. Just curious, how did you find this?

@nicolasguzca
Copy link

Stackoverflow I believe, its been a blur to be honest haha, I've been doing scrapping and stuff to do this until I finally found your answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment