Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yt-search

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yt-search - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

5

bin/cli.js

@@ -16,2 +16,7 @@ #!/usr/bin/env node

if ( !query ) {
console.log( 'No search qeury given. Exiting.' )
return process.exit( 1 )
}
ytSearch(

@@ -18,0 +23,0 @@ query,

2

dist/yt-search.min.js

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.ytSearch=e()}}(function(){return function(){function e(t,n,r){function o(u,l){if(!n[u]){if(!t[u]){var s="function"==typeof require&&require;if(!l&&s)return s(u,!0);if(i)return i(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}return e}()({1:[function(e,t,n){"use strict";function r(e,t){function n(){for(var n=e.split(/\s+/),s=v+n.join("+"),a=[],f=function(e){var t=e;a.push(function(e){o(s,t,function(t,n){t?e(t):e(null,n)})})},c=r.pageStart;c<r.pageEnd;c++)f(c);d(a,function(e,n){if(e)t(e);else{n=[].concat.apply([],n);var r=n.filter(i),o=n.filter(u),s=n.filter(l);t(null,{videos:r,playlists:o,accounts:s})}})}var r=Object.assign({},h);r="string"==typeof e?Object.assign(r,{query:e}):Object.assign(r,e),e=r.query||r.search,n()}function o(e,t,n){e+="&page="+t;var r=g.parse(e);p.req(r,function(e,t,r){e?n(e):s(r,n)})}function i(e){return e.url.indexOf("watch")>=0&&e.url.indexOf("&list")===-1&&e.url.indexOf("&user")===-1}function u(e){return e.url.indexOf("list")>=0}function l(e){return e.url.indexOf("user")>=0}function s(e,t){for(var n=c.load(e),r=n(".yt-lockup-content"),o=[],i=0;i<r.length;i++){var u=r[i],l=n(".yt-lockup-title",u),s=n("a",l),f=n("span",l),p=a(f.text()),d=s.attr("href")||"",g=d.split("=")[1],v=n(".yt-lockup-meta-info",u),h=n("li",v),y=n(h[0]).text(),m=n(h[1]).text(),x=Number(m.split(" ")[0].split(",").join("").trim()),w={title:s.text(),url:d,videoId:g,seconds:Number(p.seconds),timestamp:p.timestamp,duration:p,ago:y,views:Number(x)};o.push(w)}t(null,o)}function a(e){for(var t=e.split(" "),n=t[t.length-1].replace(/[^:\d]/g,""),r=n.split(":"),o=0,i=0,u=r.length-1;u>=0;u--)if(!(r[u].length<=0)){var l=r[u].replace(/\D/g,"");if(o+=parseInt(l)*(i>0?Math.pow(60,i):1),i++,i>2)break}return{toString:function(){return o+" seconds ("+n+")"},seconds:o,timestamp:n}}function f(e){console.log("doing list search"),r(e,function(e,t){if(e)throw e;var n=t.videos,r=t.playlists,o=t.accounts;console.log("videos: "+n.length),console.log("playlists: "+r.length),console.log("accounts: "+o.length);for(var i=0;i<3;i++){var u=n[i],l=" ("+u.timestamp+")";console.log(u.title+l)}})}var c=e("cheerio"),p=e("dasu"),d=e("async.parallel"),g=e("url"),v="https://www.youtube.com/results?hl=en&gl=US&category=music&search_query=",h={pageStart:1,pageEnd:3};t.exports=function(e,t){r(e,t)},t.exports.search=r,e.main===t&&f("superman theme")},{"async.parallel":void 0,cheerio:void 0,dasu:void 0,url:void 0}]},{},[1])(1)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ytSearch=e()}}(function(){return function i(u,l,s){function a(t,e){if(!l[t]){if(!u[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(f)return f(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var o=l[t]={exports:{}};u[t][0].call(o.exports,function(e){return a(u[t][1][e]||e)},o,o.exports,i,u,l,s)}return l[t].exports}for(var f="function"==typeof require&&require,e=0;e<s.length;e++)a(s[e]);return a}({1:[function(e,t,n){"use strict";var r,x=e("cheerio"),s=e("dasu"),a=e("async.parallel"),f=e("url"),c="https://www.youtube.com/results?hl=en&gl=US&category=music&search_query=",o={pageStart:1,pageEnd:3};function i(i,u){var l=Object.assign({},o);if(!i)return u(new Error("No query given."));l="string"==typeof i?Object.assign(l,{query:i}):Object.assign(l,i),i=l.query||l.search,function(){for(var e=i.split(/\s+/),r=c+e.join("+"),n=[],t=function(e){var t=e;n.push(function(n){!function(e,t,r){e+="&page="+t;var n=f.parse(e);s.req(n,function(e,t,n){e?r(e):function(e,t){for(var n=x.load(e),r=n(".yt-lockup-content"),o=[],i=0;i<r.length;i++){var u=r[i],l=n(".yt-lockup-title",u),s=n("a",l),a=n("span",l),f=w(a.text()),c=s.attr("href")||"",p=c.split("=")[1],d=n(".yt-lockup-meta-info",u),g=n("li",d),v=n(g[0]).text(),h=n(g[1]).text(),y=Number(h.split(" ")[0].split(",").join("").trim()),m={title:s.text(),url:c,videoId:p,seconds:Number(f.seconds),timestamp:f.timestamp,duration:f,ago:v,views:Number(y)};o.push(m)}t(null,o)}(n,r)})}(r,t,function(e,t){e?n(e):n(null,t)})})},o=l.pageStart;o<l.pageEnd;o++)t(o);a(n,function(e,t){if(e)u(e);else{var n=(t=[].concat.apply([],t)).filter(p),r=t.filter(d),o=t.filter(g);u(null,{videos:n,playlists:r,accounts:o})}})}()}function p(e){return 0<=e.url.indexOf("watch")&&-1===e.url.indexOf("&list")&&-1===e.url.indexOf("&user")}function d(e){return 0<=e.url.indexOf("list")}function g(e){return 0<=e.url.indexOf("user")}function w(e){for(var t=e.split(" "),n=t[t.length-1].replace(/[^:\d]/g,""),r=n.split(":"),o=0,i=0,u=r.length-1;0<=u;u--)if(!(r[u].length<=0)){var l=r[u].replace(/\D/g,"");if(o+=parseInt(l)*(0<i?Math.pow(60,i):1),2<++i)break}return{toString:function(){return o+" seconds ("+n+")"},seconds:o,timestamp:n}}t.exports=function(e,t){i(e,t)},t.exports.search=i,e.main===t&&(r="superman theme",console.log("doing list search"),i(r,function(e,t){if(e)throw e;var n=t.videos,r=t.playlists,o=t.accounts;console.log("videos: "+n.length),console.log("playlists: "+r.length),console.log("accounts: "+o.length);for(var i=0;i<3;i++){var u=n[i],l=" ("+u.timestamp+")";console.log(u.title+l)}}))},{"async.parallel":void 0,cheerio:void 0,dasu:void 0,url:void 0}]},{},[1])(1)});
{
"name": "yt-search",
"version": "0.1.4",
"version": "0.2.0",
"description": "search youtube",

@@ -17,3 +17,4 @@ "main": "dist/yt-search.min.js",

"uglify": "uglifyjs dist/yt-search.js -cmo dist/yt-search.min.js",
"prepublish": "npm run build && npm test",
"prepare": "npm run build && npm test",
"prepublishOnly": "npm run build && npm test",
"test:production": "production=1 node test/test.js | faucet",

@@ -36,3 +37,3 @@ "test:dev": "node test/test.js | faucet",

"async.parallel": "~0.5.2",
"cheerio": "~0.19.0",
"cheerio": "~0.22.0",
"dasu": "0.0.23",

@@ -48,6 +49,7 @@ "minimist": "~1.2.0",

"faucet": "0.0.1",
"mocha": "^2.4.5",
"mocha": "~5.2.0",
"spacestandard": "~0.2.0",
"tape": "~4.9.0"
"tape": "~4.9.0",
"uglify-js": "~3.4.9"
}
}

@@ -1,8 +0,12 @@

# yt-search - simple youtube search API and CLI
[![npm](https://img.shields.io/npm/v/yt-search.svg?maxAge=3600&style=flat-square)](https://www.npmjs.com/package/yt-search)
[![npm](https://img.shields.io/npm/l/yt-search.svg?maxAge=3600&style=flat-square)](https://github.com/talmobi/yt-search/blob/master/LICENSE)
# yt-search
simple youtube search API and CLI
![](https://thumbs.gfycat.com/ContentShockingCuttlefish-size_restricted.gif)
## Simple to use
## Easy to use
### CLI usage
#### CLI usage
```bash

@@ -15,3 +19,3 @@ npm install -g yt-search

### API usage
#### API usage
```js

@@ -33,3 +37,3 @@ const ytSearch = require( 'yt-search' )

### Output
#### Output
```js

@@ -52,9 +56,9 @@ {

# About
Simple api to search youtube results.
## About
Simple function to get youtube search results.
# Why
## Why
Not sure..
# How
## How
Using HTTP requests and parsing the results with [cheerio](https://github.com/cheeriojs/cheerio).

@@ -64,3 +68,3 @@

# API
## Usage
```bash

@@ -87,5 +91,5 @@

# Installation
## Installation
```bash
npm install yt-search # local API usage
npm install yt-search # local module usage
```

@@ -97,1 +101,5 @@

## Test
```
npm test
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc