Closed byadems closed 4 months ago
it's been like this for 2 days and even though it's been corrected, the result is the same.
@byadems
I was having the same issue up until now, I believe he just means to update the package through npm. This did fix the issue for me.
npm install youtubei.js@latest
@byadems
I was having the same issue up until now, I believe he just means to update the package through npm. This did fix the issue for me.
npm install youtubei.js@latest
Do you know how to update on the Railway platform?
@byadems
Are you using Node.js or is it something else?
Deleting your node_modules
folder and then running npm install
should work.
@byadems
@LuanRT Node via Railway.i'm running it through js. The name of the related Bot is also called Raganork-md, I asked the developer to fix it, he said he couldn't be interested right now. Can't I fix it myself, please help me.
@LuanRT, I'm also having 400 error code running with 9.1.0
version.
This code gives me an error:
import { Innertube } from "youtubei.js";
(async () => {
const yt = await Innertube.create();
yt.music.search("hello", { type: "song" }).then(console.log);
})();
Here is a full error:
file:///home/tmp/node_modules/.pnpm/youtubei.js@9.1.0/node_modules/youtubei.js/dist/src/utils/HTTPClient.js:99
throw new InnertubeError(`Request to ${response.url} failed with status ${response.status}`, yield response.text());
^
InnertubeError: Request to https://www.youtube.com/youtubei/v1/search?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false&alt=json failed with status 400
at HTTPClient.<anonymous> (file:///home/tmp/node_modules/.pnpm/youtubei.js@9.1.0/node_modules/youtubei.js/dist/src/utils/HTTPClient.js:99:19)
at Generator.next (<anonymous>)
at fulfilled (/home/tmp/node_modules/.pnpm/tslib@2.6.2/node_modules/tslib/tslib.js:166:62)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
info: '{\n' +
' "error": {\n' +
' "code": 400,\n' +
' "message": "Request contains an invalid argument.",\n' +
' "errors": [\n' +
' {\n' +
' "message": "Request contains an invalid argument.",\n' +
' "domain": "global",\n' +
' "reason": "badRequest"\n' +
' }\n' +
' ],\n' +
' "status": "INVALID_ARGUMENT"\n' +
' }\n' +
'}\n',
date: 2024-03-14T16:08:44.681Z,
version: '9.1.0'
}
Node.js v21.5.0
Surprisingly, running the same code from my local machine gives an expected result. Can it be that youtube blocked my somehow? How do I find out? Is it permanent? And why the error code is so weird?..
Here is the test suit running on maching where the error ocuured:
FAIL node test/main.test.ts (31.697 s)
YouTube.js Tests
Main
✓ Innertube#getInfo (638 ms)
✓ Innertube#getBasicInfo (135 ms)
✓ Innertube#getShortsWatchItem (685 ms)
✓ Innertube#getShortsWatchItem#Continue (760 ms)
✓ Innertube#search (806 ms)
✓ Innertube#getSearchSuggestions (114 ms)
✓ Innertube#getGuide (40 ms)
✓ Innertube#getTrending (346 ms)
✓ Innertube#getPlaylist (91 ms)
✓ Innertube#resolveURL (32 ms)
✓ Innertube#download (2958 ms)
Innertube#getBasicInfo
✓ Format#language multiple audio tracks (176 ms)
✓ Format#language single audio track with captions (193 ms)
Innertube#search
✓ Search#getContinuation (792 ms)
Innertube#getComments
✓ Comments#getContinuation (554 ms)
CommentThread#getReplies
✓ CommentThread#getContinuation (171 ms)
Innertube#getHomeFeed
✕ HomeFeed#getContinuation (2 ms)
Innertube#getChannel
✓ Channel#getHome (2 ms)
✓ Channel#getPlaylists (90 ms)
✓ Channel#getCommunity (166 ms)
✓ Channel#getAbout (53 ms)
✓ Channel#search (454 ms)
Channel#getVideos
✓ Channel#getContinuation (205 ms)
✓ Channel#applyFilter (172 ms)
Innertube#getHashtag
✓ HashtagFeed#getContinuation (553 ms)
YouTube Music
✓ Innertube#music.getInfo (133 ms)
✕ Innertube#music.getExplore (40 ms)
✓ Innertube#music.getArtist (123 ms)
✕ Innertube#music.getAlbum (56 ms)
✓ Innertube#music.getPlaylist (131 ms)
✕ Innertube#music.getLyrics (191 ms)
✕ Innertube#music.getUpNext (494 ms)
✕ Innertube#music.getRelated (232 ms)
✓ Innertube#music.getSearchSuggestions (66 ms)
Innertube#music.search
✓ Search#applyFilter (302 ms)
✕ Search#getContinuation (1 ms)
Innertube#music.getHomeFeed
✕ HomeFeed#getContinuation
✕ HomeFeed#applyFilter
YouTube Kids
✓ Innertube#kids.getInfo (691 ms)
✓ Innertube#kids.getHomeFeed (443 ms)
✓ Innertube#kids.getChannel (167 ms)
✓ Innertube#kids.search (500 ms)
● YouTube.js Tests › Main › Innertube#getHomeFeed › HomeFeed#getContinuation
There are no continuations.
200 | if (this.#continuation) {
201 | if (this.#continuation.length === 0)
> 202 | throw new InnertubeError('There are no continuations.');
| ^
203 |
204 | const response = await this.#continuation[0].endpoint.call<T>(this.#actions, { parse: true });
205 |
at HomeFeed.<anonymous> (src/core/mixins/Feed.ts:202:15)
at node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:167:75
at __awaiter (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:163:16)
at HomeFeed.getContinuationData (bundle/node.cjs:13137:41)
at HomeFeed.<anonymous> (src/core/mixins/Feed.ts:212:19)
at node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:167:75
● YouTube.js Tests › YouTube Music › Innertube#music.search › Search#getContinuation
Continuation not found.
72 | async getContinuation(): Promise<SearchContinuation> {
73 | if (!this.#continuation)
> 74 | throw new InnertubeError('Continuation not found.');
| ^
75 |
76 | const response = await this.#actions.execute('/search', {
77 | continuation: this.#continuation,
at Search2.<anonymous> (src/parser/ytmusic/Search.ts:74:13)
at node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:167:75
at __awaiter (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:163:16)
at Search2.getContinuation (bundle/node.cjs:15423:41)
at test/main.test.ts:314:55
at node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:167:75
● YouTube.js Tests › YouTube Music › Innertube#music.getHomeFeed › HomeFeed#getContinuation
Expected node of any type MusicCarouselShelf, MusicTasteBuilderShelf, got ItemSection
463 | if (node.is(...types))
464 | return node;
> 465 | throw new ParsingError(`Expected node of any type ${types.map((type) => type.type).join(', ')}, got ${(node as YTNode).type}`);
| ^
466 | }));
467 | };
468 | }
at src/parser/helpers.ts:465:19
at Array.map (<anonymous>)
at Proxy.<anonymous> (src/parser/helpers.ts:462:33)
at new HomeFeed (src/parser/ytmusic/HomeFeed.ts:43:59)
at Music.<anonymous> (src/core/clients/Music.ts:137:12)
at fulfilled (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:164:62)
● YouTube.js Tests › YouTube Music › Innertube#music.getHomeFeed › HomeFeed#applyFilter
Expected node of any type MusicCarouselShelf, MusicTasteBuilderShelf, got ItemSection
463 | if (node.is(...types))
464 | return node;
> 465 | throw new ParsingError(`Expected node of any type ${types.map((type) => type.type).join(', ')}, got ${(node as YTNode).type}`);
| ^
466 | }));
467 | };
468 | }
at src/parser/helpers.ts:465:19
at Array.map (<anonymous>)
at Proxy.<anonymous> (src/parser/helpers.ts:462:33)
at new HomeFeed (src/parser/ytmusic/HomeFeed.ts:43:59)
at Music.<anonymous> (src/core/clients/Music.ts:137:12)
at fulfilled (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:164:62)
● YouTube.js Tests › YouTube Music › Innertube#music.getExplore
expect(received).toBeGreaterThan(expected)
Expected: > 0
Received: 0
349 | expect(explore).toBeDefined();
350 | expect(explore.sections).toBeDefined();
> 351 | expect(explore.sections?.length).toBeGreaterThan(0);
| ^
352 | expect(explore.top_buttons).toBeDefined();
353 | });
354 |
at test/main.test.ts:351:40
at fulfilled (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:164:62)
● YouTube.js Tests › YouTube Music › Innertube#music.getAlbum
Request to https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false&alt=json failed with status 404
144 | return response;
145 | }
> 146 | throw new InnertubeError(`Request to ${response.url} failed with status ${response.status}`, await response.text());
| ^
147 | }
148 |
149 | #adjustContext(ctx: Context, client: string): void {
at HTTPClient.<anonymous> (src/utils/HTTPClient.ts:146:11)
at fulfilled (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:164:62)
● YouTube.js Tests › YouTube Music › Innertube#music.getLyrics
Lyrics not available
327 |
328 | if (page.contents.item().type === 'Message')
> 329 | throw new InnertubeError(page.contents.item().as(Message).text.toString(), video_id);
| ^
330 |
331 | const section_list = page.contents.item().as(SectionList).contents;
332 |
at Music.<anonymous> (src/core/clients/Music.ts:329:13)
at fulfilled (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:164:62)
● YouTube.js Tests › YouTube Music › Innertube#music.getUpNext
expect(received).toBeDefined()
Received: undefined
384 | test('Innertube#music.getUpNext', async () => {
385 | const upnext = await innertube.music.getUpNext('eaJHysi5tYg');
> 386 | expect(upnext).toBeDefined();
| ^
387 | expect(upnext?.contents).toBeDefined();
388 | expect(upnext?.contents?.length).toBeGreaterThan(0);
389 | });
at test/main.test.ts:386:22
at fulfilled (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:164:62)
● YouTube.js Tests › YouTube Music › Innertube#music.getRelated
Cannot cast Message to one of SectionList
35 | as<T extends YTNode, K extends YTNodeConstructor<T>[]>(...types: K): InstanceType<K[number]> {
36 | if (!this.is(...types)) {
> 37 | throw new ParsingError(`Cannot cast ${this.type} to one of ${types.map((t) => t.type).join(', ')}`);
| ^
38 | }
39 | return this;
40 | }
at Message.as (src/parser/helpers.ts:37:13)
at Music.<anonymous> (src/core/clients/Music.ts:300:42)
at fulfilled (node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:164:62)
Test Suites: 1 failed, 1 total
Tests: 9 failed, 33 passed, 42 total
Snapshots: 0 total
Time: 31.87 s
Ran all test suites.
ELIFECYCLE Test failed. See above for more details.
And running locally only the HomeFeed#getContinuation
test fails (with the same error). Everything else is fine.
for more than 2 weeks, I've been getting the error in the title again for a long time a week. Although I couldn't upgrade to a 9.1.0 version when it made the update, it worked on its own and after a while the same error started happening again. I wanted to give you this information in case it might be useful to you. @LuanRT
@byadems If you are using normal YouTube stuff (so not YouTube Music), the fix is to upgrade to 9.1.0, if it occasionally starts working that's just YouTube messing around but upgrading will definitely fix it.
@Azarattum Definitely sounds like YouTube Music doesn't like your other machine. The only thing I can think of is that maybe the YouTube Music client version that YouTube.js is using for YouTube Music too old, otherwise you might want to change the IP address on the machine your are having issues on (YouTube doesn't like people doing too many requests at the same time, the more you look like a normal human user, the less problems you'll have).
@byadems If you are using normal YouTube stuff (so not YouTube Music), the fix is to upgrade to 9.1.0, if it occasionally starts working that's just YouTube messing around but upgrading will definitely fix it.
I think if I could raise it, I wouldn't write from here. Please do not comment until you have read the written messages. I think I'm being clear.
@absidue is there a way to compare/update YouTube Music client version? I'm afraid changing the IP address isn't an option...
Steps to reproduce
dlsong will be enough to encounter this error.
Failure Logs
Expected behavior
Successfully download a video or song file
Current behavior
He constantly makes mistakes
Version
Default
Anything else?
No response
Checklist