diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3222072..38ea6e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ 11, 17 ] + java: [ 17 ] steps: - uses: actions/checkout@v3 diff --git a/build.gradle b/build.gradle index 53749e4..b84cd15 100644 --- a/build.gradle +++ b/build.gradle @@ -57,5 +57,5 @@ jar { group = 'me.kavin.piped' version = '1.0' -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 diff --git a/src/main/java/me/kavin/piped/utils/DatabaseHelper.java b/src/main/java/me/kavin/piped/utils/DatabaseHelper.java index 0f5ea30..a0b5b8f 100644 --- a/src/main/java/me/kavin/piped/utils/DatabaseHelper.java +++ b/src/main/java/me/kavin/piped/utils/DatabaseHelper.java @@ -8,6 +8,7 @@ import me.kavin.piped.utils.obj.db.*; import org.hibernate.SharedSessionContract; import org.hibernate.StatelessSession; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -55,7 +56,7 @@ public class DatabaseHelper { } } - public static List getChannelsFromIds(SharedSessionContract s, List id) { + public static List getChannelsFromIds(SharedSessionContract s, Collection id) { CriteriaBuilder cb = s.getCriteriaBuilder(); CriteriaQuery cr = cb.createQuery(Channel.class); Root root = cr.from(Channel.class); @@ -97,7 +98,7 @@ public class DatabaseHelper { return s.createQuery(cr).uniqueResult(); } - public static List getPlaylistVideosFromIds(SharedSessionContract s, List id) { + public static List getPlaylistVideosFromIds(SharedSessionContract s, Collection id) { CriteriaBuilder cb = s.getCriteriaBuilder(); CriteriaQuery cr = cb.createQuery(PlaylistVideo.class); Root root = cr.from(PlaylistVideo.class); diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index 6823c63..7f76311 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -116,7 +116,7 @@ public class ResponseHelper { segment.getStartTimeSeconds()))); info.getSubtitles() - .forEach(subtitle -> subtitles.add(new Subtitle(rewriteURL(subtitle.getUrl()), + .forEach(subtitle -> subtitles.add(new Subtitle(rewriteURL(subtitle.getContent()), subtitle.getFormat().getMimeType(), subtitle.getDisplayLanguageName(), subtitle.getLanguageTag(), subtitle.isAutoGenerated()))); @@ -137,17 +137,17 @@ public class ResponseHelper { boolean livestream = info.getStreamType() == StreamType.LIVE_STREAM; if (!livestream) { - info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(rewriteVideoURL(stream.getUrl()), + 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))); info.getVideoStreams() .forEach(stream -> videoStreams - .add(new PipedStream(rewriteVideoURL(stream.getUrl()), String.valueOf(stream.getFormat()), + .add(new PipedStream(rewriteVideoURL(stream.getContent()), String.valueOf(stream.getFormat()), stream.getResolution(), stream.getFormat().getMimeType(), false))); info.getAudioStreams() - .forEach(stream -> audioStreams.add(new PipedStream(rewriteVideoURL(stream.getUrl()), + .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()))); @@ -528,22 +528,18 @@ public class ResponseHelper { info.getRelatedItems().forEach(item -> { switch (item.getInfoType()) { - case STREAM: - items.add(collectRelatedStream(item)); - break; - case CHANNEL: + case STREAM -> items.add(collectRelatedStream(item)); + case CHANNEL -> { ChannelInfoItem channel = (ChannelInfoItem) item; items.add(new SearchChannel(item.getName(), rewriteURL(item.getThumbnailUrl()), substringYouTube(item.getUrl()), channel.getDescription(), channel.getSubscriberCount(), channel.getStreamCount(), channel.isVerified())); - break; - case PLAYLIST: + } + case PLAYLIST -> { PlaylistInfoItem playlist = (PlaylistInfoItem) item; items.add(new SearchPlaylist(item.getName(), rewriteURL(item.getThumbnailUrl()), substringYouTube(item.getUrl()), playlist.getUploaderName(), playlist.getStreamCount())); - break; - default: - break; + } } }); @@ -569,22 +565,18 @@ public class ResponseHelper { pages.getItems().forEach(item -> { switch (item.getInfoType()) { - case STREAM: - items.add(collectRelatedStream(item)); - break; - case CHANNEL: + case STREAM -> items.add(collectRelatedStream(item)); + case CHANNEL -> { ChannelInfoItem channel = (ChannelInfoItem) item; items.add(new SearchChannel(item.getName(), rewriteURL(item.getThumbnailUrl()), substringYouTube(item.getUrl()), channel.getDescription(), channel.getSubscriberCount(), channel.getStreamCount(), channel.isVerified())); - break; - case PLAYLIST: + } + case PLAYLIST -> { PlaylistInfoItem playlist = (PlaylistInfoItem) item; items.add(new SearchPlaylist(item.getName(), rewriteURL(item.getThumbnailUrl()), substringYouTube(item.getUrl()), playlist.getUploaderName(), playlist.getStreamCount())); - break; - default: - break; + } } }); @@ -1031,8 +1023,6 @@ public class ResponseHelper { )) .orderBy(cb.desc(root.get("uploaded"))); - List feedItems = new ObjectArrayList<>(); - List