damonwonghv / youtube-search-api

Get Youtube Search result without any login or api key
MIT License
86 stars 30 forks source link

[SyntaxError: JSON Parse error: Unexpected character: '] when ran on iOS simulator inside react-native app #28

Open silencer07 opened 10 months ago

silencer07 commented 10 months ago

works fine with android.

basically I tried copy pasting the code, and added some logs

console.log("before JSON.parse 2", decodeURI(data));
initdata = await JSON.parse(data);

the output is:

before JSON.parse 2  '\x7b\x22responseContext\x22:\x7b\x22serviceTrackingParams\x22:\x5b\x7b\x22service\x22:\x22GFEEDBACK\x22,\x22params\x22:\x5b\x7b\x22key\x22:\x22has_unlimited_entitlement\x22,\x22value\x22:\x22False\x22\x7d,\x7b\x22key\x22:\x22has_premium_lite_entitlement\x22,\x22value\x22:\x22False\x22\x7d,\x7b\x22key\x22:\x22logged_in\x22,\x22value\x22:\x220\x22\x7d,\x7b\x22key\x22:\x22country-type\x22,\x22value\x22:\x22B\x22\x7d,\x7b\x22key\x22:\x22e\x22,\x22value\x22:\x2223804281,23946420,23966208,23983296,23998056,24004644,24007246,24034168,24036948,24077241,24080738,24120819,24135310,24140247,24166867,24181174,24187377,24241378,24255543,24255545,24288664,24290971,24367579,24377598,24377910,24382552,24385569,24385728,24387949,24390675,24428788,24428941,24428945,24439361,24451319,24453989,24458317,24458324,24458329,24458839,24459436,24468724,24485421,24490203,24506515,24506784,24515423,24518452,24524098,24524567,24537200,24539025,24542367,24542452, 
.....

do I need to do some sort of decoding or something

AdamElitzur commented 4 months ago

@silencer07 I got the same issue, did you find a solution or alternative for react-native? I'm using expo, and would love for this to work! Thanks!

silencer07 commented 4 months ago

Hi @AdamElitzur,

You will need to basically need to have an ios version of the code.

Or maybe you can try experiment and maybe find a way to force this library to send a header similar to what android is sending. Maybe that would make the response of server similar to android

AdamElitzur commented 4 months ago

Hi @silencer07, thanks so much. Looks very complicated, but I'll look into it! Did you fork the repo and make a new npm package, or what did you do?

silencer07 commented 4 months ago

@AdamElitzur I copy pasted the code and created my own js file and just modified the files.

I did not publish npm because it is for hobby app and the code is dirty :D

Good luck!

AdamElitzur commented 4 months ago

Ok, sounds good, thank you!

AdamElitzur commented 4 months ago

Oh one thing @silencer07, were you able to publish an app with this to the app store? I want to make sure it'll get approved. Thanks!

silencer07 commented 4 months ago

Yep. Search for videoke party maker remote in both app store and play store

collinscoder1 commented 4 months ago

Yep. Search for videoke party maker remote in both app store and play store

Provide a link to play store i want to download the app.