diff --git a/build.gradle b/build.gradle index 7fd9722..195ddf6 100644 --- a/build.gradle +++ b/build.gradle @@ -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' diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index af7a5bb..64b0b02 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -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()); } } diff --git a/src/main/java/me/kavin/piped/utils/obj/StreamItem.java b/src/main/java/me/kavin/piped/utils/obj/StreamItem.java index 8844799..058febb 100644 --- a/src/main/java/me/kavin/piped/utils/obj/StreamItem.java +++ b/src/main/java/me/kavin/piped/utils/obj/StreamItem.java @@ -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; } } diff --git a/src/main/java/me/kavin/piped/utils/obj/db/Video.java b/src/main/java/me/kavin/piped/utils/obj/db/Video.java index a6a648d..9ed5215 100644 --- a/src/main/java/me/kavin/piped/utils/obj/db/Video.java +++ b/src/main/java/me/kavin/piped/utils/obj/db/Video.java @@ -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; }