Add isShort field to StreamInfo.

This commit is contained in:
Kavin 2022-10-27 10:24:36 +01:00
parent 78bbfa7af4
commit 2b8039ff87
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
4 changed files with 24 additions and 9 deletions

View file

@ -16,7 +16,7 @@ dependencies {
implementation 'it.unimi.dsi:fastutil-core:8.5.9'
implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:2e9763d4d2e1e11a885c99291cb3c6cf2a349617'
implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:05987f18894d023b7f7f4c2556534971b2a8b810'
implementation 'com.github.FireMasterK:nanojson:5df3e81e87b791d01f132f376e4b7d4a1780f346'
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.4'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.4'

View file

@ -384,7 +384,7 @@ public class ResponseHelper {
var channel = video.getChannel();
relatedStreams.add(new StreamItem("/watch?v=" + video.getId(), video.getTitle(), rewriteURL(video.getThumbnail()), channel.getUploader(),
"/channel/" + channel.getUploaderId(), rewriteURL(channel.getUploaderAvatar()), null, null,
video.getDuration(), -1, -1, channel.isVerified()));
video.getDuration(), -1, -1, channel.isVerified(), false));
}
final Playlist playlist = new Playlist(pl.getName(), rewriteURL(pl.getThumbnail()), null, null, pl.getOwner().getUsername(),
@ -908,7 +908,7 @@ public class ResponseHelper {
feedItems.add(new StreamItem("/watch?v=" + video.getId(), video.getTitle(),
rewriteURL(video.getThumbnail()), channel.getUploader(), "/channel/" + channel.getUploaderId(),
rewriteURL(channel.getUploaderAvatar()), null, null, video.getDuration(), video.getViews(),
video.getUploaded(), channel.isVerified()));
video.getUploaded(), channel.isVerified(), video.isShort()));
}
return mapper.writeValueAsBytes(feedItems);
@ -1019,7 +1019,7 @@ public class ResponseHelper {
feedItems.add(new StreamItem("/watch?v=" + video.getId(), video.getTitle(),
rewriteURL(video.getThumbnail()), channel.getUploader(), "/channel/" + channel.getUploaderId(),
rewriteURL(channel.getUploaderAvatar()), null, null, video.getDuration(), video.getViews(),
video.getUploaded(), channel.isVerified()));
video.getUploaded(), channel.isVerified(), video.isShort()));
}
updateSubscribedTime(filtered);
@ -1608,7 +1608,7 @@ public class ResponseHelper {
&& (System.currentTimeMillis() - infoTime) < TimeUnit.DAYS.toMillis(Constants.FEED_RETENTION)) {
video = new Video(info.getId(), info.getName(), info.getViewCount(), info.getDuration(),
Math.max(infoTime, time), info.getThumbnailUrl(), channel);
Math.max(infoTime, time), info.getThumbnailUrl(), info.isShortFormContent(), channel);
try (StatelessSession s = DatabaseSessionFactory.createStatelessSession()) {
var tr = s.beginTransaction();
@ -1786,6 +1786,6 @@ public class ResponseHelper {
return new StreamItem(substringYouTube(item.getUrl()), item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUploaderName(), substringYouTube(item.getUploaderUrl()),
rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), item.getShortDescription(), item.getDuration(),
item.getViewCount(), item.getUploadDate() != null ? item.getUploadDate().offsetDateTime().toInstant().toEpochMilli() : -1, item.isUploaderVerified());
item.getViewCount(), item.getUploadDate() != null ? item.getUploadDate().offsetDateTime().toInstant().toEpochMilli() : -1, item.isUploaderVerified(), item.isShortFormContent());
}
}

View file

@ -2,12 +2,14 @@ package me.kavin.piped.utils.obj;
public class StreamItem {
private final String type = "video";
public String url, title, thumbnail, uploaderName, uploaderUrl, uploaderAvatar, uploadedDate, shortDescription;
public long duration, views, uploaded;
public boolean uploaderVerified;
public boolean uploaderVerified, isShort;
public StreamItem(String url, String title, String thumbnail, String uploaderName, String uploaderUrl,
String uploaderAvatar, String uploadedDate, String shortDescription, long duration, long views, long uploaded, boolean uploaderVerified) {
String uploaderAvatar, String uploadedDate, String shortDescription, long duration, long views, long uploaded, boolean uploaderVerified, boolean isShort) {
this.url = url;
this.title = title;
this.thumbnail = thumbnail;
@ -20,5 +22,6 @@ public class StreamItem {
this.views = views;
this.uploaded = uploaded;
this.uploaderVerified = uploaderVerified;
this.isShort = isShort;
}
}

View file

@ -27,6 +27,9 @@ public class Video {
@Column(name = "thumbnail", length = 400)
private String thumbnail;
@Column(name = "is_short", nullable = false, columnDefinition = "boolean default false")
private boolean isShort;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "uploader_id", nullable = false)
private Channel channel;
@ -34,13 +37,14 @@ public class Video {
public Video() {
}
public Video(String id, String title, long views, long duration, long uploaded, String thumbnail, Channel channel) {
public Video(String id, String title, long views, long duration, long uploaded, String thumbnail, boolean isShort, Channel channel) {
this.id = id;
this.title = title;
this.views = views;
this.duration = duration;
this.uploaded = uploaded;
this.thumbnail = thumbnail;
this.isShort = isShort;
this.channel = channel;
}
@ -92,6 +96,14 @@ public class Video {
this.thumbnail = thumbnail;
}
public boolean isShort() {
return isShort;
}
public void setShort(boolean aShort) {
isShort = aShort;
}
public Channel getChannel() {
return channel;
}