mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-12-13 13:50:28 +05:30
feat(sponsorblock): support actionTypes (#766)
* feat(sponsorblock): support actionTypes * feat(sponsorblock): handle nullable actionType * style: correctly format assignment Co-authored-by: Bnyro <82752168+Bnyro@users.noreply.github.com> --------- Co-authored-by: Bnyro <82752168+Bnyro@users.noreply.github.com>
This commit is contained in:
parent
e68e3f9356
commit
cd4bc36f4f
@ -99,7 +99,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
||||
try {
|
||||
return getJsonResponse(
|
||||
SponsorBlockUtils.getSponsors(request.getPathParameter("videoId"),
|
||||
request.getQueryParameter("category")).getBytes(UTF_8),
|
||||
request.getQueryParameter("category"), request.getQueryParameter("actionType")).getBytes(UTF_8),
|
||||
"public, max-age=3600");
|
||||
} catch (Exception e) {
|
||||
return getErrorResponse(e, request.getPath());
|
||||
|
@ -22,7 +22,7 @@ import static me.kavin.piped.consts.Constants.mapper;
|
||||
|
||||
public class SponsorBlockUtils {
|
||||
|
||||
public static String getSponsors(String id, String categories)
|
||||
public static String getSponsors(String id, String categories, String actionType)
|
||||
throws IOException {
|
||||
|
||||
if (StringUtils.isEmpty(categories))
|
||||
@ -30,11 +30,15 @@ public class SponsorBlockUtils {
|
||||
|
||||
String hash = DigestUtils.sha256Hex(id);
|
||||
|
||||
for (String url : Constants.SPONSORBLOCK_SERVERS) {
|
||||
for (String apiUrl : Constants.SPONSORBLOCK_SERVERS) {
|
||||
try {
|
||||
String url = apiUrl + "/api/skipSegments/" + URLUtils.silentEncode(hash.substring(0, 4))
|
||||
|
||||
var resp = RequestUtils.sendGetRaw(url + "/api/skipSegments/" + URLUtils.silentEncode(hash.substring(0, 4))
|
||||
+ "?categories=" + URLUtils.silentEncode(categories)).get();
|
||||
+ "?categories=" + URLUtils.silentEncode(categories);
|
||||
if (actionType != null && !actionType.isBlank())
|
||||
url += "&actionTypes=" + URLUtils.silentEncode(actionType);
|
||||
|
||||
var resp = RequestUtils.sendGetRaw(url).get();
|
||||
|
||||
if (resp.status() == 200) {
|
||||
var any = mapper.readTree(resp.body());
|
||||
|
Loading…
Reference in New Issue
Block a user