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)
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();

View file

@ -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)
)));
}

View file

@ -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;
}
}