From 5b77fbed1c7e74da21828413c43f21a62c3ea33a Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Sat, 29 May 2021 00:10:11 +0530 Subject: [PATCH] Support for initial pages of other channel URL types. --- .../java/me/kavin/piped/ServerLauncher.java | 17 ++++++++++++++++- .../me/kavin/piped/utils/ResponseHelper.java | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/kavin/piped/ServerLauncher.java b/src/main/java/me/kavin/piped/ServerLauncher.java index 09f3da4..20f572b 100644 --- a/src/main/java/me/kavin/piped/ServerLauncher.java +++ b/src/main/java/me/kavin/piped/ServerLauncher.java @@ -78,7 +78,22 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher { } })).map("/channels/:channelId", AsyncServlet.ofBlocking(executor, request -> { try { - return getJsonResponse(ResponseHelper.channelResponse(request.getPathParameter("channelId")), + return getJsonResponse( + ResponseHelper.channelResponse("channel/" + request.getPathParameter("channelId")), + "public, max-age=600"); + } catch (Exception e) { + return getErrorResponse(e); + } + })).map("/c/:name", AsyncServlet.ofBlocking(executor, request -> { + try { + return getJsonResponse(ResponseHelper.channelResponse("c/" + request.getPathParameter("name")), + "public, max-age=600"); + } catch (Exception e) { + return getErrorResponse(e); + } + })).map("/user/:name", AsyncServlet.ofBlocking(executor, request -> { + try { + return getJsonResponse(ResponseHelper.channelResponse("user/" + request.getPathParameter("name")), "public, max-age=600"); } catch (Exception e) { return getErrorResponse(e); diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index ca97c8f..139ec13 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -166,9 +166,9 @@ public class ResponseHelper { } - public static final byte[] channelResponse(String channelId) throws Exception { + public static final byte[] channelResponse(String channelPath) throws Exception { - final ChannelInfo info = ChannelInfo.getInfo("https://youtube.com/channel/" + channelId); + final ChannelInfo info = ChannelInfo.getInfo("https://youtube.com/" + channelPath); final List relatedStreams = new ObjectArrayList<>();