Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Comment thread
AudricV marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ public String getName() throws ParsingException {

@Override
public long getDuration() throws ParsingException {
// Duration can only be extracted for normal videos, not live streams
if (getStreamType() != StreamType.VIDEO_STREAM) {
// Duration can not be extract from live streams, only from normal videos
Comment thread
Stypox marked this conversation as resolved.
Outdated
if (isLive()) {
return -1;
}

Expand Down Expand Up @@ -220,6 +220,12 @@ public String getTextualUploadDate() throws ParsingException {
return cachedTextualUploadDate.orElse(null);
}

// Live streams have no upload date
if (isLive()) {
cachedTextualUploadDate = Optional.empty();
return null;
}

// This might be null e.g. for live streams
this.cachedTextualUploadDate = metadataPart(1, 1)
.map(this::getTextContentFromMetadataPart);
Expand Down Expand Up @@ -249,7 +255,11 @@ public long getViewCount() throws ParsingException {
if (optTextContent.isPresent()) {
return getViewCountFromViewCountText(optTextContent.get());
}
return -1;
return !isLive()
? -1
// Live streams don't have the metadata row present if there are 0 viewers
// https://github.com/TeamNewPipe/NewPipeExtractor/pull/1320#discussion_r2205837528
: 0;
}

private long getViewCountFromViewCountText(@Nonnull final String viewCountText)
Expand Down Expand Up @@ -322,6 +332,10 @@ private String getTextContentFromMetadataPart(final JsonObject metadataPart) {
return metadataPart.getObject("text").getString("content");
}

private boolean isLive() throws ParsingException {
return getStreamType() != StreamType.VIDEO_STREAM;
}

abstract static class ChannelImageViewModel {
protected JsonObject viewModel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor {
/**
* Parses the number of views
*
* @return the number of views or -1 for live streams
* @return the number of views or -1 if not available
Comment thread
Stypox marked this conversation as resolved.
Outdated
* @throws ParsingException if there is an error in the extraction
*/
long getViewCount() throws ParsingException;
Expand Down
Loading