mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Don't parse manifest and add proxyUrl for clientside rewrites.
This commit is contained in:
parent
d53459171f
commit
f00153205e
2 changed files with 4 additions and 22 deletions
|
@ -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<String> resp = Constants.h2client
|
||||
.send(HttpRequest.newBuilder(URI.create(hls)).GET().build(), BodyHandlers.ofLines()).body();
|
||||
ObjectArrayList<String> 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,
|
||||
|
|
|
@ -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<PipedStream> audioStreams, List<PipedStream> videoStreams, List<StreamItem> relatedStreams,
|
||||
|
|
Loading…
Reference in a new issue