Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Unexpected token < in JSON at position 0 #71

Closed
eugabrielsilva opened this issue Oct 2, 2020 · 34 comments · Fixed by #91
Closed

Unexpected token < in JSON at position 0 #71

eugabrielsilva opened this issue Oct 2, 2020 · 34 comments · Fixed by #91
Labels

Comments

@eugabrielsilva
Copy link

Some searches are returning this error... probably something related to JSON.parse() function.

@TimeForANinja
Copy link
Owner

looks like a major rework from youtube's side
this are the new api-data i could pull from that page (if anyone cares to see)
json.txt

i know it's a problem that the library crashes but i'm unsure if it makes sense to adopt at fastest speed possible
this might lead to major changes and a lot of work

@dalisoft
Copy link

dalisoft commented Oct 9, 2020

Same issue

@eugabrielsilva
Copy link
Author

None of my searches are working anymore because of this and I really need this library for my Discord Bot :(
If it is possible to fix it, I would be extremely grateful...

@JackyKit123
Copy link

Same issue, but the problem doesn't occur in a consistent way. Sometime the same search query and option pass while sometimes it doesn't

@DenysAshikhin
Copy link

DenysAshikhin commented Oct 11, 2020

Would it be possible to have the current way and if it fails, attempt a more temporary duct-tape fix until we know for sure if the new API formatting will stay?

Or at least something we can do locally to force it to work upon a fail?

@MrZBou
Copy link

MrZBou commented Oct 16, 2020

Same problem, 75% of requests returns this

@mome0320
Copy link

Same problem

@TimeForANinja
Copy link
Owner

started working on it in https://github.com/TimeForANinja/node-ytsr/tree/wip-api-adjustments but have problems finding the time

@112batman
Copy link

same problem

1 similar comment
@kevin4dhd
Copy link

same problem

@kira0x1
Copy link

kira0x1 commented Oct 19, 2020

ive been getting this alot and while testing I realized its arbitrary one minute it I get it one minute I dont

@flaviotordini
Copy link

Hi all, until the bug is fixed I suggest this work around: in your script/app when you receive this error, clear the cookies in your http connection and retry. Do this until you get a working search, then keep the cookies.

@lxcool9243
Copy link

Hi all, until the bug is fixed I suggest this work around: in your script/app when you receive this error, clear the cookies in your http connection and retry. Do this until you get a working search, then keep the cookies.

How can I do this programmatically in an app running server side ?

@TulioAbreu
Copy link

😿 I'm having the same issue. Do you have any tips on how to hotfix this running inside Node environment?

@TimeForANinja
Copy link
Owner

started working on it in https://github.com/TimeForANinja/node-ytsr/tree/wip-api-adjustments but have problems finding the time

that's the only hotfix i can provide for now

@SoulHarsh007
Copy link

@cyph84
Copy link

cyph84 commented Oct 22, 2020

Seems like its happening 100% of the time now

@TimeForANinja
Copy link
Owner

Seems like its happening 100% of the time now

i'd count that as a good sign

@Siposattila
Copy link

Yeah the problem occurs 100% all the time... :c

@lxcool9243
Copy link

started working on it in https://github.com/TimeForANinja/node-ytsr/tree/wip-api-adjustments but have problems finding the time

that's the only hotfix i can provide for now

For now I am using YT Data API and waiting for this bug to resolve.

@kira0x1
Copy link

kira0x1 commented Oct 26, 2020

funny enough another API I found had a similar problem. If I get time ill try to help out.

@Klema4
Copy link

Klema4 commented Oct 27, 2020

I have a similar problem too ngl. Is there a way to fix this faster than the devs? I don't want to wait another month :(

@dalisoft
Copy link

I have a similar problem too ngl. Is there a way to fix this faster than the devs? I don't want to wait another month :(

Then help these devs to get fix faster

@kira0x1
Copy link

kira0x1 commented Oct 28, 2020

I have a similar problem too ngl. Is there a way to fix this faster than the devs? I don't want to wait another month :(

Then help these devs to get fix faster

They were asking if it was faster.

@kira0x1
Copy link

kira0x1 commented Oct 28, 2020

I have a similar problem too ngl. Is there a way to fix this faster than the devs? I don't want to wait another month :(

It is, I think the dev said theyre short on time so if you can spend time on the repo that would be good ❤️

@Klema4
Copy link

Klema4 commented Oct 29, 2020

I have a similar problem too ngl. Is there a way to fix this faster than the devs? I don't want to wait another month :(

It is, I think the dev said they're short on time so if you can spend time on the repo that would be good ❤️

Ok thx, I will wait then.

@TimeForANinja
Copy link
Owner

TimeForANinja commented Oct 29, 2020

@firsttobebear
Copy link

Is there an update on the status?

@Siposattila
Copy link

Nope! I will try to help the devs but I have to work sry this project where I need this lib is just a side project for my own satisfaction.

@firsttobebear
Copy link

Any update?

@TimeForANinja
Copy link
Owner

try the wip: npm i ytsr@wip

@batuhansahan
Copy link

has any usage doc changed, because im getting "search string is mandatory" error. @TimeForANinja

@TimeForANinja
Copy link
Owner

Yep, quite a few things changed
Wip will end up in a new major release and I'll propably write some 'how to port' notes

For your use case I'd have to guess without more intel
My guess: if you use filters check the /test/e3e-test.js for changes 😉

@batuhansahan
Copy link

batuhansahan commented Nov 26, 2020

thanks @TimeForANinja for anyone want to use new api

      const filters = await ytsr.getFilters("NoCopyrightMusic");
      const filter = filters.get('Type').find(a => a.label === 'Video');
      const search = await ytsr(filter.query, { limit: 25 });
      console.log(search);

@TimeForANinja TimeForANinja mentioned this issue Dec 11, 2020
5 tasks
TimeForANinja added a commit that referenced this issue Dec 13, 2020
- [x] fix requests

- [x] update exaple responses

- [x] update typings

- [x] update documentation / README

- [x] rewrite tests

closes #87 
closes #71 
closes #62 

# Porting code
* The Filters provided by `ytsr#getFilters` are now provided as Map of Maps instead of a Map of Arrays
* `result#originalQuery` and `result#correctedQuery` were introduced to differentiate the query that we asked for and the query that youtube provided results for
* all refinements are now found at `result#refinements` - sorted by relevance - instead of mixed into `result#items`
* `result#active` was renamed to `result#activeFilters`
* request options for miniget were moved to `options#requestOptions`
* nextpageRef was replaced by the continuation feature => check the README for more information
* boolean variables like `live` and `upcoming` were renamed to `isLive` and `isUpcoming`
* `ShelfCompact` and `ShelfVertical` were merged into a single type `shelf` which contains an array of any kind of other item - this required the addition of the `GridMovie`-Type (short version of `Movie`)
* The `show`-Type was added
* `playlist#author` was renamed to `playlist#owner`
* for the types `playlist` and `mix` the way thumbnail & firstItem are handled changed => check the typings or example responses
* `pages` was added as a more request-efficient alternative to `limit`
* all thumbnails are now `Image`-Objects with `url`, `width` and `height` properties - arrays of images are always sorted by descending resolution
* all links have been renamed from `ref` to `url` to keep it consistend across all libraries
* all snake_case variables were replaced by CamelCase
* all users/channels feature both the `channelID` as well as a canonical `url`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.