Skip to content

Instantly share code, notes, and snippets.

View JacobWeisenburger's full-sized avatar
🚀
Available for hire!

Jacob Weisenburger JacobWeisenburger

🚀
Available for hire!
View GitHub Profile
@JacobWeisenburger
JacobWeisenburger / checkIfYouTubeChannelIsLive.ts
Last active September 2, 2025 16:44
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
}
@JacobWeisenburger
JacobWeisenburger / CustomErrorMessages.ts
Created February 10, 2025 19:07
A way to make custom error messages for types
type ValidateType<T extends string> =
T extends 'bad' ? 'Error message'
: T extends 'another bad' ? 'Another error message'
: T extends 'Error message' | 'Another error message' ? `Can't use '${ T }'`
: T
function fn<T extends string> ( arg: ValidateType<T> ) { }
fn( 'this should work' ) // works
fn( 'bad' ) // Argument of type '"bad"' is not assignable to parameter of type '"Error message"'.