Open a Random Video from a Specific YouTube Channel

I created a Script to open a random video from a specific YouTube Channel. The script prompts user for the name of the channel, uses the scrapeSelector to get videos from the channel and then selects a random one to open.

Future enhancements: I'd like to add some error logging to help users if they enter an invalid channel name that returns a 404 or if a given channel exists but doesn't return any videos. I tried adding some console.logs but wasn't sure how to output helpful logs to ScriptKit users.

// Name: Random Video From YouTube Channel
// Description: Open a random video from a specific YouTube Channel
// Author: Monica Powell
// Twitter: @indigitalcolor
// GitHub: @m0nica
import "@johnlindquist/kit"
let channelName = await arg("YouTube Channel Name (e.g, yogawithadriene):")
let videos = await scrapeSelector(
el => ({
name: el.innerText,
value: el.href,
let randomVideo = videos[Math.floor(Math.random() * videos.length)]
exec(`open "${randomVideo.value}"`)

View gist: