Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10.0.0 [YOUTUBEJS][Parser]: InnertubeError: Something went wrong at ContentMetadataView! #668

Open
4 tasks done
iBicha opened this issue Jun 16, 2024 · 3 comments
Open
4 tasks done
Labels
bug Something isn't working

Comments

@iBicha
Copy link
Contributor

iBicha commented Jun 16, 2024

Steps to reproduce

Happens when trying to read playlists (I'll dig into this further when I have some time)

This is from yt2alt, usage looks like this

    async getPlaylistWithVideos(playlistId, limit = PLAYLIST_LIMIT) {
        await this.createSession();

        let playlist = await this.innertube.getPlaylist(playlistId);

        const videos = await this.getFeedVideosWithLimit(playlist, limit);

        return this.toPlaylistWithVideos(playlist, videos);
    }

    async getFeedVideosWithLimit(feed, limit = PLAYLIST_LIMIT) {
        const videos = [];
        while (limit === -1 || videos.length < limit) {
            try {
                videos.push(...feed.videos);
                if (!feed.has_continuation) {
                    break;
                }
                feed = await feed.getContinuation();
            } catch (error) {
                console.error(error);
                break;
            }
        }

        return videos.slice(0, limit)
            .map(video => this.toVideo(video));
    }

Failure Logs

[YOUTUBEJS][Parser]: InnertubeError: Something went wrong at ContentMetadataView!
This is a bug, please report it at https://github.com/LuanRT/YouTube.js/issues
    at ERROR_HANDLER (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/parser.js:48:31)
    at Module.parseItem (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/parser.js:393:13)
    at new PageHeaderView (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/classes/PageHeaderView.js:16:32)
    at Module.parseItem (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/parser.js:388:28)
    at new PageHeader (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/classes/PageHeader.js:8:31)
    at parseItem (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/parser.js:388:28)
    at parse (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/parser.js:437:34)
    at Module.parseResponse (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/parser.js:194:34)
    at new Feed (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/core/mixins/Feed.js:39:61)
    at new Playlist (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/youtube/Playlist.js:22:9) {
  info: {
    stack: "TypeError: Cannot destructure property 'content' of 'data' as it is undefined.\n" +
      '    at Text.fromAttributed (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/classes/misc/Text.js:42:17)\n' +
      '    at file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/classes/ContentMetadataView.js:10:32\n' +
      '    at Array.map (<anonymous>)\n' +
      '    at file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/classes/ContentMetadataView.js:9:98\n' +
      '    at Array.map (<anonymous>)\n' +
      '    at new ContentMetadataView (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/classes/ContentMetadataView.js:6:48)\n' +
      '    at Module.parseItem (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/parser.js:388:28)\n' +
      '    at new PageHeaderView (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/classes/PageHeaderView.js:16:32)\n' +
      '    at Module.parseItem (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/parser.js:388:28)\n' +
      '    at new PageHeader (file:///Users/brahim/Roku/yt2alt/node_modules/youtubei.js/dist/src/parser/classes/PageHeader.js:8:31)'
  },
  date: 2024-06-16T16:18:45.549Z,
  version: '10.0.0'
}

Expected behavior

Reads videos from playlists

Current behavior

Error printed, but still successfully reads videos (or at least the ids are there)

Version

Default

Anything else?

No response

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.
@iBicha iBicha added the bug Something isn't working label Jun 16, 2024
@iBicha
Copy link
Contributor Author

iBicha commented Jun 16, 2024

So when reading this playlist I have, the issue is with the parsing of ContentMetadataView.

Parsing assumes that a ContentMetadataView contains rows, and each row contains parts, and each part is a text. But in my case I see that a part can be of type AvatarStack, which seems to be a list of avatars (I assume this is because maybe it is possible, or it will become possible, to collaborate on creating a playlist by multiple people maybe?)

Here's the json of this ContentMetadataView causing the bug

{
  "metadataRows": [
    {
      "metadataParts": [
        {
          "avatarStack": {
            "avatarStackViewModel": {
              "avatars": [
                {
                  "avatarViewModel": {
                    "image": {
                      "sources": [
                        {
                          "url": "https://yt3.ggpht.com/ytc/redacted",
                          "width": 48,
                          "height": 48
                        }
                      ],
                      "processor": {
                        "borderImageProcessor": {
                          "circular": true
                        }
                      }
                    },
                    "avatarImageSize": "AVATAR_SIZE_XS"
                  }
                }
              ],
              "text": {
                "content": "redacted",
                "commandRuns": [
                  {
                    "startIndex": 0,
                    "length": 15,
                    "onTap": {
                      "innertubeCommand": {
                        "clickTrackingParams": "redacted",
                        "commandMetadata": {
                          "webCommandMetadata": {
                            "url": "/@BrahimHadriche",
                            "webPageType": "WEB_PAGE_TYPE_CHANNEL",
                            "rootVe": 3611,
                            "apiUrl": "/youtubei/v1/browse"
                          }
                        },
                        "browseEndpoint": {
                          "browseId": "redacted",
                          "canonicalBaseUrl": "redacted"
                        }
                      }
                    }
                  }
                ],
                "styleRuns": [
                  {
                    "startIndex": 0,
                    "length": 15,
                    "weightLabel": "FONT_WEIGHT_NORMAL",
                    "styleRunExtensions": {
                      "styleRunColorMapExtension": {
                        "colorMap": [
                          {
                            "key": "USER_INTERFACE_THEME_LIGHT",
                            "value": 4294967295
                          },
                          {
                            "key": "USER_INTERFACE_THEME_DARK",
                            "value": 4294967295
                          }
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    },
    {
      "metadataParts": [
        {
          "text": {
            "content": "9 videos"
          }
        },
        {
          "text": {
            "content": "Public"
          }
        }
      ]
    }
  ]
} 

@absidue
Copy link
Collaborator

absidue commented Jun 16, 2024

Until now YouTube has only used that node on the channel page, hence the current handling. Sounds like they are switching to that on the playlist page too then.

Thank you for providing the snippet that causes the problem, that will make it easier to add support for it.

@wogikaze
Copy link

I got the same error when running my playlist organizer tool.
The JSON of ContentMetadataView looks a little different, so I'll paste mine as well.

{
  "metadataRows": [
    {
      "metadataParts": [
        {
          "avatarStack": {
            "avatarStackViewModel": {
              "avatars": [
                {
                  "avatarViewModel": {
                    "image": {
                      "sources": [
                        {
                          "url": "<url-redacted>",
                          "width": 48,
                          "height": 48
                        }
                      ],
                      "processor": {
                        "borderImageProcessor": {
                          "circular": true
                        }
                      }
                    },
                    "avatarImageSize": "AVATAR_SIZE_XS"
                  }
                }
              ],
              "text": {
                "content": "<test-redacted>",
                "commandRuns": [
                  {
                    "startIndex": 0,
                    "length": 14,
                    "onTap": {
                      "innertubeCommand": {
                        "clickTrackingParams": "redacted",
                        "commandMetadata": {
                          "webCommandMetadata": {
                            "url": "/@redacted",
                            "webPageType": "WEB_PAGE_TYPE_CHANNEL",
                            "rootVe": 3611,
                            "apiUrl": "/youtubei/v1/browse"
                          }
                        },
                        "browseEndpoint": {
                          "browseId": "redacted",
                          "canonicalBaseUrl": "/@redacted"
                        }
                      }
                    }
                  }
                ],
                "styleRuns": [
                  {
                    "startIndex": 0,
                    "length": 14,
                    "fontColor": 4294967295,
                    "weightLabel": "FONT_WEIGHT_NORMAL"
                  }
                ]
              },
              "rendererContext": {
                "loggingContext": {
                  "loggingDirectives": {
                    "trackingParams": "redacted",
                    "visibility": {
                      "types": "12"
                    },
                    "clientVeSpec": {
                      "uiType": 184971,
                      "veCounter": 610901681
                    }
                  }
                },
                "accessibilityContext": {
                  "label": "redacted"
                },
                "commandContext": {
                  "onTap": {
                    "innertubeCommand": {
                      "clickTrackingParams": "redacted",
                      "commandMetadata": {
                        "webCommandMetadata": {
                          "url": "/@redacted",
                          "webPageType": "WEB_PAGE_TYPE_CHANNEL",
                          "rootVe": 3611,
                          "apiUrl": "/youtubei/v1/browse"
                        }
                      },
                      "browseEndpoint": {
                        "browseId": "redacted",
                        "canonicalBaseUrl": "/@redacted"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "metadataParts": [
        {
          "text": {
            "content": "Playlist"
          }
        },
        {
          "text": {
            "content": "Public"
          }
        },
        {
          "text": {
            "content": "260 videos"
          }
        },
        {
          "text": {
            "content": "4,628,354 views"
          }
        }
      ]
    }
  ],
  "delimiter": "",
  "rendererContext": {
    "loggingContext": {
      "loggingDirectives": {
        "trackingParams": "redacted",
        "visibility": {
          "types": "12"
        },
        "clientVeSpec": {
          "uiType": 176757,
          "veCounter": 610901680
        }
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants