Skip to content

Instantly share code, notes, and snippets.

@JacobWeisenburger
Last active January 28, 2025 17:59
Show Gist options
  • Save JacobWeisenburger/f43f4635be7bfb8328823103bfaf3e5f to your computer and use it in GitHub Desktop.
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment