diff --git a/lib/info.js b/lib/info.js index a903e5c5..befb5d1b 100644 --- a/lib/info.js +++ b/lib/info.js @@ -250,7 +250,7 @@ const parseJSON = (source, varName, json) => { }; -const findJSON = (source, varName, body, left, right, prependJSON = '') => { +const findJSON = (source, varName, body, left, right, prependJSON) => { let jsonStr = utils.between(body, left, right); if (!jsonStr) { throw Error(`Could not find ${varName} in ${source}`); diff --git a/test/basic-info-test.js b/test/basic-info-test.js index a49b0b59..5d0ab56c 100644 --- a/test/basic-info-test.js +++ b/test/basic-info-test.js @@ -218,6 +218,11 @@ describe('ytdl.getBasicInfo()', () => { describe('`x-youtube-identity-token` not given', () => { it('Retrieves identity-token from watch.html page', async() => { const scope = nock(id, 'regular', { + watchHtml: [true, 400], + get_video_info: false, + player: false, + }); + const scope2 = nock(id, 'regular', { watchHtml: [true, 200, body => `${body}\n{"ID_TOKEN":"abcd"}`], watchJson: false, get_video_info: false, @@ -225,10 +230,12 @@ describe('ytdl.getBasicInfo()', () => { }); let info = await ytdl.getBasicInfo(id, { requestOptions: { + maxRetries: 1, headers: { cookie: 'abc=1' }, }, }); scope.done(); + scope2.done(); assert.ok(info.formats.length); });