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 1.0.1 to 1.0.2

2

dist/yt-search.min.js

@@ -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"),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)});
!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 a(o,l,u){function s(e,t){if(!l[e]){if(!o[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:{}};o[e][0].call(i.exports,function(t){return s(o[e][1][t]||t)},i,i.exports,a,o,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"),f=t("url"),U=t("querystring"),O=t("human-time"),i="https://www.youtube.com/results?",d={YT_SEARCH_QUERY_URI:"",hl:"en",gl:"US",category:"",pageStart:1,pageEnd:3};function o(o,l){var u=Object.assign({},d);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=f.parse(r);c.req(i,function(t,e,r){if(t)n(t);else{if(200!==e.status)return n("http status: "+e.status);try{!function(t,e){var r=N.load(t),n=r("#content"),i=r("meta[itemprop=videoId]",n).attr("content");if(!i)return e("video unavailable");var o="",l="",u="",s="",c="",p="",f=r('link[href*="/user/"]',n)||r('a[href*="/user/"]');if(f){var d=f.attr("href")||"";d&&(u=d.split("/").pop(),s="https://youtube.com/user/"+u)}c=r(".yt-user-info a").text().trim();var m=r('link[href*="/channel/"]',n)||r('a[href*="/channel/"');if(o=r("meta[itemprop=channelId]",n).attr("content"),l="https://youtube.com/channel/"+o,m){var h=m.attr("href")||"";h&&(o=h.split("/").pop(),l="https://youtube.com/channel/"+o)}var v="https://i.ytimg.com/vi/"+i+"/default.jpg",y="https://i.ytimg.com/vi/"+i+"/hqdefault.jpg",g=r('script[type="application/ld+json"]').text();try{var b=JSON.parse(g);p=b.itemListElement[0].item.name}catch(t){}var x="",w=r("meta[itemprop=duration]",n).attr("content");w&&(x=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}}(w));if(!x){var I=t.match(/approxDurationMs.*?(\d+)/);if(I&&I[1]){var U=I[1],k=function(t){var e="",r=t/36e5,n=t/6e4%60,i=t/36e5%60;r&&(e+=r+":");n&&(e+=n+":");String(i).length<2&&(e+="0");return e+=i}(U);x=q(k)}}var S=r("meta[itemprop=uploadDate]",n).attr("content"),j={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(x.seconds),timestamp:x.timestamp,duration:x,views:Number(r("meta[itemprop=interactionCount]",n).attr("content")),genre:r("meta[itemprop=genre]",n).attr("content").toLowerCase(),uploadDate:S,ago:O(new Date(S)),thumbnail:v,image:y,author:{name:p||c,id:u||o,url:s||l,userId:u,userName:c,userUrl:s,channelId:o,channelName:p,channelUrl:l}};e(null,j)}(r,n)}catch(t){n(t)}}})}(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=f.parse(r);c.req(i,function(t,e,r){if(t)n(t);else{if(200!==e.status)return n("http status: "+e.status);try{!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"),a=r(".pl-header-title",i).text().trim(),o=r("#pl-header").attr("data-full-list-id"),l=r(".pl-header-details",i),u=r("li",l),s=D(r("a",u[0])),c=r(u[1]).text().trim(),p=Number(c.replace(/\D+/g,"")),f=r(u[2]).text().trim(),d=Number(f.replace(/\D+/g,"")),m=function(t){for(var e=t.trim().split(/[\s.-]+/),r=0;r<e.length;r++){var n=e.slice(r),i=n.join(" "),a=n.reverse().join(" "),o=new Date(i),l=new Date(a);if("Invalid Date"!==o.toString())return C(o);if("Invalid Date"!==l.toString())return C(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="+o,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=D(k);v.push({title:b,videoId:x,listId:o,url:w,thumbnailUrl:I,thumbnailUrlHQ:U,owner:S.name,author:S})}var j={title:a,listId:o,url:"https://www.youtube.com/playlist?hl=en&list="+o,videoCount:p,views:Number(d),lastUpdate:m,thumbnail:n,items:v,author:s};e(null,j)}(r,n)}catch(t){n(t)}}})}(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=f.parse(t);c.req(r,function(t,e,r){if(t)n(t);else{if(200!==e.status)return n("http status: "+e.status);try{!function(t,e){for(var r=N.load(t),n=r(".yt-lockup"),i=[],a=[],o=0;o<n.length;o++){var l=n[o],u=r(".yt-lockup-content",l),s=r(".yt-lockup-title",u),c=r("a",s),p=r("span",s),f=(q(p.text()),c.attr("href")||""),d=U.parse(f.split("?",2)[1]);if(0===f.indexOf("/watch?")||0===f.indexOf("/user/")||0===f.indexOf("/channel/")){var m=d.v,h=d.list,v="unknown";m&&(v="video"),h&&(v="list"),(0<=f.indexOf("/channel/")||0<=f.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,a.push(y))}}if(i.length)return e(i,a);e(null,a)}(r,n)}catch(t){n(t)}}})}(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(m),a=r.filter(v),o=r.filter(y);l(null,{videos:i.filter(h),playlists:a,lists:a,accounts:o,channels:o})}})}()}function m(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),a=q(t("span",n).text()),o=i.attr("href")||"",l=U.parse(o.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(),f=t(c[1]).text(),d=Number(f.split(" ")[0].split(",").join("").trim()),m="",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&&(m=(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(a.seconds),timestamp:a.timestamp,duration:a,views:Number(d),thumbnail:x,image:w,ago:p,author:{name:y||h,id:v||m,url:g.attr("href")||b.attr("href"),userId:v,userName:y,userUrl:g.attr("href")||"",channelId:m,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(),a=n.attr("href"),o=U.parse(a.split("?",2)[1]),l=o.list,u=o.v,s="",c="",p="",f="",d="",m="",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/")&&(d="https://youtube.com/user/"+(f=y.split("/").pop()),m=v.text().trim())):m=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:m||p,id:f||s,url:d||c,userId:f,userUrl:d,userName:m,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)),a=(i.text().trim(),i.attr("href")||""),o="",l="",u="",s="",c="",p="";0<=a.indexOf("channel/")&&(l="https://youtube.com/channel/"+(o=a.split("/").pop()),u=i.text().trim()),0<=a.indexOf("user/")&&(c="https://youtube.com/user/"+(s=a.split("/").pop()),p=i.text().trim());var f,d,m,h=t(".yt-lockup-meta-info",n).text().trim(),v=Number(h.replace(/\D+/g,"")),y=t(".yt-lockup-description",n).text().trim();return(d="url")in(f={type:"channel",title:p||u,description:y,url:m=c||l,videoCountLabel:h,videoCount:v,thumbnail:r,name:p||u,id:s||o})?Object.defineProperty(f,d,{value:m,enumerable:!0,configurable:!0,writable:!0}):f[d]=m,f}function q(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,a=0,o=n.length-1;0<=o;o--)if(!(n[o].length<=0)){var l=n[o].replace(/\D/g,"");if(i+=parseInt(l)*(0<a?Math.pow(60,a):1),2<++a)break}return{toString:function(){return i+" seconds ("+r+")"},seconds:i,timestamp:r}}function D(t){var e="",r="",n="",i="",a="",o="",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/")&&(a="https://youtube.com/user/"+(i=l.split("/").pop()),o=t.text().trim()),{name:o||n,id:i||e,url:a||r,channelId:e,channelUrl:r,channelUrlText:n,userId:i,userUrl:a,userUrlText:o}):{}}function C(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 a=0;a<3;a++){var o=r[a],l=" ("+o.timestamp+")";console.log(o.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.1",
"version": "1.0.2",
"description": "search youtube",

@@ -5,0 +5,0 @@ "main": "dist/yt-search.min.js",

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