LuanRT / YouTube.js

A JavaScript client for YouTube's private API, known as InnerTube.
https://ytjs.dev
MIT License
3.54k stars 224 forks source link

Error while retrieving Community Posts: `InnertubeError: Something went wrong at Video!` #515

Open nagalluri opened 1 year ago

nagalluri commented 1 year ago

Steps to reproduce

I am trying to retrieve community posts but I am consistently observing the below error. You should be able to reproduce with the following code snippet. Could you please provide details on how this could be resolved? Thanks

const { Innertube, UniversalCache } = require("youtubei.js");

const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true }); 
const channel = await yt.getChannel("UCWOA1ZGywLbqmigxE4Qlvuw"); // Netflix

console.info('\nCommunity posts:');
const posts = await channel.getCommunity();

Failure Logs

InnertubeError: Something went wrong at Video!
This is a bug, please report it at https://github.com/LuanRT/YouTube.js/issues
    at ERROR_HANDLER (/var/task/node_modules/youtubei.js/bundle/node.cjs:10325:22)
    at Object.parseItem (/var/task/node_modules/youtubei.js/bundle/node.cjs:10634:7)
    at new BackstagePost (/var/task/node_modules/youtubei.js/bundle/node.cjs:2523:40)
    at Object.parseItem (/var/task/node_modules/youtubei.js/bundle/node.cjs:10630:22)
    at new BackstagePostThread (/var/task/node_modules/youtubei.js/bundle/node.cjs:2536:32)
    at parseItem (/var/task/node_modules/youtubei.js/bundle/node.cjs:10630:22)
    at Object.parseArray (/var/task/node_modules/youtubei.js/bundle/node.cjs:10650:22)
    at new ItemSection (/var/task/node_modules/youtubei.js/bundle/node.cjs:6142:36)
    at parseItem (/var/task/node_modules/youtubei.js/bundle/node.cjs:10630:22)
    at Object.parseArray (/var/task/node_modules/youtubei.js/bundle/node.cjs:10650:22) {
  info: {
    stack: "TypeError: Cannot read properties of undefined (reading 'find')\n" +
      '    at new Video (/var/task/node_modules/youtubei.js/bundle/node.cjs:1265:64)\n' +
      '    at Object.parseItem (/var/task/node_modules/youtubei.js/bundle/node.cjs:10630:22)\n' +
      '    at new BackstagePost (/var/task/node_modules/youtubei.js/bundle/node.cjs:2523:40)\n' +
      '    at Object.parseItem (/var/task/node_modules/youtubei.js/bundle/node.cjs:10630:22)\n' +
      '    at new BackstagePostThread (/var/task/node_modules/youtubei.js/bundle/node.cjs:2536:32)\n' +
      '    at parseItem (/var/task/node_modules/youtubei.js/bundle/node.cjs:10630:22)\n' +
      '    at Object.parseArray (/var/task/node_modules/youtubei.js/bundle/node.cjs:10650:22)\n' +
      '    at new ItemSection (/var/task/node_modules/youtubei.js/bundle/node.cjs:6142:36)\n' +
      '    at parseItem (/var/task/node_modules/youtubei.js/bundle/node.cjs:10630:22)\n' +
      '    at Object.parseArray (/var/task/node_modules/youtubei.js/bundle/node.cjs:10650:22)'
  },
  date: 2023-10-02T00:17:23.641Z,
  version: '6.4.0'

Expected behavior

The expected behavior is to retrieve the list of community posts

Current behavior

The call to retrieve community posts is failing with the specified error

Version

Default

Anything else?

No response

Checklist

LuanRT commented 1 year ago

That's just a parser warning (which you can turn off if they bother you), it shouldn't cause the whole function to break. Are you able to access that "posts" variable or is there a hard error that prevents that?

nagalluri commented 1 year ago

Thanks for the quick response. Yes, I can still access the posts variable. May I ask what may be causing the parser warning? Is it something that I need to handle?

absidue commented 1 year ago

YouTube making layout changes or renaming properties. In this case it looks like one of the community posts has a video embedded/linked and they've made changes to the videoRenderer object, so the parser is erroring when it tries to parse that video. Probably an A/B test, so it only affects specific YouTube users at the moment.

nagalluri commented 1 year ago

Got it, thanks for the details

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.