Comparing version 0.0.2 to 0.1.0
@@ -6,2 +6,4 @@ #!/usr/bin/env node | ||
var nfzf = require( 'node-fzf' ) | ||
var ytSearch = require( | ||
@@ -17,10 +19,33 @@ path.join( __dirname, '../dist/yt-search.min.js' ) | ||
query, | ||
function ( err, list ) { | ||
function ( err, r ) { | ||
if ( err ) throw err | ||
for ( var i = 0; i < list.length; i++ ) { | ||
var song = list[ i ] | ||
console.log( song.title + ' : ' + song.duration ) | ||
console.log( '---------------' ) | ||
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 | ||
) | ||
list.push( text ) | ||
} | ||
nfzf( list, function ( val, ind ) { | ||
console.log( val ) | ||
var url = ( | ||
'https://www.youtube.com' + | ||
videos[ ind ].url | ||
) | ||
console.log( url ) | ||
} ) | ||
} | ||
) |
@@ -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 n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.ytSearch=e()}}(function(){return function(){function e(n,t,o){function r(u,l){if(!t[u]){if(!n[u]){var s="function"==typeof require&&require;if(!l&&s)return s(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var a=t[u]={exports:{}};n[u][0].call(a.exports,function(e){var t=n[u][1][e];return r(t?t:e)},a,a.exports,e,n,t,o)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}return e}()({1:[function(e,n,t){"use strict";function o(e){for(key in e)m[key]=e[key]}function r(e){return e.replace(/\W/g)}function i(e,n){function t(){if(o)return console.log("responding from cache"),n(null,o);for(var t=e.split(/\s+/),r=d+t.join("+"),i=7,l=[],s=function(e){l.push(function(n){var t=e;u(r,t,function(e,t){e?n(e):n(null,t)})})},f=1;f<i;f++)s(f);c(l,function(e,t){if(e)n(e);else{var o=[].concat.apply([],t);console.log("async query completed ["+i+"], found: "+o.length+" songs"),n(null,o)}})}console.log("query: "+e);var o,i=r(e),l=h[i];if(l){var s=Date.now()-l.time;s<y?o=l.data:delete h[i]}t()}function u(e,n,t){e+="&page="+n,console.log("finding songs from: "+e);var o=p.parse(e);a(o,function(e,n,o){e?t(e):l(o,t)})}function l(e,n){for(var t=f.load(e),o=t(".yt-lockup-content"),r=[],i=0;i<o.length;i++){var u=o[i],l=t(".yt-lockup-title",u),a=t("a",l),c=t("span",l),p=s(c.text()),d=a.attr("href"),g=t(".yt-lockup-meta-info",u),v=t("li",g),y=t(v[0]).text(),h=t(v[1]).text(),m=Number(h.split(" ")[0].split(",").join("").trim()),w={title:a.text(),url:d,duration:p,ago:y,views:m};console.log('"'+w.title+'" views: '+w.views),r.push(w)}n(null,r)}function s(e){for(var n=e.split(" "),t=n[n.length-1].replace(/[^:\d]/g,""),o=t.split(":"),r=0,i=0,u=o.length-1;u>=0;u--)if(!(o[u].length<=0)){var l=o[u].replace(/\D/g,"");if(r+=parseInt(l)*(i>0?Math.pow(60,i):1),i++,i>2)break}return{toString:function(){return r+" seconds ("+t+")"},seconds:r,timestamp:t}}var f=e("cheerio"),a=e("dasu").req,c=e("async.parallel"),p=e("url"),d="https://www.youtube.com/results?hl=en&gl=US&category=music";d+="&search_query=";var g=1e3,v=60*g,y=5*v,h={},m={min_results:80,min_requests:3,max_requests:8,ignore_playlists:!0,ignore_accounts:!0,only_videos:!0};n.exports=function(e,n,t){i(e,n,t)},n.exports.opts=o,n.exports.search=i},{"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{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 c=n[u]={exports:{}};t[u][0].call(c.exports,function(e){var n=t[u][1][e];return o(n?n:e)},c,c.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=[],c=function(e){var t=e;a.push(function(e){o(s,t,function(t,n){t?e(t):e(null,n)})})},f=r.pageStart;f<r.pageEnd;f++)c(f);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}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=f.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),c=n("span",l),p=a(c.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 c(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 f=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&&c("superman theme")},{"async.parallel":void 0,cheerio:void 0,dasu:void 0,url:void 0}]},{},[1])(1)}); |
{ | ||
"name": "yt-search", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "search youtube", | ||
@@ -28,3 +28,4 @@ "main": "index.js", | ||
"dasu": "0.0.23", | ||
"minimist": "~1.2.0" | ||
"minimist": "~1.2.0", | ||
"node-fzf": "0.0.4" | ||
}, | ||
@@ -31,0 +32,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4977
36
5
+ Addednode-fzf@0.0.4
+ Addedansi-regex@2.1.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcli-color@1.2.0(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedd@1.0.2(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedes6-weak-map@2.0.3(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedis-promise@2.2.2(transitive)
+ Addedkeypress@0.2.1(transitive)
+ Addedlru-queue@0.1.0(transitive)
+ Addedmemoizee@0.4.17(transitive)
+ Addedminimatch@3.0.8(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addednode-fzf@0.0.4(transitive)
+ Addedredstar@0.0.2(transitive)
+ Addedtimers-ext@0.1.8(transitive)
+ Addedttys@0.0.3(transitive)
+ Addedtype@2.7.3(transitive)