node-ytsr
node-ytsr copied to clipboard
Need options to NOT follow correctedQuery
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).
I think we need an option to not follow correctedQuery or features to search video id.
that's a youtube feature
the web client behaves the same:
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
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.
and i also find some info on other youtube search engine library. sp
is just fixed value. not changing.
so can we add this feature? also i think it will be good if this option is default parameter.
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)
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==
that would allow to set at least a single filter...