From 241f73d8ab20861991d3682095e2b6e5ea17d7ba Mon Sep 17 00:00:00 2001 From: fent <933490+fent@users.noreply.github.com> Date: Sat, 24 Oct 2020 04:35:19 -0700 Subject: [PATCH] refactor: fully remove deprecated properties BREAKING CHANGES: - deprecated properties that gave a deprecated warning have been removed, these properties were moved into `info.videoDetails` --- lib/info-extras.js | 3 --- lib/info.js | 18 ------------------ lib/util.js | 25 ------------------------- typings/index.d.ts | 13 +------------ 4 files changed, 1 insertion(+), 58 deletions(-) diff --git a/lib/info-extras.js b/lib/info-extras.js index 4fcce5aa..156b1b06 100644 --- a/lib/info-extras.js +++ b/lib/info-extras.js @@ -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'); diff --git a/lib/info.js b/lib/info.js index df9407bb..fb05712e 100644 --- a/lib/info.js +++ b/lib/info.js @@ -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; }; diff --git a/lib/util.js b/lib/util.js index 714bca8b..227853fe 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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; @@ -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; - }, - }); -}; diff --git a/typings/index.d.ts b/typings/index.d.ts index 926efa3d..f0ed7e9f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -122,7 +122,6 @@ declare module 'ytdl-core' { } interface Media { - image?: string; category: string; category_url: string; game?: string; @@ -133,6 +132,7 @@ declare module 'ytdl-core' { artist_url?: string; writers?: string; licensed_by?: string; + thumbnails: thumbnail[]; } interface Author { @@ -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; @@ -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; @@ -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; @@ -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;