Skip to content

Commit

Permalink
feat(info): add age_restricted and no_embed_allowed keys to video…
Browse files Browse the repository at this point in the history
… info'

closese #321
  • Loading branch information
fent committed Aug 2, 2018
1 parent dcb7281 commit 7fc2df9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/info.js
Expand Up @@ -125,6 +125,7 @@ function gotConfig(id, options, additional, config, fromEmbed, callback) {
} else if (info.status === 'fail') {
if (info.errorcode === '150' && config.args) {
info = config.args;
info.no_embed_allowed = true;
} else {
return callback(
new Error(`Code ${info.errorcode}: ${util.stripHTML(info.reason)}`));
Expand Down Expand Up @@ -156,6 +157,7 @@ function gotConfig(id, options, additional, config, fromEmbed, callback) {

// Add additional properties to info.
Object.assign(info, additional);
info.age_restricted = fromEmbed;

if (info.formats.length ||
config.args.dashmpd || info.dashmpd || info.hlsvp) {
Expand Down
2 changes: 1 addition & 1 deletion test/files/videos/pJk0p-98Xzc-vevo/expected_info.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/info-test.js
Expand Up @@ -171,6 +171,7 @@ describe('ytdl.getInfo()', () => {
assert.ifError(err);
scope.done();
assert.equal(info.formats.length, expectedInfo.formats.length);
assert.ok(info.age_restricted);
done();
});
});
Expand Down
2 changes: 2 additions & 0 deletions typings/index.d.ts
Expand Up @@ -182,6 +182,8 @@ declare module 'ytdl-core' {
description: string;
related_videos: relatedVideo[]
video_url: string;
no_embed_allowed?: boolean;
age_restricted: boolean;
}

type relatedVideo = {
Expand Down

0 comments on commit 7fc2df9

Please sign in to comment.