Fix NPE when extracting itags with non-existing streamingData key

This commit is contained in:
Stypox 2019-09-12 15:08:17 +02:00
parent 0d8fb65003
commit 3f1ba93be5
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 5 additions and 1 deletions

View File

@ -915,8 +915,12 @@ public class YoutubeStreamExtractor extends StreamExtractor {
private Map<String, ItagItem> getItags(String streamingDataKey, ItagItem.ItagType itagTypeWanted) throws ParsingException {
Map<String, ItagItem> urlAndItags = new LinkedHashMap<>();
JsonObject streamingData = playerResponse.getObject("streamingData");
if (!streamingData.has(streamingDataKey)) {
return urlAndItags;
}
JsonArray formats = playerResponse.getObject("streamingData").getArray(streamingDataKey);
JsonArray formats = streamingData.getArray(streamingDataKey);
for (int i = 0; i != formats.size(); ++i) {
JsonObject formatData = formats.getObject(i);
int itag = formatData.getInt("itag");