Fix NPE in getPlaylistHeader() when browseMetadataResponse is null#1510
Fix NPE in getPlaylistHeader() when browseMetadataResponse is null#1510dweep-js wants to merge 1 commit into
Conversation
On playlist continuation pages (getPage()), browseMetadataResponse is not set, causing a NullPointerException when getPlaylistHeader() tries to call .getObject() on it. Fix by returning an empty JsonObject early when browseMetadataResponse is null, avoiding the crash on subsequent playlist page loads. Fixes: TeamNewPipe/NewPipe#13593
|
absurdlylongusername
left a comment
There was a problem hiding this comment.
Please add regression tests that address this bug fix, so can easily verify that it doesn't work without the fix, and does work with the fix.
This makes it quicker to test changes without having to reproduce it manually in NewPipe
AudricV
left a comment
There was a problem hiding this comment.
Thank you for your pull request.
While this fixes the null pointer exception, methods used by getPage of a new YoutubePlaylistExtractor instance relying on browseMetadataResponse to check for something won't work properly (and for other fields used too).
Instead, a proper fix would be to propagate in the page IDs the needed data like done in YoutubeChannelTabExtractor. In this case, only the result of isCoursePlaylist needs to be saved.
So you should:
- remove the
isCoursePlaylistfield - add a
isCoursePlaylistboolean parameter tocollectStreamsFrommethod - use the extraction code currently in the
isCoursePlaylistmethod as the value of this new boolean parameter in thegetInitialPagemethod - add a
pageID toPageobjects built bygetNextPageFrom, by passing theisCoursePlaylistboolean as a string. To do so, use thePage(String, String, List<String>, Map<String, String>, byte[])constructor with the following (the current url value, null, List.of(isCoursePlaylist), null, body) - retrieve the string value in
getPageand convert it to a boolean, while handling the lack of the ID by usingfalsein this case. Then pass this boolean value in thecollectStreamsFromcall.
If that's too complex for you, that's fine, I wanted to fix this issue, so I can do this in a different PR.



On playlist continuation pages (getPage()), browseMetadataResponse is not set, causing a NullPointerException when getPlaylistHeader() tries to call .getObject() on it.
Fix by returning an empty JsonObject early when browseMetadataResponse is null, avoiding the crash on subsequent playlist page loads.
Fixes: TeamNewPipe/NewPipe#13593