From f00153205e1bcdae482047904156feb0205c5c1b Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 10 Jun 2021 02:50:53 +0530 Subject: [PATCH] Don't parse manifest and add proxyUrl for clientside rewrites. --- .../me/kavin/piped/utils/ResponseHelper.java | 22 ------------------- .../me/kavin/piped/utils/obj/Streams.java | 4 ++++ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index 902d3ad..d4c80ca 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -11,7 +11,6 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.json.JSONObject; import org.schabi.newpipe.extractor.InfoItem; @@ -103,27 +102,6 @@ public class ResponseHelper { if ((hls = info.getHlsUrl()) != null && !hls.isEmpty()) livestream = true; - if (hls != null) { - - java.util.stream.Stream resp = Constants.h2client - .send(HttpRequest.newBuilder(URI.create(hls)).GET().build(), BodyHandlers.ofLines()).body(); - ObjectArrayList lines = new ObjectArrayList<>(); - resp.forEach(line -> lines.add(line)); - - for (int i = lines.size() - 1; i > 2; i--) { - String line = lines.get(i); - if (line.startsWith("https://manifest.googlevideo.com")) { - String prevLine = lines.get(i - 1); - String height = StringUtils.substringBetween(prevLine, "RESOLUTION=", ",").split("x")[1]; - int fps = Integer.parseInt(StringUtils.substringBetween(prevLine, "FRAME-RATE=", ",")); - String quality = height + "p"; - if (fps > 30) - quality += fps; - videoStreams.add(new PipedStream(line, "HLS", quality, "application/x-mpegURL", false)); - } - } - } - if (!livestream) { info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(rewriteURL(stream.getUrl()), String.valueOf(stream.getFormat()), stream.getResolution(), stream.getFormat().getMimeType(), true, diff --git a/src/main/java/me/kavin/piped/utils/obj/Streams.java b/src/main/java/me/kavin/piped/utils/obj/Streams.java index fa7d578..2edfda2 100644 --- a/src/main/java/me/kavin/piped/utils/obj/Streams.java +++ b/src/main/java/me/kavin/piped/utils/obj/Streams.java @@ -2,6 +2,8 @@ package me.kavin.piped.utils.obj; import java.util.List; +import me.kavin.piped.consts.Constants; + public class Streams { public String title, description, uploadDate, uploader, uploaderUrl, uploaderAvatar, thumbnailUrl, hls; @@ -16,6 +18,8 @@ public class Streams { public boolean livestream; + public final String proxyUrl = Constants.PROXY_PART; + public Streams(String title, String description, String uploadDate, String uploader, String uploaderUrl, String uploaderAvatar, String thumbnailUrl, long duration, long views, long likes, long dislikes, List audioStreams, List videoStreams, List relatedStreams,