From 2aae9f52d58d3619cb4dcb388095cad2ebc858cf Mon Sep 17 00:00:00 2001 From: Sorin Postelnicu Date: Sun, 13 Aug 2023 19:32:25 +0200 Subject: [PATCH] Fixed NullPointerException in YoutubeSearchQueryHandlerFactory --- .../YoutubeSearchQueryHandlerFactory.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java index 44b036be6e..32dc504243 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java @@ -43,19 +43,21 @@ public String getUrl(final String searchString, try { if (!contentFilters.isEmpty()) { final String contentFilter = contentFilters.get(0); - switch (contentFilter) { - case VIDEOS: - return SEARCH_URL + encodeUrlUtf8(searchString) + "&sp=EgIQAQ%253D%253D"; - case CHANNELS: - return SEARCH_URL + encodeUrlUtf8(searchString) + "&sp=EgIQAg%253D%253D"; - case PLAYLISTS: - return SEARCH_URL + encodeUrlUtf8(searchString) + "&sp=EgIQAw%253D%253D"; - case MUSIC_SONGS: - case MUSIC_VIDEOS: - case MUSIC_ALBUMS: - case MUSIC_PLAYLISTS: - case MUSIC_ARTISTS: - return MUSIC_SEARCH_URL + encodeUrlUtf8(searchString); + if (contentFilter != null) { + switch (contentFilter) { + case VIDEOS: + return SEARCH_URL + encodeUrlUtf8(searchString) + "&sp=EgIQAQ%253D%253D"; + case CHANNELS: + return SEARCH_URL + encodeUrlUtf8(searchString) + "&sp=EgIQAg%253D%253D"; + case PLAYLISTS: + return SEARCH_URL + encodeUrlUtf8(searchString) + "&sp=EgIQAw%253D%253D"; + case MUSIC_SONGS: + case MUSIC_VIDEOS: + case MUSIC_ALBUMS: + case MUSIC_PLAYLISTS: + case MUSIC_ARTISTS: + return MUSIC_SEARCH_URL + encodeUrlUtf8(searchString); + } } }