YouTube.js
YouTube.js copied to clipboard
13.0.1 InnertubeError: CompositeVideoPrimaryInfo not found
Steps to reproduce
-
yarn add youtubei.js@latest
-
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.
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);
}
}
Any solution for this?
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.
Is there a way to workaround this for now? @Jppblue did you figure out how to workaround it?