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

fix: address filterWrapper is not iterable error #210

Closed
wants to merge 2 commits into from

Conversation

reply2za
Copy link
Contributor

@reply2za reply2za commented Aug 5, 2023

Addresses issue#206

A quick and technically not ideal fix. This change adds a safety check so that if wrapper.subMenu returns undefined, then the method returns an empty filter map, instead of throwing an error. This will likely always be the case now and this code does not address the root issue.

The fact of the matter is that YouTube likely updated their payload data (thus breaking the filter feature). The main fix would be updating the path to searchFilterGroupRenderer, which still exists. The point of this PR, at the very least, is to add a safety check to allow for YTSR to return search data, which is much better than not returning anything at all whenever YouTube updates their response.

Furthermore, I did take a look into the new payload and found that filter data could maybe be retrieved like this:

exports.parseFilters = json => {
  const pc = json.header.searchHeaderRenderer.searchFilterButton.buttonRenderer.command.openPopupAction.popup;
  const filterWrapper = pc.searchFilterOptionsDialogRenderer.groups || [];
  const parsedGroups = new Map();
...

I did not make a PR with this code (yet) for a few reasons. Firstly because all the tests that rely on local HTML data fail, because this code only expects the new payload format. Also the typings have to be updated.

Update:
I updated the code to support both the old and new payload formats.

Thanks,
Reply2za

@Domjan1911
Copy link

Hi, where is this utils.js , I can't find it, I tried searching for Freetube on whereis Freetube but on my terminal it shows nothing, I'm a Linux newbie.

@SergioAcostaTer
Copy link

pls fix it

@reply2za
Copy link
Contributor Author

reply2za commented Aug 8, 2023

@Domjan1911
The utils.js file is within node modules. node modules -> ytsr -> lib -> utils.js

The utils.js code I am using is this.

@TimeForANinja
Copy link
Owner

closing in favor of #203

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

Successfully merging this pull request may close these issues.

4 participants