From 50c4783f71ecf4d8841289d0ef96f2f3e5eca0f7 Mon Sep 17 00:00:00 2001 From: Ritvik Saraf <13ritvik@gmail.com> Date: Sat, 19 Jan 2019 17:31:21 +0530 Subject: [PATCH] fixed extracting hls url --- .../extractors/YoutubeStreamExtractor.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 4801fa461..3b614fc36 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -5,6 +5,7 @@ import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParserException; import org.jsoup.Jsoup; +import org.jsoup.helper.StringUtil; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; @@ -386,13 +387,18 @@ public class YoutubeStreamExtractor extends StreamExtractor { public String getHlsUrl() throws ParsingException { assertPageFetched(); try { - String hlsvp; - if (playerArgs != null && playerArgs.isString("hlsvp")) { - hlsvp = playerArgs.getString("hlsvp", ""); - } else { - return ""; + 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; } catch (Exception e) { throw new ParsingException("Could not get hls manifest url", e);