fixed extracting hls url

This commit is contained in:
Ritvik Saraf 2019-01-19 17:31:21 +05:30
parent 99915e4527
commit 50c4783f71

View File

@ -5,6 +5,7 @@ import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException; import com.grack.nanojson.JsonParserException;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.helper.StringUtil;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
@ -386,11 +387,16 @@ public class YoutubeStreamExtractor extends StreamExtractor {
public String getHlsUrl() throws ParsingException { public String getHlsUrl() throws ParsingException {
assertPageFetched(); assertPageFetched();
try { try {
String hlsvp; String hlsvp = "";
if (playerArgs != null && playerArgs.isString("hlsvp")) { if (playerArgs != null) {
if( playerArgs.isString("hlsvp") ) {
hlsvp = playerArgs.getString("hlsvp", ""); hlsvp = playerArgs.getString("hlsvp", "");
} else { }else {
return ""; hlsvp = JsonParser.object()
.from(playerArgs.getString("player_response", "{}"))
.getObject("streamingData", new JsonObject())
.getString("hlsManifestUrl", "");
}
} }
return hlsvp; return hlsvp;