Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
fix: Invalid parsing of description (#114)
Browse files Browse the repository at this point in the history
* Update main.js

* add Metadata testcase

Co-authored-by: TimeForANinja <[email protected]>
  • Loading branch information
Asgarrrr and TimeForANinja authored May 5, 2021
1 parent a04a718 commit 90ab8b0
Show file tree
Hide file tree
Showing 4 changed files with 4,404 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const main = module.exports = async(linkOrId, options, rt = 3) => {
thumbnails,
bestThumbnail: thumbnails[0],
lastUpdated: UTIL.parseText(info.stats[2], ''),
description: Array.isArray(info.description) && info.description.length ? UTIL.parseText(info.description) : null,
description: info.description ? UTIL.parseText(info.description, '') : null,
visibility: info.badges && JSON.stringify(info.badges).includes('UNLISTED') ? 'unlisted' : 'everyone',
author: !secInfo ? null : {
name: info_owner.title.runs[0].text,
Expand Down
12 changes: 12 additions & 0 deletions test/main-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ describe('YTPL()', () => {
scope.done();
});

it('parses & compare meta data from a regular playlist', async() => {
const dataDir = 'test/pages/';
const targetData = FS.readFileSync(`${dataDir}withDescription.json`);
const scope = NOCK(YT_HOST)
.get(PLAYLIST_PATH)
.query({ gl: 'US', hl: 'en', list: 'PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK' })
.replyWithFile(200, `${dataDir}withDescription.html`);
const resp = await YTPL('PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK', { limit: 100 });
ASSERT.deepEqual(resp, JSON.parse(targetData));
scope.done();
});

it('compare first page', async() => {
const data_dir = 'test/pages/';
const data = Array.from(
Expand Down
24 changes: 24 additions & 0 deletions test/pages/withDescription.html

Large diffs are not rendered by default.

Loading

0 comments on commit 90ab8b0

Please sign in to comment.