node-ytpl
node-ytpl copied to clipboard
Fix issue when playlistVideoListRenderer is not the first property
I found a playlist that has a different format than others: https://www.youtube.com/playlist?list=PL2aBZuCeDwlQN4aWkYJlwjjNRr8N5Qtt1
When doing some debug I found out that common playlists have the property playlistVideoListRenderer as the first one inside this path:
parsed.json.contents
.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content
.sectionListRenderer.contents[0]
.itemSectionRenderer.contents[0]
But this playlist had not one but two values inside the itemSectionRenderer.contents field, and the first value does not contain the usual playlistVideoListRenderer but a new property called playlistShowMetadataRenderer. Please take a look at this schema-like output:
{
"json": {
"contents": {
"twoColumnBrowseResultsRenderer": {
"tabs": [
{
"tabRenderer": {
"content": {
"sectionListRenderer": {
"contents": [
{
"itemSectionRenderer": {
"contents": [
{
"playlistShowMetadataRenderer": {
...
}
}
],
...
}
},
{
"itemSectionRenderer": {
"contents": [
{
"playlistVideoListRenderer": {
...
}
}
],
...
}
}
],
...
}
},
...
}
}
]
}
},
...
},
...
}
This PR simply loops into the itemSectionRenderer property to find the right value to move on. I added one test with this specific playlist.
Thanks in advance!