LuanRT / YouTube.js

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

latest version - unexpected token (1:47) #683

Closed honzawashere closed 2 months ago

honzawashere commented 3 months ago

Steps to reproduce

  1. use getInfo() function with platform "WEB" or "YTMUSIC"
  2. you'll get the error

Failure Logs

SyntaxError: Unexpected token (1:47)
    at pp$4.raise (node_modules\acorn\dist\acorn.js:3586:15)
    at pp$9.unexpected (node_modules\acorn\dist\acorn.js:772:10)
    at pp$9.semicolon (node_modules\acorn\dist\acorn.js:749:68)
    at pp$8.parseVarStatement (node_modules\acorn\dist\acorn.js:1192:10)
    at pp$8.parseStatement (node_modules\acorn\dist\acorn.js:927:19)
    at pp$8.parseBlock (node_modules\acorn\dist\acorn.js:1260:23)
    at pp$5.parseFunctionBody (node_modules\acorn\dist\acorn.js:3404:24)
    at pp$8.parseFunction (node_modules\acorn\dist\acorn.js:1382:10)
    at pp$8.parseFunctionStatement (node_modules\acorn\dist\acorn.js:1076:17)
    at pp$8.parseStatement (node_modules\acorn\dist\acorn.js:915:19) {
  pos: 47,
  loc: Position { line: 1, column: 47 },
  raisedAt: 56
}

Expected behavior

I expected my node.js express server to return the info as an response

Current behavior

instead of getting info, i'm getting an error

Version

Default

Anything else?

i don't know, i've already provided enough information for this issue. if the code is needed, i can also provide if you ask for it.

Checklist

honzawashere commented 3 months ago

*not with platform, but with client "WEB" or "YTMUSIC"

1162064779 commented 2 months ago

Same problem,changing the client to ANDROID solved this. The problem with the web client may be caused by ytdlp issues.

retrouser955 commented 2 months ago

Same problem here!

phobu commented 2 months ago

got the same issue :(

rahmangans commented 2 months ago

same issue :( please helpp

PikachuEXE commented 2 months ago

Please only comment if you have additional info to avoid spam notifications Put reaction on OP to signal that you have the same issue Thx

honzawashere commented 2 months ago

Same problem,changing the client to ANDROID solved this. The problem with the web client may be caused by ytdlp issues.

That's actually really cool. Switched to "ANDROID" and everything works completely normal! Also "YTMUSIC_ANDROID" is working for me.

PikachuEXE commented 2 months ago

In FreeTube we have to remove previous player cache entry But only applicable to those passing cache when using Innertube.create Might be applicable to your case

https://github.com/FreeTubeApp/FreeTube/pull/5384/files#diff-f4ca67281c6be819c2166841d7631ffd5316d4c3a3b40e01a512c4113a537b2c

rizer234 commented 2 months ago

Update package version to latest(v10.1.0). this bug has been resolved.

binbard commented 2 months ago

@rizer234 not working, already on latest vesion (v10.1.0).

file:///D:/doe/dev/my/ytd/node_modules/jintr/dist/main.js:53 throw new JinterError(e.message); ^ JinterError: Unexpected token (1:47) at Jinter.evaluate (file:///D:/doe/my/ytd/node_modules/jintr/dist/main.js:53:19) at Object.evaluate [as eval] (file:///D:/doe/my/ytd/node_modules/youtubei.js/dist/src/platform/jsruntime/jinter.js:10:28) at Player.decipher (file:///D:/doe/my/ytd/node_modules/youtubei.js/dist/src/core/Player.js:77:38) at Format.decipher (file:///D:/doe/my/ytd/node_modules/youtubei.js/dist/src/parser/classes/misc/Format.js:126:23) at Module. (file:///D:/doe/my/ytd/node_modules/youtubei.js/dist/src/utils/FormatUtils.js:14:35) at Generator.next () at D:\doe\try\my\ytd\node_modules\tslib\tslib.js:169:75 at new Promise () at __awaiter (D:\doe\my\ytd\node_modules\tslib\tslib.js:165:16) at Module.download (file:///D:/doe/my/ytd/node_modules/youtubei.js/dist/src/utils/FormatUtils.js:5:12) Node.js v20.15.0

while running download example given in readme

honzawashere commented 2 months ago

Update package version to latest(v10.1.0). this bug has been resolved.

the bug is not resolved yet, and for some reason I am also getting another error now when trying to run the same function with ANDROID client now...

Error: Request to https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json failed with status 404

binbard commented 2 months ago

@honzawashere Same problem of 404 i get with some clients including ANDROID

honzawashere commented 2 months ago

@honzawashere Same problem of 404 i get with some clients including ANDROID

according to some sources, YouTube itself changed some scripts of their app and that's probably why we're receiving the unexpected token error. but about the 404 error, i don't really know what's causing it. in my case i'm logged in to account on my session and maybe that's also causing something but i'm assuming right now something changed with youtube's API, because after trying multiple clients i wasn't able to get it working!

InnertubeError: Request to https://www.youtube.com/youtubei/v1/next?prettyPrint=false&alt=json failed with status 404 at HTTPClient. (node_modules\youtubei.js\bundle\node.cjs:2081:13) at Generator.next () at fulfilled (node_modules\tslib\tslib.js:166:62) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { info: '{\n' + ' "error": {\n' + ' "code": 404,\n' + ' "message": "Requested entity was not found.",\n' + ' "errors": [\n' + ' {\n' + ' "message": "Requested entity was not found.",\n' + ' "domain": "global",\n' + ' "reason": "notFound"\n' + ' }\n' + ' ],\n' + ' "status": "NOT_FOUND"\n' + ' }\n' + '}\n', date: 2024-07-14T10:31:11.568Z, version: '10.1.0' }

also it's weird to see that it's trying to use "/next" when getting info from video imho. but let's hope it gets quickly fixed.

EDIT: this was my bad, i actually forgot to set UniversalCache to be persistent. i fixed it with iOS client

absidue commented 2 months ago

@binbard If you have the cache setup, make sure you clear the cache after upgrading.

honzawashere commented 2 months ago

@binbard If you have the cache setup, make sure you clear the cache after upgrading.

yeah, after cleaning the cache and setting up everything again, the android and ios somehow started working for me.