node-ytsr icon indicating copy to clipboard operation
node-ytsr copied to clipboard

Need options to NOT follow correctedQuery

Open Bananamilk452 opened this issue 3 years ago • 6 comments

When I search some video id, it searches weird things because the original query is changing. I don't know this problem is caused by youtube or this library.

Example:

When I search video id 47PchnnBBJA, (its game soundtrack) It changes to correctedQuery: '47 cannABIS'. So it gives me cannabis videos. but it solves when I change my hl, gl to my locale (ko-KR).

image

I think we need an option to not follow correctedQuery or features to search video id.

Bananamilk452 avatar Oct 15 '21 14:10 Bananamilk452

that's a youtube feature the web client behaves the same: image

clicking the link just appends &sp=QgIIAQ%253D%2 to the query url the sp parameter is the same used for filters i expect it to be some kinda bitmap but i wasn't able to figure it out yet for that reason i also never implemented an easy way to pass sp paramters to ytsr

TimeForANinja avatar Oct 17 '21 02:10 TimeForANinja

sp seems it's a fixed filter value. you can also find out on every filter link href.

but I don't think it have some meaning. it just increasing number by rule.

image1

and i also find some info on other youtube search engine library. sp is just fixed value. not changing.

image

so can we add this feature? also i think it will be good if this option is default parameter.

Bananamilk452 avatar Oct 18 '21 11:10 Bananamilk452

it gets a bit harder since for some categories (e.g. Features) you can set multiple filters while for categories (e.g Sort By) you can only set one other than that i'd much prefer a way to set filters without doing web-requests (the way it's currently implemented)

TimeForANinja avatar Oct 18 '21 11:10 TimeForANinja

It's okay if this isn't a default parameter. However, I can't understand well how the filter is implemented, but what I just found out is that if I decode the sp parameter applied to the original filter to binary, paste the binary decoded sp parameter (QgIIAQ==) to the back, and then encode it back to base64 and it works. Could this be possible?

example:

const filters1 = await ytsr.getFilters('some keyword doesnt search properly');
const filter1 = filters1.get('Type').get('Video');
const filters2 = await ytsr.getFilters(filter1.url);
const filter2 = filters2.get('Features').get('Live');
const options = {
  exactMatch: true,
}

/*
if exactMatch is true, and it has no option

=> add sp "QgIIAQ==" to query object. result: ( query: { gl: 'US', hl: 'en', search_query: 'github' , sp: 'QgIIAQ=='} )

if exactMatch is true and it has sp.

=> decode sp, and paste binary-decoded 'QgIIAQ==' to the back and encode, update the sp
*/

const searchResults = await ytsr(filter2.url, options);

// result sp is EgQQAUABQgIIAQ==

Bananamilk452 avatar Oct 18 '21 12:10 Bananamilk452

i made package with implementation of this issue + filters without get

better-ytsr

Bananamilk452 avatar Oct 24 '21 08:10 Bananamilk452

that would allow to set at least a single filter...

TimeForANinja avatar Dec 22 '21 22:12 TimeForANinja