node-ytdl-core icon indicating copy to clipboard operation
node-ytdl-core copied to clipboard

ytdl.getInfo(...).videoDetails.title does not always honor lang

Open MarmadileManteater opened this issue 2 years ago • 0 comments

ytdl.getInfo does not always return the correct localized title even when it is provided the lang option. I created a gist to demonstrate this using the localized response from ytpl as a reference and using the videos in this playlist: PLB6Mfu4v-kdUKpNVGykSxx5CpnTP2_rcB

localization (in this example playlistResponse comes from ytpl)

As I dug into the issue further, I discovered that the correct localized title is stored in the response object, but it is buried. This is where the expected values of .videoDetails.title and .videoDetails.description are located.

.videoDetails.title should be the value of .response.contents.twoColumnWatchNextResults.results.results.contents[0].videoPrimaryInfoRenderer.title.runs[0].text

image

.videoDetails.description should (probably) be the value of .response.contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.description.runs[0].text (update .response.contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.description.runs contains an array of the lines in the localized description)

I created another gist to demonstrate using this workaround for the title field.

TLDR; the correct localized title and description are being fetched by ytdl.getInfo, but ytdl.getInfo(...).videoDetails doesn't contain them, and instead, they are buried in the response object.

MarmadileManteater avatar Sep 03 '22 02:09 MarmadileManteater