Skip to content

Commit

Permalink
refactor: fully remove deprecated properties
Browse files Browse the repository at this point in the history
BREAKING CHANGES:
- deprecated properties that gave a deprecated warning have been
  removed, these properties were moved into `info.videoDetails`
  • Loading branch information
fent committed Oct 25, 2020
1 parent f54ea22 commit 241f73d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 58 deletions.
3 changes: 0 additions & 3 deletions lib/info-extras.js
Expand Up @@ -58,9 +58,6 @@ exports.getMedia = info => {
media[`${type}_url`] = urllib.resolve(VIDEO_URL,
meta.endpoint.commandMetadata.webCommandMetadata.url);
media.thumbnails = meta.thumbnail.thumbnails;
// TODO: Added for backwards compatibility. Remove later.
util.deprecate(media, 'image', urllib.resolve(VIDEO_URL, media.thumbnails[0].url),
'info.videoDetails.media.image', 'info.videoDetails.media.thumbnails');
}
let topic = contents
.filter(meta => meta.richMetadataRenderer.style === 'RICH_METADATA_RENDERER_STYLE_TOPIC');
Expand Down
18 changes: 0 additions & 18 deletions lib/info.js
Expand Up @@ -193,24 +193,6 @@ const gotConfig = async(id, options, info, body) => {
info.related_videos = extras.getRelatedVideos(info);
info.html5player = info.html5player || (info.player && info.player.assets && info.player.assets.js);

// TODO: Remove these warnings later and remove the properties.
// Remember to remove from typings too.
for (let [prop, value] of Object.entries(additional)) {
util.deprecate(info, prop, value, `info.${prop}`, `info.videoDetails.${prop}`);
}
util.deprecate(info, 'published', info.player_response.microformat.playerMicroformatRenderer.publishDate,
'info.published', 'info.videoDetails.publishDate');
let props = {
description: 'shortDescription',
video_id: 'videoId',
title: 'title',
length_seconds: 'lengthSeconds',
};
for (let [oldProp, newProp] of Object.entries(props)) {
util.deprecate(info, oldProp, info.videoDetails[newProp],
`info.${oldProp}`, `info.videoDetails.${newProp}`);
}

return info;
};

Expand Down
25 changes: 0 additions & 25 deletions lib/util.js
Expand Up @@ -343,9 +343,6 @@ exports.addFormatMeta = format => {
format.audioCodec = format.hasAudio && format.codecs ?
format.codecs.split(', ').slice(-1)[0] : null;
format.isLive = /\bsource[/=]yt_live_broadcast\b/.test(format.url);
// TODO: Remove these warnings later and remove the properties.
// Remember to remove from typings too.
exports.deprecate(format, 'live', format.isLive, 'format.live', 'format.isLive');
format.isHLS = /\/manifest\/hls_(variant|playlist)\//.test(format.url);
format.isDashMPD = /\/manifest\/dash\//.test(format.url);
return format;
Expand Down Expand Up @@ -440,25 +437,3 @@ exports.playError = (info, statuses) => {
}
return null;
};


/**
* Temporary helper to help deprecating a few properties.
*
* @param {Object} obj
* @param {string} prop
* @param {Object} value
* @param {string} oldPath
* @param {string} newPath
*/
exports.deprecate = (obj, prop, value, oldPath, newPath) => {
Object.defineProperty(obj, prop, {
get: () => {
// eslint-disable-next-line no-console
console.warn(
`\`${oldPath}\` will be removed in a near future release, ` +
`use \`${newPath}\` instead.`);
return value;
},
});
};
13 changes: 1 addition & 12 deletions typings/index.d.ts
Expand Up @@ -122,7 +122,6 @@ declare module 'ytdl-core' {
}

interface Media {
image?: string;
category: string;
category_url: string;
game?: string;
Expand All @@ -133,6 +132,7 @@ declare module 'ytdl-core' {
artist_url?: string;
writers?: string;
licensed_by?: string;
thumbnails: thumbnail[];
}

interface Author {
Expand Down Expand Up @@ -220,7 +220,6 @@ declare module 'ytdl-core' {
eventid: string;
token: string;
atc: string;
title: string;
cr: string;
apply_fade_on_midrolls: string;
cl: string;
Expand All @@ -230,8 +229,6 @@ declare module 'ytdl-core' {
fflags: string;
ssl: string;
pltype: string;
media: Media;
author: Author;
enabled_engage_types: string;
hl: string;
is_listed: string;
Expand Down Expand Up @@ -280,7 +277,6 @@ declare module 'ytdl-core' {
as_launched_in_country: string;
avg_rating: string;
fade_out_start_milliseconds: string;
length_seconds: string;
midroll_prefetch_size: string;
allow_ratings: string;
thumbnail_url: string;
Expand All @@ -305,19 +301,12 @@ declare module 'ytdl-core' {
ptk: string;
vmap: string;
watermark: string[];
video_id: string;
dbp: string;
ad_flags: string;
html5player: string;
formats: videoFormat[];
published: number;
description: string;
related_videos: relatedVideo[];
video_url: string;
no_embed_allowed?: boolean;
age_restricted: boolean;
likes?: number;
dislikes?: number;
player_response: {
playabilityStatus: {
status: string;
Expand Down

0 comments on commit 241f73d

Please sign in to comment.