Support for initial pages of other channel URL types.

This commit is contained in:
FireMasterK 2021-05-29 00:10:11 +05:30
parent 3811a7f264
commit 5b77fbed1c
No known key found for this signature in database
GPG key ID: 8DFF5DD33E93DB58
2 changed files with 18 additions and 3 deletions

View file

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

View file

@ -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<StreamItem> relatedStreams = new ObjectArrayList<>();