diff --git a/src/main/java/me/kavin/piped/server/handlers/StreamHandlers.java b/src/main/java/me/kavin/piped/server/handlers/StreamHandlers.java index 50cb034..320f4b5 100644 --- a/src/main/java/me/kavin/piped/server/handlers/StreamHandlers.java +++ b/src/main/java/me/kavin/piped/server/handlers/StreamHandlers.java @@ -214,7 +214,7 @@ public class StreamHandlers { } if (lbryURL != null) - streams.videoStreams.add(0, new PipedStream(lbryURL, "MP4", "LBRY", "video/mp4", false)); + streams.videoStreams.add(0, new PipedStream(lbryURL, "MP4", "LBRY", "video/mp4", false, -1)); // Attempt to get dislikes calculating with the RYD API rating if (streams.dislikes < 0 && streams.likes >= 0) { @@ -260,10 +260,10 @@ public class StreamHandlers { } if (lbryHlsURL != null) - streams.videoStreams.add(0, new PipedStream(lbryHlsURL, "HLS", "LBRY HLS", "application/x-mpegurl", false)); + streams.videoStreams.add(0, new PipedStream(lbryHlsURL, "HLS", "LBRY HLS", "application/x-mpegurl", false, -1)); if (lbryURL != null) - streams.videoStreams.add(0, new PipedStream(lbryURL, "MP4", "LBRY", "video/mp4", false)); + streams.videoStreams.add(0, new PipedStream(lbryURL, "MP4", "LBRY", "video/mp4", false, -1)); long time = info.getUploadDate() != null ? info.getUploadDate().offsetDateTime().toInstant().toEpochMilli() : System.currentTimeMillis(); diff --git a/src/main/java/me/kavin/piped/utils/CollectionUtils.java b/src/main/java/me/kavin/piped/utils/CollectionUtils.java index 452f476..8b7ada0 100644 --- a/src/main/java/me/kavin/piped/utils/CollectionUtils.java +++ b/src/main/java/me/kavin/piped/utils/CollectionUtils.java @@ -48,18 +48,18 @@ public class CollectionUtils { info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(rewriteVideoURL(stream.getContent()), 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(), 30))); + stream.getIndexEnd(), stream.getCodec(), stream.getWidth(), stream.getHeight(), stream.getFps(), stream.getItagItem().getContentLength()))); info.getVideoStreams() .forEach(stream -> videoStreams .add(new PipedStream(rewriteVideoURL(stream.getContent()), String.valueOf(stream.getFormat()), - stream.getResolution(), stream.getFormat().getMimeType(), false))); + stream.getResolution(), stream.getFormat().getMimeType(), false, stream.getItagItem().getContentLength()))); info.getAudioStreams() .forEach(stream -> audioStreams.add(new PipedStream(rewriteVideoURL(stream.getContent()), String.valueOf(stream.getFormat()), stream.getAverageBitrate() + " kbps", stream.getFormat().getMimeType(), false, stream.getBitrate(), stream.getInitStart(), - stream.getInitEnd(), stream.getIndexStart(), stream.getIndexEnd(), stream.getCodec(), stream.getAudioTrackId(), stream.getAudioTrackName(), - Optional.ofNullable(stream.getAudioTrackType()).map(Enum::name).orElse(null), + stream.getInitEnd(), stream.getIndexStart(), stream.getIndexEnd(), stream.getItagItem().getContentLength(), stream.getCodec(), stream.getAudioTrackId(), + stream.getAudioTrackName(), Optional.ofNullable(stream.getAudioTrackType()).map(Enum::name).orElse(null), Optional.ofNullable(stream.getAudioLocale()).map(Locale::toLanguageTag).orElse(null) ))); } diff --git a/src/main/java/me/kavin/piped/utils/obj/PipedStream.java b/src/main/java/me/kavin/piped/utils/obj/PipedStream.java index 818b6c2..c798902 100644 --- a/src/main/java/me/kavin/piped/utils/obj/PipedStream.java +++ b/src/main/java/me/kavin/piped/utils/obj/PipedStream.java @@ -10,17 +10,20 @@ public class PipedStream { public int bitrate, initStart, initEnd, indexStart, indexEnd, width, height, fps; - public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly) { + public long contentLength; + + public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, long contentLength) { this.url = url; this.format = format; this.quality = quality; this.mimeType = mimeType; this.videoOnly = videoOnly; + this.contentLength = contentLength; } public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, int bitrate, - int initStart, int initEnd, int indexStart, int indexEnd, String codec, String audioTrackId, - String audioTrackName, String audioTrackType, String audioTrackLocale) { + int initStart, int initEnd, int indexStart, int indexEnd, long contentLength, String codec, + String audioTrackId, String audioTrackName, String audioTrackType, String audioTrackLocale) { this.url = url; this.format = format; this.quality = quality; @@ -31,6 +34,7 @@ public class PipedStream { this.initEnd = initEnd; this.indexStart = indexStart; this.indexEnd = indexEnd; + this.contentLength = contentLength; this.codec = codec; this.audioTrackId = audioTrackId; this.audioTrackName = audioTrackName; @@ -39,7 +43,7 @@ public class PipedStream { } public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, int bitrate, - int initStart, int initEnd, int indexStart, int indexEnd, String codec, int width, int height, int fps) { + int initStart, int initEnd, int indexStart, int indexEnd, String codec, int width, int height, int fps, long contentLength) { this.url = url; this.format = format; this.quality = quality; @@ -54,5 +58,6 @@ public class PipedStream { this.width = width; this.height = height; this.fps = fps; + this.contentLength = contentLength; } }