diff --git a/src/main/java/me/kavin/piped/utils/CollectionUtils.java b/src/main/java/me/kavin/piped/utils/CollectionUtils.java index ea4efe8..e442c51 100644 --- a/src/main/java/me/kavin/piped/utils/CollectionUtils.java +++ b/src/main/java/me/kavin/piped/utils/CollectionUtils.java @@ -13,6 +13,7 @@ import org.schabi.newpipe.extractor.stream.StreamType; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Optional; import static me.kavin.piped.utils.URLUtils.*; @@ -42,18 +43,23 @@ public class CollectionUtils { boolean livestream = info.getStreamType() == StreamType.LIVE_STREAM; + final var extraParams = Map.of( + "ump", "1", + "srfvp", "1" + ); + if (!livestream) { - info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(stream.getItag(), rewriteVideoURL(stream.getContent()), + info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(stream.getItag(), rewriteVideoURL(stream.getContent(), extraParams), String.valueOf(stream.getFormat()), stream.getResolution(), stream.getFormat().getMimeType(), true, stream.getBitrate(), stream.getInitStart(), stream.getInitEnd(), stream.getIndexStart(), stream.getIndexEnd(), stream.getCodec(), stream.getWidth(), stream.getHeight(), stream.getFps(), stream.getItagItem().getContentLength()))); info.getVideoStreams() .forEach(stream -> videoStreams - .add(new PipedStream(stream.getItag(), rewriteVideoURL(stream.getContent()), String.valueOf(stream.getFormat()), + .add(new PipedStream(stream.getItag(), rewriteVideoURL(stream.getContent(), Map.of()), String.valueOf(stream.getFormat()), stream.getResolution(), stream.getFormat().getMimeType(), false, stream.getItagItem().getContentLength()))); info.getAudioStreams() - .forEach(stream -> audioStreams.add(new PipedStream(stream.getItag(), rewriteVideoURL(stream.getContent()), + .forEach(stream -> audioStreams.add(new PipedStream(stream.getItag(), rewriteVideoURL(stream.getContent(), extraParams), String.valueOf(stream.getFormat()), stream.getAverageBitrate() + " kbps", stream.getFormat().getMimeType(), false, stream.getBitrate(), stream.getInitStart(), stream.getInitEnd(), stream.getIndexStart(), stream.getIndexEnd(), stream.getItagItem().getContentLength(), stream.getCodec(), stream.getAudioTrackId(), @@ -73,8 +79,8 @@ public class CollectionUtils { info.getTextualUploadDate(), info.getUploaderName(), substringYouTube(info.getUploaderUrl()), getLastThumbnail(info.getUploaderAvatars()), getLastThumbnail(info.getThumbnails()), info.getDuration(), info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.getUploaderSubscriberCount(), info.isUploaderVerified(), - audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteVideoURL(info.getHlsUrl()), - rewriteVideoURL(info.getDashMpdUrl()), null, info.getCategory(), info.getLicence(), + audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteVideoURL(info.getHlsUrl(), Map.of()), + rewriteVideoURL(info.getDashMpdUrl(), Map.of()), null, info.getCategory(), info.getLicence(), info.getPrivacy().name().toLowerCase(), info.getTags(), metaInfo, chapters, previewFrames); } diff --git a/src/main/java/me/kavin/piped/utils/URLUtils.java b/src/main/java/me/kavin/piped/utils/URLUtils.java index 7a8184a..46c1678 100644 --- a/src/main/java/me/kavin/piped/utils/URLUtils.java +++ b/src/main/java/me/kavin/piped/utils/URLUtils.java @@ -12,10 +12,7 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Comparator; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; +import java.util.*; import static me.kavin.piped.consts.Constants.PROXY_HASH_SECRET; @@ -44,18 +41,18 @@ public class URLUtils { } public static String rewriteURL(final String old) { - return rewriteURL(old, Constants.IMAGE_PROXY_PART); + return rewriteURL(old, Constants.IMAGE_PROXY_PART, Map.of()); } public static String getLastThumbnail(final List thumbnails) { return thumbnails.isEmpty() ? null : rewriteURL(thumbnails.getLast().getUrl()); } - public static String rewriteVideoURL(final String old) { - return rewriteURL(old, Constants.PROXY_PART); + public static String rewriteVideoURL(final String old, final Map extraParams) { + return rewriteURL(old, Constants.PROXY_PART, extraParams); } - public static String rewriteURL(final String old, final String proxy) { + public static String rewriteURL(final String old, final String proxy, final Map extraParams) { if (StringUtils.isEmpty(old)) return null; @@ -109,6 +106,10 @@ public class URLUtils { queryPairs.add(List.of("host", host)); } + for (var entry : extraParams.entrySet()) { + queryPairs.add(List.of(entry.getKey(), entry.getValue())); + } + String path = url.getPath(); if (path.contains("=")) {