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<>();