Add content length property.

This commit is contained in:
Kavin 2023-05-26 19:55:01 +01:00
parent 5d085ce592
commit 61bfd478aa
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
3 changed files with 16 additions and 11 deletions

View File

@ -214,7 +214,7 @@ public class StreamHandlers {
} }
if (lbryURL != null) 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 // Attempt to get dislikes calculating with the RYD API rating
if (streams.dislikes < 0 && streams.likes >= 0) { if (streams.dislikes < 0 && streams.likes >= 0) {
@ -260,10 +260,10 @@ public class StreamHandlers {
} }
if (lbryHlsURL != null) 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) 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() long time = info.getUploadDate() != null ? info.getUploadDate().offsetDateTime().toInstant().toEpochMilli()
: System.currentTimeMillis(); : System.currentTimeMillis();

View File

@ -48,18 +48,18 @@ public class CollectionUtils {
info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(rewriteVideoURL(stream.getContent()), info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(rewriteVideoURL(stream.getContent()),
String.valueOf(stream.getFormat()), stream.getResolution(), stream.getFormat().getMimeType(), true, String.valueOf(stream.getFormat()), stream.getResolution(), stream.getFormat().getMimeType(), true,
stream.getBitrate(), stream.getInitStart(), stream.getInitEnd(), stream.getIndexStart(), 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() info.getVideoStreams()
.forEach(stream -> videoStreams .forEach(stream -> videoStreams
.add(new PipedStream(rewriteVideoURL(stream.getContent()), String.valueOf(stream.getFormat()), .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() info.getAudioStreams()
.forEach(stream -> audioStreams.add(new PipedStream(rewriteVideoURL(stream.getContent()), .forEach(stream -> audioStreams.add(new PipedStream(rewriteVideoURL(stream.getContent()),
String.valueOf(stream.getFormat()), stream.getAverageBitrate() + " kbps", String.valueOf(stream.getFormat()), stream.getAverageBitrate() + " kbps",
stream.getFormat().getMimeType(), false, stream.getBitrate(), stream.getInitStart(), stream.getFormat().getMimeType(), false, stream.getBitrate(), stream.getInitStart(),
stream.getInitEnd(), stream.getIndexStart(), stream.getIndexEnd(), stream.getCodec(), stream.getAudioTrackId(), stream.getAudioTrackName(), stream.getInitEnd(), stream.getIndexStart(), stream.getIndexEnd(), stream.getItagItem().getContentLength(), stream.getCodec(), stream.getAudioTrackId(),
Optional.ofNullable(stream.getAudioTrackType()).map(Enum::name).orElse(null), stream.getAudioTrackName(), Optional.ofNullable(stream.getAudioTrackType()).map(Enum::name).orElse(null),
Optional.ofNullable(stream.getAudioLocale()).map(Locale::toLanguageTag).orElse(null) Optional.ofNullable(stream.getAudioLocale()).map(Locale::toLanguageTag).orElse(null)
))); )));
} }

View File

@ -10,17 +10,20 @@ public class PipedStream {
public int bitrate, initStart, initEnd, indexStart, indexEnd, width, height, fps; 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.url = url;
this.format = format; this.format = format;
this.quality = quality; this.quality = quality;
this.mimeType = mimeType; this.mimeType = mimeType;
this.videoOnly = videoOnly; this.videoOnly = videoOnly;
this.contentLength = contentLength;
} }
public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, int bitrate, 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, int initStart, int initEnd, int indexStart, int indexEnd, long contentLength, String codec,
String audioTrackName, String audioTrackType, String audioTrackLocale) { String audioTrackId, String audioTrackName, String audioTrackType, String audioTrackLocale) {
this.url = url; this.url = url;
this.format = format; this.format = format;
this.quality = quality; this.quality = quality;
@ -31,6 +34,7 @@ public class PipedStream {
this.initEnd = initEnd; this.initEnd = initEnd;
this.indexStart = indexStart; this.indexStart = indexStart;
this.indexEnd = indexEnd; this.indexEnd = indexEnd;
this.contentLength = contentLength;
this.codec = codec; this.codec = codec;
this.audioTrackId = audioTrackId; this.audioTrackId = audioTrackId;
this.audioTrackName = audioTrackName; this.audioTrackName = audioTrackName;
@ -39,7 +43,7 @@ public class PipedStream {
} }
public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, int bitrate, 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.url = url;
this.format = format; this.format = format;
this.quality = quality; this.quality = quality;
@ -54,5 +58,6 @@ public class PipedStream {
this.width = width; this.width = width;
this.height = height; this.height = height;
this.fps = fps; this.fps = fps;
this.contentLength = contentLength;
} }
} }