mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Add null-check for SponsorBlock endpoint (#154)
This commit is contained in:
parent
0c86edc1be
commit
49f439e761
1 changed files with 6 additions and 0 deletions
|
@ -8,6 +8,8 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.grack.nanojson.JsonArray;
|
||||
import com.grack.nanojson.JsonObject;
|
||||
import com.grack.nanojson.JsonParser;
|
||||
|
@ -15,12 +17,16 @@ import com.grack.nanojson.JsonParserException;
|
|||
import com.grack.nanojson.JsonWriter;
|
||||
|
||||
import me.kavin.piped.consts.Constants;
|
||||
import me.kavin.piped.utils.resp.InvalidRequestResponse;
|
||||
|
||||
public class SponsorBlockUtils {
|
||||
|
||||
public static final String getSponsors(String id, String categories)
|
||||
throws IOException, InterruptedException, NoSuchAlgorithmException, JsonParserException {
|
||||
|
||||
if (StringUtils.isEmpty(categories))
|
||||
return Constants.mapper.writeValueAsString(new InvalidRequestResponse());
|
||||
|
||||
String hash = toSha256(id);
|
||||
|
||||
URI uri = URI.create("https://sponsor.ajay.app/api/skipSegments/" + URLUtils.silentEncode(hash.substring(0, 4))
|
||||
|
|
Loading…
Reference in a new issue