diff --git a/lib/parser/contents/classes/Message.js b/lib/parser/contents/classes/Message.js new file mode 100644 index 00000000..1d43d238 --- /dev/null +++ b/lib/parser/contents/classes/Message.js @@ -0,0 +1,13 @@ +'use strict'; + +const Text = require('./Text'); + +class Message { + type = 'messageRenderer' + + constructor(data) { + this.text = new Text(data.text); + } +} + +module.exports = Message; \ No newline at end of file diff --git a/lib/parser/contents/index.js b/lib/parser/contents/index.js index 2bec603f..66d6baa5 100644 --- a/lib/parser/contents/index.js +++ b/lib/parser/contents/index.js @@ -91,7 +91,9 @@ class Parser { for (let item of data) { const keys = Object.keys(item); const classname = this.sanitizeClassName(keys[0]); - + + if (this.shouldIgnore(classname)) return; + try { const TargetClass = require('./classes/' + classname); results.push(new TargetClass(item[keys[0]], ctx)); @@ -106,6 +108,8 @@ class Parser { const keys = Object.keys(data); const classname = this.sanitizeClassName(keys[0]); + if (this.shouldIgnore(classname)) return; + try { const TargetClass = require('./classes/' + classname); return new TargetClass(data[keys[0]], ctx); @@ -136,6 +140,12 @@ class Parser { .replace(/Renderer|Model/g, '') .replace(/Radio/g, 'Mix').trim(); } + + static shouldIgnore(classname) { + return [ + 'PromotedSparklesWeb' + ].includes(classname); + } } module.exports = Parser; \ No newline at end of file diff --git a/lib/parser/youtube/VideoInfo.js b/lib/parser/youtube/VideoInfo.js index b48df9de..9fc596ea 100644 --- a/lib/parser/youtube/VideoInfo.js +++ b/lib/parser/youtube/VideoInfo.js @@ -63,7 +63,7 @@ class VideoInfo { /** * @type {import('../contents/classes/MerchandiseShelf')} */ - this.merchandise = results?.get({ type: 'merchandiseShelfRenderer' }); + this.merchandise = results?.get({ type: 'merchandiseShelfRenderer' }) || {}; /** * @type {import('../contents/classes/ChipCloud')} @@ -140,7 +140,7 @@ class VideoInfo { /** * Retrieves watch next feed continuation. - * @returns {Promise.} + * @returns {Promise.} */ async getWatchNextContinuation() { const response = await this.#watch_next_continuation.endpoint.call(this.#actions); @@ -154,7 +154,7 @@ class VideoInfo { /** @type {string} */ get filters() { - return this.related_chip_cloud.chips.map((chip) => chip.text); + return this.related_chip_cloud?.chips.map((chip) => chip.text) || []; } get page() {