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

Need options to NOT follow correctedQuery #146

Open
Bananamilk452 opened this issue Oct 15, 2021 · 6 comments
Open

Need options to NOT follow correctedQuery #146

Bananamilk452 opened this issue Oct 15, 2021 · 6 comments

Comments

@Bananamilk452
Copy link

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.

@TimeForANinja
Copy link
Owner

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

@Bananamilk452
Copy link
Author

Bananamilk452 commented Oct 18, 2021

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.

@TimeForANinja
Copy link
Owner

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)

@Bananamilk452
Copy link
Author

Bananamilk452 commented Oct 18, 2021

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
Copy link
Author

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

better-ytsr

@TimeForANinja
Copy link
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants