Comparing version 2.1.0 to 2.1.1
@@ -26,3 +26,3 @@ const URL = require('url'); | ||
let error = parsed.json.alerts.find(a => a.alertRenderer && a.alertRenderer.type === 'ERROR'); | ||
if (error) throw new Error(`API-Error: ${UTIL.parseText(error.alertRenderer.text)}`); | ||
if (error) throw new Error(`API-Error: ${UTIL.parseText(error.alertRenderer.text, '* no message *')}`); | ||
} | ||
@@ -48,3 +48,3 @@ | ||
url: `${BASE_PLIST_URL}list=${plistId}`, | ||
title: UTIL.parseText(info.title), | ||
title: UTIL.parseText(info.title, ''), | ||
estimatedItemCount: UTIL.parseIntegerFromText(info.stats[0]), | ||
@@ -54,3 +54,3 @@ views: info.stats.length === 3 ? UTIL.parseIntegerFromText(info.stats[1]) : 0, | ||
bestThumbnail: thumbnails[0], | ||
lastUpdated: UTIL.parseText(info.stats[2]), | ||
lastUpdated: UTIL.parseText(info.stats[2], ''), | ||
description: Array.isArray(info.description) && info.description.length ? UTIL.parseText(info.description) : null, | ||
@@ -57,0 +57,0 @@ visibility: info.badges && JSON.stringify(info.badges).includes('UNLISTED') ? 'unlisted' : 'everyone', |
@@ -24,3 +24,3 @@ const PATH = require('path'); | ||
return { | ||
title: UTIL.parseText(info.title), | ||
title: UTIL.parseText(info.title, ''), | ||
index: info.index ? UTIL.parseIntegerFromText(info.index) : -1, | ||
@@ -27,0 +27,0 @@ id: info.videoId, |
@@ -37,3 +37,10 @@ const URL = require('url'); | ||
// Parsing utility | ||
const parseText = exports.parseText = txt => txt.simpleText || txt.runs.map(a => a.text).join(''); | ||
const parseText = exports.parseText = (txt, def = null) => { | ||
if (typeof txt !== 'object') return def; | ||
if (Object.prototype.hasOwnProperty.call(txt, 'simpleText')) return txt.simpleText; | ||
if (Array.isArray(txt.runs)) { | ||
return txt.runs.map(a => a.text).join(''); | ||
} | ||
return def; | ||
}; | ||
@@ -40,0 +47,0 @@ exports.parseIntegerFromText = txt => Number(parseText(txt).replace(/\D+/g, '')); |
{ | ||
"name": "ytpl", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Simple package to resolve YouTube playlists - no strings attached.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
28064
556