Use pre-generated playerResponse field in yt's getHlsUrl()

Also refactored code to always throw exception when the url can't be found
This commit is contained in:
Stypox 2019-09-11 20:12:30 +02:00
parent 9c423a0a40
commit 24a37b88a9
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 7 additions and 14 deletions

View File

@ -429,24 +429,17 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override
public String getHlsUrl() throws ParsingException {
assertPageFetched();
try {
String hlsvp = "";
if (playerArgs != null) {
if( playerArgs.isString("hlsvp") ) {
hlsvp = playerArgs.getString("hlsvp", "");
}else {
hlsvp = JsonParser.object()
.from(playerArgs.getString("player_response", "{}"))
.getObject("streamingData", new JsonObject())
.getString("hlsManifestUrl", "");
}
}
return hlsvp;
try {
return playerResponse.getObject("streamingData").getString("hlsManifestUrl");
} catch (Exception e) {
if (playerArgs != null && playerArgs.isString("hlsvp")) {
return playerArgs.getString("hlsvp");
} else {
throw new ParsingException("Could not get hls manifest url", e);
}
}
}
@Override
public List<AudioStream> getAudioStreams() throws ExtractionException {