2.10.4 • Published 1 year ago

yt-search v2.10.4

Weekly downloads
29,274
License
MIT
Repository
github
Last release
1 year ago

npm npm npm mac ubuntu windows

yt-search

simple youtube search API and CLI

npm.io

Installation

npm install yt-search # local module usage

Easy to use

const yts = require( 'yt-search' )
const r = await yts( 'superman theme' )

const videos = r.videos.slice( 0, 3 )
videos.forEach( function ( v ) {
	const views = String( v.views ).padStart( 10, ' ' )
	console.log( `${ views } | ${ v.title } (${ v.timestamp }) | ${ v.author.name }` )
} )
output
  38878009 | Superman Theme (4:13) | Super Man
   8861479 | Superman • Main Theme • John Williams (4:26) | HD Film Tributes
   7802473 | Superman - Main Theme (BBC Proms) (4:46) | brassbone player
try it

https://runkit.com/talmobi/runkit-npm-yt-search-basic

single video

const video = await yts( { videoId: '_4Vt0UGwmgQ' } )
console.log( video.title + ` (${ video.duration.timestamp })` )
output
Philip Glass. -  Koyaanisqatsi (original version) (3:29)
try it

https://runkit.com/talmobi/runkit-npm-yt-search-video

single playlist

const list = await yts( { listId: 'PL7k0JFoxwvTbKL8kjGI_CaV31QxCGf1vJ' } )

console.log( 'playlist title: ' + list.title )
list.videos.forEach( function ( video ) {
	console.log( video.title )
} )
output
playlist title: Superman Themes
The Max Fleischer Cartoon (From "Superman")
[Deleted video]
Superman Theme
[Private video]
Superman The Animated Series Full Theme
Smallville theme song
Reprise / Fly Away
Superman Doomsday Soundtrack- Main Title
Hans Zimmer - Man of Steel Theme
Supergirl CW Soundtrack - Superman Theme Extended
try it

https://runkit.com/talmobi/runkit-npm-yt-search-playlist

CLI Usage (interactive)

yt-search superman theme

If you have mpv installed, yt-search can directly play yt videos (or audio only)

yt-search-video Dank Memes Videos
yt-search-audio Wagner

If you don't have mpv installed, you can alternatively try installing yt-play-cli

npm install -g yt-play-cli

see: https://github.com/talmobi/yt-play

About

Simple function to get youtube search results.

Why

Not sure..

How

Using HTTP requests and parsing the results with cheerio.

CLI interactive mode with node-fzf

Options

var opts = { query: 'superman theme' }
yts( opts, function ( err, r ) {
	if ( err ) throw err
	console.log( r.videos ) // video results
	console.log( r.playlists ) // playlist results
	console.log( r.channels ) // channel results
	console.log( r.live ) // live stream results
} )

var opts = { videoId: 'e9vrfEoc8_g' }
yts( opts, function ( err, video ) {
	if ( err ) throw err
	console.log( video ) // single video metadata
} )

var opts = { listId: 'PL7k0JFoxwvTbKL8kjGI_CaV31QxCGf1vJ' }
yts( opts, function ( err, playlist ) {
	if ( err ) throw err
	console.log( playlist ) // single playlist metadata
	console.log( playlist.videos ) // playlist videos
} )

Alternatives

ytsr

Test

npm test
2.10.4

1 year ago

2.10.3

2 years ago

2.10.2

3 years ago

2.10.1

3 years ago

2.10.0

3 years ago

2.9.0

3 years ago

2.8.0

3 years ago

2.7.7

3 years ago

2.7.6

3 years ago

2.7.5

3 years ago

2.7.4

3 years ago

2.7.3

3 years ago

2.7.2

3 years ago

2.7.1

3 years ago

2.7.0

3 years ago

2.6.2

3 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.4.2

3 years ago

2.4.1

3 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.4

4 years ago

2.2.3

4 years ago

2.2.1

4 years ago

2.2.2

4 years ago

2.2.0

4 years ago

2.1.10

4 years ago

2.1.11

4 years ago

2.1.9

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

8 years ago