Skip to content

Commit

Permalink
fix: fix regression for getting info for rental and not yet live videos
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Nov 4, 2020
1 parent ddb6e3f commit 4a01794
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/info.js
Expand Up @@ -39,7 +39,7 @@ exports.getBasicInfo = async(id, options) => {
player_response = parseJSON('watch.json `player_response`', player_response);
let html5player = info.player && info.player.assets && info.player.assets.js;

let playErr = utils.playError(player_response, ['ERROR', 'UNPLAYABLE']);
let playErr = utils.playError(player_response, ['ERROR']);
let privateErr = privateVideoError(player_response);
if (playErr || privateErr) {
throw playErr || privateErr;
Expand Down
2 changes: 1 addition & 1 deletion test/download-test.js
Expand Up @@ -639,7 +639,7 @@ describe('Download video', () => {

describe('that has not yet started broadcasting', () => {
it('Fails gracefully', done => {
const id = 'GgPfoDM4HN0';
const id = 'VIBFo3Ti5vQ';
const scope = nock(id, 'live-future');
let stream = ytdl(id);
stream.on('error', err => {
Expand Down
1 change: 1 addition & 0 deletions test/files/refresh.js
Expand Up @@ -58,6 +58,7 @@ const videos = [
{
id: 'SyKPsFRP_Oc',
type: 'rental',
basicInfo: true,
saveInfo: true,
},
{
Expand Down
25 changes: 25 additions & 0 deletions test/info-test.js
Expand Up @@ -189,6 +189,31 @@ describe('ytdl.getInfo()', () => {
});
});

describe('From videos without formats', () => {
describe('Rental video', () => {
it('Gets video details', async() => {
const id = 'SyKPsFRP_Oc';
const scope = nock(id, 'rental');
let info = await ytdl.getInfo(id);
scope.done();
assert.ok(info);
assert.ok(info.videoDetails);
assert.ok(info.videoDetails.title);
});
});
describe('Not yet broadcasted', () => {
it('Gets video details', async() => {
const id = 'VIBFo3Ti5vQ';
const scope = nock(id, 'live-future');
let info = await ytdl.getInfo(id);
scope.done();
assert.ok(info);
assert.ok(info.videoDetails);
assert.ok(info.videoDetails.title);
});
});
});

describe('With cookie headers', () => {
const id = '_HSylqgVYQI';
describe('`x-youtube-identity-token` given', () => {
Expand Down

0 comments on commit 4a01794

Please sign in to comment.