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 1/2] 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); From c60d6ec0abb0e8fee9ec1f93398d3a69bf643a09 Mon Sep 17 00:00:00 2001 From: Ritvik Saraf <13ritvik@gmail.com> Date: Sat, 19 Jan 2019 18:20:02 +0530 Subject: [PATCH 2/2] removed unused import --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 3 +-- 1 file changed, 1 insertion(+), 2 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 3b614fc36..4b21a06ae 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,7 +5,6 @@ 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; @@ -398,7 +397,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { .getString("hlsManifestUrl", ""); } } - + return hlsvp; } catch (Exception e) { throw new ParsingException("Could not get hls manifest url", e);