Skip to content

Commit 24a37b8

Browse files
committed
Use pre-generated playerResponse field in yt's getHlsUrl()
Also refactored code to always throw exception when the url can't be found
1 parent 9c423a0 commit 24a37b8

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -429,22 +429,15 @@ public String getDashMpdUrl() throws ParsingException {
429429
@Override
430430
public String getHlsUrl() throws ParsingException {
431431
assertPageFetched();
432-
try {
433-
String hlsvp = "";
434-
if (playerArgs != null) {
435-
if( playerArgs.isString("hlsvp") ) {
436-
hlsvp = playerArgs.getString("hlsvp", "");
437-
}else {
438-
hlsvp = JsonParser.object()
439-
.from(playerArgs.getString("player_response", "{}"))
440-
.getObject("streamingData", new JsonObject())
441-
.getString("hlsManifestUrl", "");
442-
}
443-
}
444432

445-
return hlsvp;
433+
try {
434+
return playerResponse.getObject("streamingData").getString("hlsManifestUrl");
446435
} catch (Exception e) {
447-
throw new ParsingException("Could not get hls manifest url", e);
436+
if (playerArgs != null && playerArgs.isString("hlsvp")) {
437+
return playerArgs.getString("hlsvp");
438+
} else {
439+
throw new ParsingException("Could not get hls manifest url", e);
440+
}
448441
}
449442
}
450443

0 commit comments

Comments
 (0)