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

ytpl

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ytpl - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

3

lib/firstpage.js

@@ -11,3 +11,3 @@ "use strict";

exports.get_firstpage = function(playlist_id, options, callback) {
https.get('https://www.youtube.com/playlist?list=' + playlist_id, function(resp) {
var request = https.get('https://www.youtube.com/playlist?list=' + playlist_id, function(resp) {
if(resp.statusCode != 200) {

@@ -48,2 +48,3 @@ return callback(new Error('Status code: ' + resp.statusCode));

});
request.on('error', callback);
};

@@ -8,7 +8,15 @@ "use strict";

module.exports = function(link_or_id, object_or_callback, callback) {
if(!callback) {
module.exports = function get_playlist(link_or_id, object_or_callback, callback) {
if(typeof(object_or_callback) == 'function') {
callback = object_or_callback;
object_or_callback = {};
}
if(!callback) {
return new Promise(function(resolve, reject) {
get_playlist(link_or_id, object_or_callback, function(err, info) {
if(err) return reject(err);
resolve(info);
});
});
}
util.get_playlist_id(link_or_id, function(err, playlist_id) {

@@ -15,0 +23,0 @@ var plist = {};

@@ -7,3 +7,6 @@ "use strict";

exports.get_nonfirstpage = function(nextpage_link, options, callback) {
https.get('https://www.youtube.com' + nextpage_link, function(resp) {
var request = https.get('https://www.youtube.com' + nextpage_link, function(resp) {
if(resp.statusCode != 200) {
return callback(new Error('Status code: ' + resp.statusCode));
}
var resp_string = '';

@@ -52,2 +55,3 @@ resp.on('data', function(d) {

});
request.on('error', callback);
};

@@ -15,2 +15,3 @@ "use strict";

var author_match = important_txt.match(author_reflink_regexp);
var description = exports.remove_html(exports.between(important_txt, '<span class="pl-header-description-text" tabindex="0">', '</span>').replace(/<button class="yt-uix-button[\s\S]+/, ''));
return {

@@ -21,3 +22,3 @@ id: plist_id,

visibility: important_txt.includes('data-tooltip-text="') ? 'link only' : 'everyone',
description: exports.remove_html(exports.between(important_txt, '<span class="pl-header-description-text" tabindex="0">', '</span>').replace(/<button class="yt-uix-button[\s\S]+/, '')),
description: description ? description : null,
views: author_match[2].split(' ')[0].replace('.', ''),

@@ -61,11 +62,2 @@ last_updated: author_match[3],

exports.remove_html = function(string) {
return new Entities().decode(
string.replace(/\n/g, ' ')
.replace(/\s*<\s*br\s*\/?\s*>\s*/gi, '\n')
.replace(/<\s*\/\s*p\s*>\s*<\s*p[^>]*>/gi, '\n')
.replace(/<.*?>/gi, '')
).trim();
};
var id_regex = /^[a-zA-Z0-9-_]{24,34}$/;

@@ -141,1 +133,10 @@ exports.get_playlist_id = function(link, callback) {

};
exports.remove_html = function(string) {
return new Entities().decode(
string.replace(/\n/g, ' ')
.replace(/\s*<\s*br\s*\/?\s*>\s*/gi, '\n')
.replace(/<\s*\/\s*p\s*>\s*<\s*p[^>]*>/gi, '\n')
.replace(/<.*?>/gi, '')
).trim();
};

@@ -8,3 +8,3 @@ {

],
"version": "0.0.3",
"version": "0.1.0",
"repository": {

@@ -11,0 +11,0 @@ "type": "git",

@@ -19,3 +19,3 @@ # node-ytpl

# API
### ytpl(id, [options,] callback)
### ytpl(id, [options, callback])

@@ -35,8 +35,15 @@ Attempts to resolve the given playlist id

* function
* getting fired after the request is done
* getting fired after the request is done
* contains an error or a result
* returns a Promise when no callback is defined
* [Example response](https://github.com/timeforaninja/node-ytpl/blob/master/example/example_output)
# Related / Works well with
* [node-ytdl-core](https://github.com/fent/node-ytdl-core)
* [node-ytsr](https://github.com/TimeForANinja/node-ytsr)
# Install

@@ -43,0 +50,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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