twlite / youtube-sr

A dead-simple youtube metadata scraper
https://npmjs.com/package/youtube-sr
MIT License
113 stars 16 forks source link

Update youtube query url #21

Closed ShortByte closed 3 years ago

ShortByte commented 3 years ago

The query search for the Youtube URL has been changed. The Youtube URL is built differently and does not use the standard URL encoding. In the query part only the spaces are changed to + characters.

This extremely changes the search results and you get wrong answers.

ShortByte commented 3 years ago

.replaceAll(" ", "+") for in the end also a regex. I also added the & character, otherwise it would cause problems with query building.

twlite commented 3 years ago

% => %25 $ => %24 @ => %40

image

also ? => %3F # => %23 ^ => %5E = => %3D , => %2C

twlite commented 3 years ago

What about encodeURIComponent(query).replaceAll("%20", "+")?

ShortByte commented 3 years ago

I was just thinking the same thing. Since I had tested in the browser and had considered that the browser itself replaces the special characters. Should I push this solution?

twlite commented 3 years ago

I guess

ShortByte commented 3 years ago

I just noticed again that replaceAll does not exist in JavaScript. I remembered it also from Java.

twlite commented 3 years ago

lgtm