Fix issue when there is no didYouMeanRenderer in itemSectionRenderer

This commit is contained in:
wb9688 2020-03-21 20:11:06 +01:00
parent 5a775a4bbe
commit dd434cca01
1 changed files with 4 additions and 2 deletions

View File

@ -176,8 +176,10 @@ public class YoutubeSearchExtractor extends SearchExtractor {
final JsonObject itemSectionRenderer = initialData.getObject("contents").getObject("sectionListRenderer")
.getArray("contents").getObject(0).getObject("itemSectionRenderer");
if (itemSectionRenderer == null) return "";
return getTextFromObject(itemSectionRenderer.getArray("contents").getObject(0)
.getObject("didYouMeanRenderer").getObject("correctedQuery"));
final JsonObject didYouMeanRenderer = itemSectionRenderer.getArray("contents")
.getObject(0).getObject("didYouMeanRenderer");
if (didYouMeanRenderer == null) return "";
return getTextFromObject(didYouMeanRenderer.getObject("correctedQuery"));
} else {
JsonObject showingResultsForRenderer = initialData.getObject("contents")
.getObject("twoColumnSearchResultsRenderer").getObject("primaryContents")