Update to v13 and add queue and completely change code
This commit is contained in:
parent
dcef23d0ed
commit
55a38726a3
6706 changed files with 424137 additions and 61608 deletions
141
node_modules/yt-search/README.md
generated
vendored
Normal file
141
node_modules/yt-search/README.md
generated
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
[](https://www.npmjs.com/package/yt-search)
|
||||
[](https://www.npmjs.com/package/yt-search)
|
||||
[](https://www.npmjs.com/package/yt-search)
|
||||

|
||||

|
||||

|
||||
|
||||
# yt-search
|
||||
simple youtube search API and CLI
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
```bash
|
||||
npm install yt-search # local module usage
|
||||
```
|
||||
|
||||
## Easy to use
|
||||
```javascript
|
||||
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
|
||||
```javascript
|
||||
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
|
||||
```javascript
|
||||
const video = await yts( { videoId: '_4Vt0UGwmgQ' } )
|
||||
console.log( video.title + ` (${ video.duration.timestamp })` )
|
||||
```
|
||||
###### output
|
||||
```javascript
|
||||
Philip Glass. - Koyaanisqatsi (original version) (3:29)
|
||||
```
|
||||
|
||||
###### try it
|
||||
https://runkit.com/talmobi/runkit-npm-yt-search-video
|
||||
|
||||
#### single playlist
|
||||
```javascript
|
||||
const list = await yts( { listId: 'PL7k0JFoxwvTbKL8kjGI_CaV31QxCGf1vJ' } )
|
||||
|
||||
console.log( 'playlist title: ' + list.title )
|
||||
list.videos.forEach( function ( video ) {
|
||||
console.log( video.title )
|
||||
} )
|
||||
```
|
||||
###### output
|
||||
```javascript
|
||||
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)
|
||||
```bash
|
||||
yt-search superman theme
|
||||
```
|
||||
|
||||
If you have `mpv` installed, yt-search can directly play yt videos (or audio only)
|
||||
```bash
|
||||
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`
|
||||
```bash
|
||||
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](https://github.com/cheeriojs/cheerio).
|
||||
|
||||
CLI interactive mode with [node-fzf](https://github.com/talmobi/node-fzf)
|
||||
|
||||
## Options
|
||||
```bash
|
||||
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](https://www.npmjs.com/package/ytsr)
|
||||
|
||||
## Test
|
||||
```
|
||||
npm test
|
||||
```
|
68
node_modules/yt-search/bin/cli.js
generated
vendored
Executable file
68
node_modules/yt-search/bin/cli.js
generated
vendored
Executable file
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
var fs = require( 'fs' )
|
||||
var path = require( 'path' )
|
||||
|
||||
var ytSearch = require(
|
||||
path.join( __dirname, '../dist/yt-search.js' )
|
||||
)
|
||||
|
||||
var argv = require( 'minimist' )( process.argv.slice( 2 ) )
|
||||
|
||||
var pjson = require( path.join( __dirname, '../package.json' ) )
|
||||
|
||||
if ( argv.v || argv.V || argv.version ) {
|
||||
console.log( pjson.name + ': ' + pjson.version )
|
||||
process.exit()
|
||||
}
|
||||
|
||||
var query = argv._.join( ' ' )
|
||||
|
||||
if ( !query ) {
|
||||
console.log( 'No search query given. Exiting.' )
|
||||
return process.exit( 1 )
|
||||
}
|
||||
|
||||
ytSearch(
|
||||
query,
|
||||
function ( err, r ) {
|
||||
if ( err ) throw err
|
||||
|
||||
var list = []
|
||||
var videos = r.videos
|
||||
|
||||
for ( var i = 0; i < videos.length; i++ ) {
|
||||
var song = videos[ i ]
|
||||
// console.log( song.title + ' : ' + song.duration )
|
||||
|
||||
var title = song.title
|
||||
|
||||
var text = (
|
||||
title +
|
||||
' ($t)'.replace( '$t', song.timestamp ) +
|
||||
' | ' + song.videoId + ' | ' + song.views
|
||||
)
|
||||
|
||||
list.push( text )
|
||||
}
|
||||
|
||||
var nfzf = require( 'node-fzf' )
|
||||
nfzf( list, function ( r ) {
|
||||
if ( !r.selected ) {
|
||||
process.exit( 1 )
|
||||
}
|
||||
|
||||
// console.log( r.selected.value )
|
||||
|
||||
const video = videos[ r.selected.index ]
|
||||
|
||||
if ( argv[ 'v' ] || argv[ '--id' ] ) {
|
||||
console.log( video.videoId )
|
||||
} else {
|
||||
console.log( video.url )
|
||||
}
|
||||
|
||||
process.exit()
|
||||
} )
|
||||
}
|
||||
)
|
4
node_modules/yt-search/bin/mpv_audio.sh
generated
vendored
Executable file
4
node_modules/yt-search/bin/mpv_audio.sh
generated
vendored
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
QUERY="$@"
|
||||
mpv --no-video "$(yt-search $QUERY)"
|
4
node_modules/yt-search/bin/mpv_video.sh
generated
vendored
Executable file
4
node_modules/yt-search/bin/mpv_video.sh
generated
vendored
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
QUERY="$@"
|
||||
mpv "$(yt-search $QUERY)"
|
1319
node_modules/yt-search/dist/yt-search.js
generated
vendored
Normal file
1319
node_modules/yt-search/dist/yt-search.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
58
node_modules/yt-search/package.json
generated
vendored
Normal file
58
node_modules/yt-search/package.json
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"name": "yt-search",
|
||||
"version": "2.10.2",
|
||||
"description": "search youtube",
|
||||
"main": "dist/yt-search.js",
|
||||
"bin": {
|
||||
"yt-search": "bin/cli.js",
|
||||
"yt-search-video": "bin/mpv_video.sh",
|
||||
"yt-search-audio": "bin/mpv_audio.sh"
|
||||
},
|
||||
"files": [
|
||||
"bin/**.*",
|
||||
"dist/yt-search.js"
|
||||
],
|
||||
"scripts": {
|
||||
"debug": "debug=1 node src/index.js --silent",
|
||||
"build": "npm run build:src",
|
||||
"build:src": "browserify --node --no-bundle-external --standalone ytSearch -t [ babelify --presets [ @babel/preset-env ] ] src/index.js -o dist/yt-search.js 2>&1 | wooster",
|
||||
"prepublishOnly": "npm test",
|
||||
"test:production": "node test/test.js | faucet",
|
||||
"test:util": "node test/test-get-scripts.js",
|
||||
"test:dev": "cross-env debug=1 test_yt_search=1 node test/test.js",
|
||||
"test": "npm run test:util && npm run build && npm run test:production"
|
||||
},
|
||||
"author": "talmobi <talmo.christian@gmail.com>",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/talmobi/yt-search"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/talmobi/yt-search/issues",
|
||||
"email": "talmo.christian@gmail.com"
|
||||
},
|
||||
"dependencies": {
|
||||
"async.parallellimit": "~0.5.2",
|
||||
"boolstring": "~1.0.2",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"dasu": "~0.4.2",
|
||||
"human-time": "0.0.2",
|
||||
"jsonpath-plus": "~5.0.2",
|
||||
"minimist": "~1.2.5",
|
||||
"node-fzf": "~0.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "~7.11.4",
|
||||
"@babel/preset-env": "~7.11.0",
|
||||
"@talmobi/faucet": "0.0.3",
|
||||
"babelify": "~10.0.0",
|
||||
"browserify": "~17.0.0",
|
||||
"cross-env": "~7.0.2",
|
||||
"looks-same-plus": "0.0.2",
|
||||
"spacestandard": "~0.3.0",
|
||||
"tape": "~5.0.1",
|
||||
"wooster": "~0.5.0"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue