play youtube videos ( sound only ) in the terminal using electron (and its bundled chromium)
npm install -g yt-play-cli
# enter interactive search and select mode
yt-play
or
npm install -g yt-play-cli
# play known video id directly
yt-play rnQBF2CIygg
const ytp = require( 'yt-play-cli' )
ytp.play( 'Wkof3nPK--Y' )
ytp.on( 'duration', function ( time ) {
console.log( time.text )
} )
ytp.once( 'end', function () {
process.exit()
} )
Play youtube videos ( music only ) from the CLI using electron.
Uses yt-search and node-fzf to search for videos to play if no CLI videoId argument is provided.
To test/try/play around with electron.
Using electron we simply go to the youtube page and play the video.. and attach some video event listeners and block ads.
The reason we use electron instead of puppeteer is because the chromium version that comes bundled with electron can play more media types ( e.g. h264 that some YouTube video's are encoded in ) that the chromium version that puppeteer comes with can't play ( e.g. https://www.youtube.com/watch?v=pFbkURxNKPE )
Using puppeteer-core we simply go to the youtube page and play
the video.. and attach some video event listeners and block ads.
Leaving video id cli argument empty you will enter search and select mode using yt-search and node-fzf
$ yt-play [youtube-video-id]
If no video id is provided you will enter interactive search and select mode.
npm install -g yt-play-cli
Searches and plays a youtube video using the CLI
npm test