YouTube.js icon indicating copy to clipboard operation
YouTube.js copied to clipboard

13.0.1 InnertubeError: CompositeVideoPrimaryInfo not found

Open xuya227939 opened this issue 9 months ago • 4 comments

Steps to reproduce

  1. yarn add youtubei.js@latest

  2. Code like this

const { Innertube } = require('youtubei.js');

async function getVideoInfo(videoUrl) {
    try {
        const innertube = await Innertube.create();

        const videoId = new URL(videoUrl).searchParams.get('v');
        console.log('%c Line:9 🥓 videoId', 'color:#93c0a4', videoId);

        const video = await innertube.getInfo(videoId);
    } catch (error) {
        console.error('Error fetching video info:', error);
        return null;
    }
}

// 替换为你的视频链接
const videoUrl = 'https://www.youtube.com/watch?v=Bjs4JXDLbtM';

getVideoInfo(videoUrl).then(videoInfo => {});

Failure Logs

[YOUTUBEJS][Parser]: InnertubeError: CompositeVideoPrimaryInfo not found!
This is a bug, want to help us fix it? Follow the instructions at https://github.com/LuanRT/YouTube.js/blob/main/docs/updating-the-parser.md or report it at https://github.com/LuanRT/YouTube.js/issues!
Introspected and JIT generated this class in the meantime:
class CompositeVideoPrimaryInfo extends YTNode {
  static type = 'CompositeVideoPrimaryInfo';

  

  constructor(data: RawNode) {
    super();
  }
}

Expected behavior

getInfo

Current behavior

error

Version

Default

Anything else?

No response

Checklist

  • [x] I am running the latest version.
  • [x] I checked the documentation and found no answer.
  • [x] I have searched the existing issues and made sure this is not a duplicate.
  • [x] I have provided sufficient information.

xuya227939 avatar Mar 15 '25 07:03 xuya227939

I'm add CompositeVideoPrimaryInfo.ts in src/classes/,

import { Parser, type RawNode } from '../index.js';
import { YTNode } from '../helpers.js';

export default class CompositeVideoPrimaryInfo extends YTNode {
  static type = 'CompositeVideoPrimaryInfo';

  header;
  contents;

  constructor(data: RawNode) {
    super();
    // parse the data here, ex;
    this.header = Parser.parseItem(data.header);
    this.contents = Parser.parseArray(data.contents);
  }
}

xuya227939 avatar Mar 15 '25 07:03 xuya227939

Any solution for this?

Jppblue avatar Mar 21 '25 15:03 Jppblue

If this specific YouTube node contains data you want, feel free to submit a pull request implementing it. Otherwise, just disable the logger or ignore it, as it won't actually cause any parsing errors.

LuanRT avatar Mar 21 '25 19:03 LuanRT

Is there a way to workaround this for now? @Jppblue did you figure out how to workaround it?

glaksmono avatar May 15 '25 03:05 glaksmono