Comparing version 1.0.0 to 1.0.1
@@ -57,3 +57,2 @@ #!/usr/bin/env node | ||
var url = ( | ||
'https://www.youtube.com' + | ||
videos[ r.selected.index ].url | ||
@@ -60,0 +59,0 @@ ) |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ytSearch=t()}}(function(){return function o(a,l,u){function s(e,t){if(!l[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=l[e]={exports:{}};a[e][0].call(i.exports,function(t){return s(a[e][1][t]||t)},i,i.exports,o,a,l,u)}return l[e].exports}for(var c="function"==typeof require&&require,t=0;t<u.length;t++)s(u[t]);return s}({1:[function(t,e,r){"use strict";var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};var n,N=t("cheerio"),c=t("dasu"),p=t("async.parallellimit"),d=t("url"),U=t("querystring"),I=t("human-time"),i="https://www.youtube.com/results?",m={YT_SEARCH_QUERY_URI:"",hl:"en",gl:"US",category:"",pageStart:1,pageEnd:3};function o(o,l){var u=Object.assign({},m);if(!o)return l(new Error("No query given."));if(!(u="string"==typeof o?Object.assign(u,{query:o}):Object.assign(u,o)).YT_SEARCH_QUERY_URI){var t=i,e=u.hl||u.language||u.lang;e&&(t+="&hl="+e.slice(0,2)),u.gl&&(t+="&gl="+u.gl),u.category&&(t+="&category="+u.category),u.YT_SEARCH_QUERY_URI=t}if(u.videoId)return function(t,w){var e=void 0;"string"==typeof t&&(e=t);"object"===(void 0===t?"undefined":s(t))&&(e=t.videoId);var r="https://www.youtube.com/watch?hl=en&v="+e,n=d.parse(r);c.req(n,function(t,e,r){var n,i,o,l,u,s,c,p,d,m,f,h,v,y,g,b,x;t?w(t):(n=r,i=w,o=N.load(n),l=o("#content"),u=o("meta[itemprop=videoId]",l).attr("content"),s=o('link[href*="/user/"]',l).attr("href").split("/").pop(),c=o(".yt-user-info a").text().trim(),p="https://youtube.com/user/"+s,o('link[href*="/channel/"]',l),d=o("meta[itemprop=channelId]",l).attr("content"),m="https://youtube.com/channel/"+d,f="https://i.ytimg.com/vi/"+u+"/default.jpg",h="https://i.ytimg.com/vi/"+u+"/hqdefault.jpg",v=o('script[type="application/ld+json"]').text(),y=JSON.parse(v).itemListElement[0].item.name,g=function(t){var e=t.slice(0,2),r=t.slice(2).toUpperCase();if("PT"!==e)return{toString:function(){return a[0]},seconds:0,timestamp:0};var n=r.match(/\d?\dH/),i=r.match(/\d?\dM/),o=r.match(/\d?\dS/);n=n&&n[0].slice(0,-1)||0,i=i&&i[0].slice(0,-1)||0,o=o&&o[0].slice(0,-1)||0,n=parseInt(n),i=parseInt(i),o=parseInt(o),r="",n&&(r+=n+":");i&&(r+=i+":");var l=60*n*60+60*i+o;return{toString:function(){return l+" seconds ("+r+")"},seconds:l,timestamp:r+=o}}(o("meta[itemprop=duration]",l).attr("content")),b=o("meta[itemprop=uploadDate]",l).attr("content"),x={title:o("meta[itemprop=name]",l).attr("content"),description:o("meta[itemprop=description]",l).attr("content"),url:o("link[itemprop=url]",l).attr("href"),videoId:u,seconds:Number(g.seconds),timestamp:g.timestamp,duration:g,views:Number(o("meta[itemprop=interactionCount]",l).attr("content")),genre:o("meta[itemprop=genre]",l).attr("content").toLowerCase(),uploadDate:b,ago:I(new Date(b)),thumbnail:f,image:h,author:{name:y||c,id:s||d,url:p||m,userId:s,userName:c,userUrl:p,channelId:d,channelName:y,channelUrl:m}},i(null,x))})}(u.videoId,l);if(u.listId)return function(t,n){var e=void 0;"string"==typeof t&&(e=t);"object"===(void 0===t?"undefined":s(t))&&(e=t.listId||t.playlistId);var r="https://www.youtube.com/playlist?hl=en&list="+e,i=d.parse(r);c.req(i,function(t,e,r){t?n(t):function(t,e){for(var r=N.load(t),n=r(".pl-header-thumb img").attr("src").split("?",2)[0],i=r(".pl-header-content"),o=r(".pl-header-title",i).text().trim(),a=r("#pl-header").attr("data-full-list-id"),l=r(".pl-header-details",i),u=r("li",l),s=O(r("a",u[0])),c=r(u[1]).text().trim(),p=Number(c.replace(/\D+/g,"")),d=r(u[2]).text().trim(),m=Number(d.replace(/\D+/g,"")),f=function(t){for(var e=t.trim().split(/[\s.-]+/),r=0;r<e.length;r++){var n=e.slice(r),i=n.join(" "),o=n.reverse().join(" "),a=new Date(i),l=new Date(o);if("Invalid Date"!==a.toString())return q(a);if("Invalid Date"!==l.toString())return q(l)}return""}(r(u[3]).text().trim()),h=r("#pl-load-more-destination .pl-video"),v=[],y=0;y<h.length;y++){var g=h[y],b=r(g).attr("data-title"),x=r(g).attr("data-video-id"),w="https://youtube.com/watch?v="+x+"&list="+a,I="https://i.ytimg.com/vi/"+x+"/default.jpg",U="https://i.ytimg.com/vi/"+x+"/hqdefault.jpg",k=r(".pl-video-owner a",g),S=O(k);v.push({title:b,videoId:x,listId:a,url:w,thumbnailUrl:I,thumbnailUrlHQ:U,owner:S.name,author:S})}var j={title:o,listId:a,url:"https://www.youtube.com/playlist?hl=en&list="+a,videoCount:p,views:Number(m),lastUpdate:f,thumbnail:n,items:v,author:s};e(null,j)}(r,n)})}(u.listId,l);o=u.query||u.search,function(){for(var t=U.escape(o).split(/\s+/),n=u.YT_SEARCH_QUERY_URI+"&search_query="+t.join("+"),r=[],e=function(t){var e=t;r.push(function(r){!function(t,e,n){t+="&page="+e;var r=d.parse(t);c.req(r,function(t,e,r){t?n(t):function(t,e){for(var r=N.load(t),n=r(".yt-lockup"),i=[],o=[],a=0;a<n.length;a++){var l=n[a],u=r(".yt-lockup-content",l),s=r(".yt-lockup-title",u),c=r("a",s),p=r("span",s),d=(k(p.text()),c.attr("href")||""),m=U.parse(d.split("?",2)[1]);if(0===d.indexOf("/watch?")||0===d.indexOf("/user/")||0===d.indexOf("/channel/")){var f=m.v,h=m.list,v="unknown";f&&(v="video"),h&&(v="list"),(0<=d.indexOf("/channel/")||0<=d.indexOf("/user/"))&&(v="channel");var y=void 0;try{switch(v){case"video":y=g(r,l);break;case"list":y=b(r,l);break;case"channel":y=x(r,l)}}catch(t){i.push(t)}y&&(y.type=v,o.push(y))}}if(i.length)return e(i,o);e(null,o)}(r,n)})}(n,e,function(t,e){t?r(t):r(null,e)})})},i=u.pageStart;i<u.pageEnd;i++)e(i);p(r,3,function(t,e){if(t)l(t);else{for(var r=[],n=0;n<e.length;n++)r=r.concat(e[0]);var i=r.filter(f),o=r.filter(v),a=r.filter(y);l(null,{videos:i.filter(h),playlists:o,lists:o,accounts:a,channels:a})}})}()}function f(t){return"video"===t.type}function h(t,e,r){var n=t.videoId;return r.findIndex(function(t){return n===t.videoId})===e}function v(t){return"list"===t.type}function y(t){return"channel"===t.type}function g(t,e){var r=t(".yt-lockup-content",e),n=t(".yt-lockup-title",r),i=t("a",n),o=k(t("span",n).text()),a=i.attr("href")||"",l=U.parse(a.split("?",2)[1]),u=l.v,s=(l.list,t(".yt-lockup-description",r).text().trim()),c=t("li",t(".yt-lockup-meta-info",r)),p=t(c[0]).text(),d=t(c[1]).text(),m=Number(d.split(" ")[0].split(",").join("").trim()),f=t('a[href^="/user/"]',r),h=(f.attr("href")||"").replace("/user/",""),v=f.text().trim(),y=t('a[href^="/channel/"]',r),g=(y.attr("href")||"").replace("/channel/",""),b=y.text().trim();var x="https://i.ytimg.com/vi/"+u+"/default.jpg",w="https://i.ytimg.com/vi/"+u+"/hqdefault.jpg";return{type:"video",title:i.text().trim(),description:s,url:"https://youtube.com/watch?v="+u,videoId:u,seconds:Number(o.seconds),timestamp:o.timestamp,duration:o,views:Number(m),thumbnail:x,image:w,ago:p,author:{name:v||b,id:h||g,url:f.attr("href")||y.attr("href"),userId:h,userName:v,userUrl:f.attr("href")||"",channelId:g,channelUrl:y.attr("href")||"",channelName:b}}}function b(t,e){var r=t(".yt-lockup-content",e),n=t("a",t(".yt-lockup-title",r)),i=n.text().trim(),o=n.attr("href"),a=U.parse(o.split("?",2)[1]),l=a.list,u=a.v,s="",c="",p="",d="",m="",f="",h=t(".yt-lockup-byline",r),v=t("a",h),y=v.attr("href");y?(0<=y.indexOf("channel/")&&(c="https://youtube.com/channel/"+(s=y.split("/").pop()),p=v.text().trim()),0<=y.indexOf("user/")&&(m="https://youtube.com/user/"+(d=y.split("/").pop()),f=v.text().trim())):f=h.text().trim();var g=t(".sidebar",e).text().trim(),b=Number(g.replace(/\D+/g,"")),x=t("a",t("li.yt-lockup-playlist-item",r)[0]).attr("href"),w=U.parse(x.split("?",2)[1]).v,I=u||w;return{type:"list",title:i,url:"https://youtube.com/playlist?list="+l,listId:l,videoCountLabel:g,videoCount:b,thumbnail:"https://i.ytimg.com/vi/"+I+"/default.jpg",image:"https://i.ytimg.com/vi/"+I+"/hqdefault.jpg",author:{name:f||p,id:d||s,url:m||c,userId:d,userUrl:m,userName:f,channelId:s,channelUrl:c,channelName:p}}}function x(t,e){var r="https:"+t("img",e).attr("src"),n=t(".yt-lockup-content",e),i=t("a",t(".yt-lockup-title",n)),o=(i.text().trim(),i.attr("href")),a="",l="",u="",s="",c="",p="";0<=o.indexOf("channel/")&&(l="https://youtube.com/channel/"+(a=o.split("/").pop()),u=i.text().trim()),0<=o.indexOf("user/")&&(c="https://youtube.com/user/"+(s=o.split("/").pop()),p=i.text().trim());var d,m,f,h=t(".yt-lockup-meta-info",n).text().trim(),v=Number(h.replace(/\D+/g,"")),y=t(".yt-lockup-description",n).text().trim();return(m="url")in(d={type:"channel",title:p||u,description:y,url:f=c||l,videoCountLabel:h,videoCount:v,thumbnail:r,name:p||u,id:s||a})?Object.defineProperty(d,m,{value:f,enumerable:!0,configurable:!0,writable:!0}):d[m]=f,d}function k(t){var e=t.split(/\s+/),r=e[e.length-1].replace(/[^:.\d]/g,"");if(!r)return{toString:function(){return e[0]},seconds:0,timestamp:0};for(;r[r.length-1].match(/\D/);)r=r.slice(0,-1);for(var n=(r=r.replace(/\./g,":")).split(/[:.]/),i=0,o=0,a=n.length-1;0<=a;a--)if(!(n[a].length<=0)){var l=n[a].replace(/\D/g,"");if(i+=parseInt(l)*(0<o?Math.pow(60,o):1),2<++o)break}return{toString:function(){return i+" seconds ("+r+")"},seconds:i,timestamp:r}}function O(t){var e="",r="",n="",i="",o="",a="",l=t.attr("href");return l?(0<=l.indexOf("channel/")&&(r="https://youtube.com/channel/"+(e=l.split("/").pop()),n=t.text().trim()),0<=l.indexOf("user/")&&(o="https://youtube.com/user/"+(i=l.split("/").pop()),a=t.text().trim()),{name:a||n,id:i||e,url:o||r,channelId:e,channelUrl:r,channelUrlText:n,userId:i,userUrl:o,userUrlText:a}):{}}function q(t){return t.getUTCFullYear()+"-"+t.getUTCMonth()+"-"+t.getUTCDate()}e.exports=function(t,e){o(t,e)},e.exports.search=o,t.main===e&&(n="superman theme list",console.log("doing list search"),o(n,function(t,e){if(t)throw t;var r=e.videos,n=e.playlists,i=e.accounts;console.log("videos: "+r.length),console.log("playlists: "+n.length),console.log("accounts: "+i.length);for(var o=0;o<3;o++){var a=r[o],l=" ("+a.timestamp+")";console.log(a.title+l)}n.forEach(function(t){})}))},{"async.parallellimit":void 0,cheerio:void 0,dasu:void 0,"human-time":void 0,querystring:void 0,url:void 0}]},{},[1])(1)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ytSearch=t()}}(function(){return function o(a,l,u){function s(e,t){if(!l[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=l[e]={exports:{}};a[e][0].call(i.exports,function(t){return s(a[e][1][t]||t)},i,i.exports,o,a,l,u)}return l[e].exports}for(var c="function"==typeof require&&require,t=0;t<u.length;t++)s(u[t]);return s}({1:[function(t,e,r){"use strict";var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};var n,N=t("cheerio"),c=t("dasu"),p=t("async.parallellimit"),d=t("url"),U=t("querystring"),x=t("human-time"),i="https://www.youtube.com/results?",m={YT_SEARCH_QUERY_URI:"",hl:"en",gl:"US",category:"",pageStart:1,pageEnd:3};function o(o,l){var u=Object.assign({},m);if(!o)return l(new Error("No query given."));if(!(u="string"==typeof o?Object.assign(u,{query:o}):Object.assign(u,o)).YT_SEARCH_QUERY_URI){var t=i,e=u.hl||u.language||u.lang;e&&(t+="&hl="+e.slice(0,2)),u.gl&&(t+="&gl="+u.gl),u.category&&(t+="&category="+u.category),u.YT_SEARCH_QUERY_URI=t}if(u.videoId)return function(t,n){var e=void 0;"string"==typeof t&&(e=t);"object"===(void 0===t?"undefined":s(t))&&(e=t.videoId);var r="https://www.youtube.com/watch?hl=en&v="+e,i=d.parse(r);c.req(i,function(t,e,r){t?n(t):function(t,e){var r=N.load(t),n=r("#content"),i=r("meta[itemprop=videoId]",n).attr("content"),o="",l="",u="",s="",c=r('link[href*="/user/"]',n);if(c){var p=c.attr("href")||"";p&&(u=p.split("/").pop(),s="https://youtube.com/user/"+u)}var d=r(".yt-user-info a").text().trim();r('link[href*="/channel/"]',n);o=r("meta[itemprop=channelId]",n).attr("content"),l="https://youtube.com/channel/"+o;var m="https://i.ytimg.com/vi/"+i+"/default.jpg",f="https://i.ytimg.com/vi/"+i+"/hqdefault.jpg",h=r('script[type="application/ld+json"]').text(),v=JSON.parse(h).itemListElement[0].item.name,y=function(t){var e=t.slice(0,2),r=t.slice(2).toUpperCase();if("PT"!==e)return{toString:function(){return a[0]},seconds:0,timestamp:0};var n=r.match(/\d?\dH/),i=r.match(/\d?\dM/),o=r.match(/\d?\dS/);n=n&&n[0].slice(0,-1)||0,i=i&&i[0].slice(0,-1)||0,o=o&&o[0].slice(0,-1)||0,n=parseInt(n),i=parseInt(i),o=parseInt(o),r="",n&&(r+=n+":");i&&(r+=i+":");var l=60*n*60+60*i+o;return{toString:function(){return l+" seconds ("+r+")"},seconds:l,timestamp:r+=o}}(r("meta[itemprop=duration]",n).attr("content")),g=r("meta[itemprop=uploadDate]",n).attr("content"),b={title:r("meta[itemprop=name]",n).attr("content"),description:r("meta[itemprop=description]",n).attr("content"),url:r("link[itemprop=url]",n).attr("href"),videoId:i,seconds:Number(y.seconds),timestamp:y.timestamp,duration:y,views:Number(r("meta[itemprop=interactionCount]",n).attr("content")),genre:r("meta[itemprop=genre]",n).attr("content").toLowerCase(),uploadDate:g,ago:x(new Date(g)),thumbnail:m,image:f,author:{name:v||d,id:u||o,url:s||l,userId:u,userName:d,userUrl:s,channelId:o,channelName:v,channelUrl:l}};e(null,b)}(r,n)})}(u.videoId,l);if(u.listId)return function(t,n){var e=void 0;"string"==typeof t&&(e=t);"object"===(void 0===t?"undefined":s(t))&&(e=t.listId||t.playlistId);var r="https://www.youtube.com/playlist?hl=en&list="+e,i=d.parse(r);c.req(i,function(t,e,r){t?n(t):function(t,e){for(var r=N.load(t),n=r(".pl-header-thumb img").attr("src").split("?",2)[0],i=r(".pl-header-content"),o=r(".pl-header-title",i).text().trim(),a=r("#pl-header").attr("data-full-list-id"),l=r(".pl-header-details",i),u=r("li",l),s=O(r("a",u[0])),c=r(u[1]).text().trim(),p=Number(c.replace(/\D+/g,"")),d=r(u[2]).text().trim(),m=Number(d.replace(/\D+/g,"")),f=function(t){for(var e=t.trim().split(/[\s.-]+/),r=0;r<e.length;r++){var n=e.slice(r),i=n.join(" "),o=n.reverse().join(" "),a=new Date(i),l=new Date(o);if("Invalid Date"!==a.toString())return q(a);if("Invalid Date"!==l.toString())return q(l)}return""}(r(u[3]).text().trim()),h=r("#pl-load-more-destination .pl-video"),v=[],y=0;y<h.length;y++){var g=h[y],b=r(g).attr("data-title"),x=r(g).attr("data-video-id"),w="https://youtube.com/watch?v="+x+"&list="+a,I="https://i.ytimg.com/vi/"+x+"/default.jpg",U="https://i.ytimg.com/vi/"+x+"/hqdefault.jpg",k=r(".pl-video-owner a",g),S=O(k);v.push({title:b,videoId:x,listId:a,url:w,thumbnailUrl:I,thumbnailUrlHQ:U,owner:S.name,author:S})}var j={title:o,listId:a,url:"https://www.youtube.com/playlist?hl=en&list="+a,videoCount:p,views:Number(m),lastUpdate:f,thumbnail:n,items:v,author:s};e(null,j)}(r,n)})}(u.listId,l);o=u.query||u.search,function(){for(var t=U.escape(o).split(/\s+/),n=u.YT_SEARCH_QUERY_URI+"&search_query="+t.join("+"),r=[],e=function(t){var e=t;r.push(function(r){!function(t,e,n){t+="&page="+e;var r=d.parse(t);c.req(r,function(t,e,r){t?n(t):function(t,e){for(var r=N.load(t),n=r(".yt-lockup"),i=[],o=[],a=0;a<n.length;a++){var l=n[a],u=r(".yt-lockup-content",l),s=r(".yt-lockup-title",u),c=r("a",s),p=r("span",s),d=(I(p.text()),c.attr("href")||""),m=U.parse(d.split("?",2)[1]);if(0===d.indexOf("/watch?")||0===d.indexOf("/user/")||0===d.indexOf("/channel/")){var f=m.v,h=m.list,v="unknown";f&&(v="video"),h&&(v="list"),(0<=d.indexOf("/channel/")||0<=d.indexOf("/user/"))&&(v="channel");var y=void 0;try{switch(v){case"video":y=g(r,l);break;case"list":y=b(r,l);break;case"channel":y=w(r,l)}}catch(t){i.push(t)}y&&(y.type=v,o.push(y))}}if(i.length)return e(i,o);e(null,o)}(r,n)})}(n,e,function(t,e){t?r(t):r(null,e)})})},i=u.pageStart;i<u.pageEnd;i++)e(i);p(r,3,function(t,e){if(t)l(t);else{for(var r=[],n=0;n<e.length;n++)r=r.concat(e[0]);var i=r.filter(f),o=r.filter(v),a=r.filter(y);l(null,{videos:i.filter(h),playlists:o,lists:o,accounts:a,channels:a})}})}()}function f(t){return"video"===t.type}function h(t,e,r){var n=t.videoId;return r.findIndex(function(t){return n===t.videoId})===e}function v(t){return"list"===t.type}function y(t){return"channel"===t.type}function g(t,e){var r=t(".yt-lockup-content",e),n=t(".yt-lockup-title",r),i=t("a",n),o=I(t("span",n).text()),a=i.attr("href")||"",l=U.parse(a.split("?",2)[1]),u=l.v,s=(l.list,t(".yt-lockup-description",r).text().trim()),c=t("li",t(".yt-lockup-meta-info",r)),p=t(c[0]).text(),d=t(c[1]).text(),m=Number(d.split(" ")[0].split(",").join("").trim()),f="",h="",v="",y="",g=t('a[href^="/user/"]',r);g&&(v=(g.attr("href")||"").replace("/user/","").trim(),y=g.text().trim());var b=t('a[href^="/channel/"]',r);b&&(f=(b.attr("href")||"").replace("/channel/","").trim(),h=b.text().trim());var x="https://i.ytimg.com/vi/"+u+"/default.jpg",w="https://i.ytimg.com/vi/"+u+"/hqdefault.jpg";return{type:"video",title:i.text().trim(),description:s,url:"https://youtube.com/watch?v="+u,videoId:u,seconds:Number(o.seconds),timestamp:o.timestamp,duration:o,views:Number(m),thumbnail:x,image:w,ago:p,author:{name:y||h,id:v||f,url:g.attr("href")||b.attr("href"),userId:v,userName:y,userUrl:g.attr("href")||"",channelId:f,channelUrl:b.attr("href")||"",channelName:h}}}function b(t,e){var r=t(".yt-lockup-content",e),n=t("a",t(".yt-lockup-title",r)),i=n.text().trim(),o=n.attr("href"),a=U.parse(o.split("?",2)[1]),l=a.list,u=a.v,s="",c="",p="",d="",m="",f="",h=t(".yt-lockup-byline",r),v=t("a",h),y=v.attr("href")||"";y?(0<=y.indexOf("channel/")&&(c="https://youtube.com/channel/"+(s=y.split("/").pop()),p=v.text().trim()),0<=y.indexOf("user/")&&(m="https://youtube.com/user/"+(d=y.split("/").pop()),f=v.text().trim())):f=h.text().trim();var g=t(".sidebar",e).text().trim(),b=Number(g.replace(/\D+/g,"")),x=t("a",t("li.yt-lockup-playlist-item",r)[0]).attr("href"),w=U.parse(x.split("?",2)[1]).v,I=u||w;return{type:"list",title:i,url:"https://youtube.com/playlist?list="+l,listId:l,videoCountLabel:g,videoCount:b,thumbnail:"https://i.ytimg.com/vi/"+I+"/default.jpg",image:"https://i.ytimg.com/vi/"+I+"/hqdefault.jpg",author:{name:f||p,id:d||s,url:m||c,userId:d,userUrl:m,userName:f,channelId:s,channelUrl:c,channelName:p}}}function w(t,e){var r="https:"+t("img",e).attr("src"),n=t(".yt-lockup-content",e),i=t("a",t(".yt-lockup-title",n)),o=(i.text().trim(),i.attr("href")||""),a="",l="",u="",s="",c="",p="";0<=o.indexOf("channel/")&&(l="https://youtube.com/channel/"+(a=o.split("/").pop()),u=i.text().trim()),0<=o.indexOf("user/")&&(c="https://youtube.com/user/"+(s=o.split("/").pop()),p=i.text().trim());var d,m,f,h=t(".yt-lockup-meta-info",n).text().trim(),v=Number(h.replace(/\D+/g,"")),y=t(".yt-lockup-description",n).text().trim();return(m="url")in(d={type:"channel",title:p||u,description:y,url:f=c||l,videoCountLabel:h,videoCount:v,thumbnail:r,name:p||u,id:s||a})?Object.defineProperty(d,m,{value:f,enumerable:!0,configurable:!0,writable:!0}):d[m]=f,d}function I(t){var e=t.split(/\s+/),r=e[e.length-1].replace(/[^:.\d]/g,"");if(!r)return{toString:function(){return e[0]},seconds:0,timestamp:0};for(;r[r.length-1].match(/\D/);)r=r.slice(0,-1);for(var n=(r=r.replace(/\./g,":")).split(/[:.]/),i=0,o=0,a=n.length-1;0<=a;a--)if(!(n[a].length<=0)){var l=n[a].replace(/\D/g,"");if(i+=parseInt(l)*(0<o?Math.pow(60,o):1),2<++o)break}return{toString:function(){return i+" seconds ("+r+")"},seconds:i,timestamp:r}}function O(t){var e="",r="",n="",i="",o="",a="",l=t.attr("href");return l?(0<=l.indexOf("channel/")&&(r="https://youtube.com/channel/"+(e=l.split("/").pop()),n=t.text().trim()),0<=l.indexOf("user/")&&(o="https://youtube.com/user/"+(i=l.split("/").pop()),a=t.text().trim()),{name:a||n,id:i||e,url:o||r,channelId:e,channelUrl:r,channelUrlText:n,userId:i,userUrl:o,userUrlText:a}):{}}function q(t){return t.getUTCFullYear()+"-"+t.getUTCMonth()+"-"+t.getUTCDate()}e.exports=function(t,e){o(t,e)},e.exports.search=o,t.main===e&&(n="superman theme list",console.log("doing list search"),o(n,function(t,e){if(t)throw t;var r=e.videos,n=e.playlists,i=e.accounts;console.log("videos: "+r.length),console.log("playlists: "+n.length),console.log("accounts: "+i.length);for(var o=0;o<3;o++){var a=r[o],l=" ("+a.timestamp+")";console.log(a.title+l)}n.forEach(function(t){})}))},{"async.parallellimit":void 0,cheerio:void 0,dasu:void 0,"human-time":void 0,querystring:void 0,url:void 0}]},{},[1])(1)}); |
{ | ||
"name": "yt-search", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "search youtube", | ||
@@ -17,3 +17,2 @@ "main": "dist/yt-search.min.js", | ||
"uglify": "uglifyjs dist/yt-search.js -cmo dist/yt-search.min.js", | ||
"prepare": "npm run build && npm test", | ||
"prepublishOnly": "npm run build && npm test", | ||
@@ -20,0 +19,0 @@ "test:production": "cross-env production=1 node test/test.js | faucet", |
24422
45