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:
parent
9c423a0a40
commit
24a37b88a9
|
@ -429,22 +429,15 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
@Override
|
@Override
|
||||||
public String getHlsUrl() throws ParsingException {
|
public String getHlsUrl() throws ParsingException {
|
||||||
assertPageFetched();
|
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) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get hls manifest url", e);
|
if (playerArgs != null && playerArgs.isString("hlsvp")) {
|
||||||
|
return playerArgs.getString("hlsvp");
|
||||||
|
} else {
|
||||||
|
throw new ParsingException("Could not get hls manifest url", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue