Update NPE.

This commit is contained in:
Kavin 2022-11-15 19:21:36 +00:00
parent d537848def
commit 6ad27aea2a
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
7 changed files with 37 additions and 37 deletions

View file

@ -16,7 +16,7 @@ dependencies {
implementation 'it.unimi.dsi:fastutil-core:8.5.9'
implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:cd90b9f950480a1991ef1175b8d10392a6f49234'
implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:15f45245d38b21d794870bea93291296c6bb9935'
implementation 'com.github.FireMasterK:nanojson:5df3e81e87b791d01f132f376e4b7d4a1780f346'
implementation 'com.fasterxml.jackson.core:jackson-core:2.14.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.0'

View file

@ -4,7 +4,7 @@ PORT:8080
HTTP_WORKERS:2
# Proxy
PROXY_PART:https://pipedproxy-ams.kavin.rocks
PROXY_PART:https://pipedproxy-cdg.kavin.rocks
# Outgoing HTTP Proxy - eg: 127.0.0.1:8118
#HTTP_PROXY: 127.0.0.1:8118

View file

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import me.kavin.piped.utils.PageMixin;
import me.kavin.piped.utils.resp.ListLinkHandlerMixin;
import okhttp3.OkHttpClient;
import okhttp3.brotli.BrotliInterceptor;
import org.apache.commons.io.IOUtils;
@ -12,6 +13,7 @@ import org.apache.commons.lang3.StringUtils;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import java.io.File;
import java.io.FileReader;
@ -80,6 +82,7 @@ public class Constants {
public static final ObjectMapper mapper = JsonMapper.builder()
.addMixIn(Page.class, PageMixin.class)
.addMixIn(ListLinkHandler.class, ListLinkHandlerMixin.class)
.build();
public static final Object2ObjectOpenHashMap<String, String> hibernateProperties = new Object2ObjectOpenHashMap<>();
@ -162,11 +165,11 @@ public class Constants {
}
}
private static final String getProperty(final Properties prop, String key) {
private static String getProperty(final Properties prop, String key) {
return getProperty(prop, key, null);
}
private static final String getProperty(final Properties prop, String key, String def) {
private static String getProperty(final Properties prop, String key, String def) {
final String envVal = System.getenv(key);

View file

@ -17,7 +17,7 @@ import org.schabi.newpipe.extractor.channel.ChannelInfo;
import org.schabi.newpipe.extractor.channel.ChannelTabInfo;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YouTubeChannelTabHandler;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException;
@ -140,7 +140,7 @@ public class ChannelHandlers {
.stream()
.map(tab -> {
try {
return new ChannelTab(tab.getTab().name(), mapper.writeValueAsString(tab));
return new ChannelTab(tab.getContentFilters().get(0), mapper.writeValueAsString(tab));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
@ -190,7 +190,7 @@ public class ChannelHandlers {
if (StringUtils.isEmpty(data))
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("data is a required parameter"));
YouTubeChannelTabHandler tabHandler = mapper.readValue(data, YouTubeChannelTabHandlerMixin.class);
ListLinkHandler tabHandler = mapper.readValue(data, ListLinkHandler.class);
var info = ChannelTabInfo.getInfo(YOUTUBE_SERVICE, tabHandler);
@ -210,7 +210,7 @@ public class ChannelHandlers {
if (StringUtils.isEmpty(data))
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("data is a required parameter"));
YouTubeChannelTabHandler tabHandler = mapper.readValue(data, YouTubeChannelTabHandlerMixin.class);
ListLinkHandler tabHandler = mapper.readValue(data, ListLinkHandler.class);
Page prevPage = mapper.readValue(prevPageStr, Page.class);

View file

@ -1,16 +1,18 @@
package me.kavin.piped.utils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.schabi.newpipe.extractor.Page;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public abstract class PageMixin {
public abstract class PageMixin extends Page {
@JsonCreator
public PageMixin(@JsonProperty("url") String url, @JsonProperty("id") String id,
@JsonProperty("ids") List<String> ids, @JsonProperty("cookies") Map<String, String> cookies,
@JsonProperty("body") byte[] body) {
@JsonProperty("ids") List<String> ids, @JsonProperty("cookies") Map<String, String> cookies,
@JsonProperty("body") byte[] body) {
super(url, id, ids, cookies, body);
}
}

View file

@ -1,23 +0,0 @@
package me.kavin.piped.utils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.schabi.newpipe.extractor.linkhandler.ChannelTabHandler;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YouTubeChannelTabHandler;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class YouTubeChannelTabHandlerMixin extends YouTubeChannelTabHandler {
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public YouTubeChannelTabHandlerMixin(@JsonProperty("originalUrl") String originalUrl, @JsonProperty("url") String url,
@JsonProperty("id") String id, @JsonProperty("contentFilters") List<String> contentFilters,
@JsonProperty("sortFilter") String sortFilter, @JsonProperty("tab") ChannelTabHandler.Tab tab,
@JsonProperty("visitorData") String visitorData) {
super(new ListLinkHandler(originalUrl, url, id, contentFilters, sortFilter), tab, visitorData);
}
}

View file

@ -0,0 +1,18 @@
package me.kavin.piped.utils.resp;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ListLinkHandlerMixin extends ListLinkHandler {
@JsonCreator
public ListLinkHandlerMixin(@JsonProperty("originalUrl") String originalUrl, @JsonProperty("url") String url, @JsonProperty("id") String id,
@JsonProperty("contentFilters") List<String> contentFilters, @JsonProperty("sortFilter") String sortFilter) {
super(originalUrl, url, id, contentFilters, sortFilter);
}
}