Merge pull request #435 from TeamPiped/npe-update

Npe update
This commit is contained in:
Kavin 2022-11-15 19:29:10 +00:00 committed by GitHub
commit 38a88557f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 43 additions and 41 deletions

View file

@ -16,7 +16,7 @@ dependencies {
implementation 'it.unimi.dsi:fastutil-core:8.5.9' implementation 'it.unimi.dsi:fastutil-core:8.5.9'
implementation 'commons-codec:commons-codec:1.15' implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bouncycastle:bcprov-jdk15on:1.70' 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.github.FireMasterK:nanojson:5df3e81e87b791d01f132f376e4b7d4a1780f346'
implementation 'com.fasterxml.jackson.core:jackson-core:2.14.0' implementation 'com.fasterxml.jackson.core:jackson-core:2.14.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.0' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.0'

View file

@ -4,7 +4,7 @@ PORT:8080
HTTP_WORKERS:2 HTTP_WORKERS:2
# Proxy # Proxy
PROXY_PART:https://pipedproxy-ams.kavin.rocks PROXY_PART:https://pipedproxy-cdg.kavin.rocks
# Outgoing HTTP Proxy - eg: 127.0.0.1:8118 # Outgoing HTTP Proxy - eg: 127.0.0.1:8118
#HTTP_PROXY: 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 com.fasterxml.jackson.databind.node.ObjectNode;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import me.kavin.piped.utils.PageMixin; import me.kavin.piped.utils.PageMixin;
import me.kavin.piped.utils.resp.ListLinkHandlerMixin;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.brotli.BrotliInterceptor; import okhttp3.brotli.BrotliInterceptor;
import org.apache.commons.io.IOUtils; 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.NewPipe;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
@ -80,6 +82,7 @@ public class Constants {
public static final ObjectMapper mapper = JsonMapper.builder() public static final ObjectMapper mapper = JsonMapper.builder()
.addMixIn(Page.class, PageMixin.class) .addMixIn(Page.class, PageMixin.class)
.addMixIn(ListLinkHandler.class, ListLinkHandlerMixin.class)
.build(); .build();
public static final Object2ObjectOpenHashMap<String, String> hibernateProperties = new Object2ObjectOpenHashMap<>(); 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); 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); 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.channel.ChannelTabInfo;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException; 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 org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException; import java.io.IOException;
@ -140,7 +140,7 @@ public class ChannelHandlers {
.stream() .stream()
.map(tab -> { .map(tab -> {
try { try {
return new ChannelTab(tab.getTab().name(), mapper.writeValueAsString(tab)); return new ChannelTab(tab.getContentFilters().get(0), mapper.writeValueAsString(tab));
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -190,7 +190,7 @@ public class ChannelHandlers {
if (StringUtils.isEmpty(data)) if (StringUtils.isEmpty(data))
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("data is a required parameter")); 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); var info = ChannelTabInfo.getInfo(YOUTUBE_SERVICE, tabHandler);
@ -210,7 +210,7 @@ public class ChannelHandlers {
if (StringUtils.isEmpty(data)) if (StringUtils.isEmpty(data))
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("data is a required parameter")); 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); Page prevPage = mapper.readValue(prevPageStr, Page.class);

View file

@ -141,7 +141,7 @@ public class StreamHandlers {
.forEach(stream -> audioStreams.add(new PipedStream(rewriteVideoURL(stream.getContent()), .forEach(stream -> audioStreams.add(new PipedStream(rewriteVideoURL(stream.getContent()),
String.valueOf(stream.getFormat()), stream.getAverageBitrate() + " kbps", String.valueOf(stream.getFormat()), stream.getAverageBitrate() + " kbps",
stream.getFormat().getMimeType(), false, stream.getBitrate(), stream.getInitStart(), stream.getFormat().getMimeType(), false, stream.getBitrate(), stream.getInitStart(),
stream.getInitEnd(), stream.getIndexStart(), stream.getIndexEnd(), stream.getCodec()))); stream.getInitEnd(), stream.getIndexStart(), stream.getIndexEnd(), stream.getCodec(), stream.getAudioTrackId(), stream.getAudioTrackName())));
} }
final List<ContentItem> relatedStreams = collectRelatedItems(info.getRelatedItems()); final List<ContentItem> relatedStreams = collectRelatedItems(info.getRelatedItems());

View file

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

@ -2,7 +2,7 @@ package me.kavin.piped.utils.obj;
public class PipedStream { public class PipedStream {
public String url, format, quality, mimeType, codec; public String url, format, quality, mimeType, codec, audioTrackId, audioTrackName;
public boolean videoOnly; public boolean videoOnly;
public int bitrate, initStart, initEnd, indexStart, indexEnd, width, height, fps; public int bitrate, initStart, initEnd, indexStart, indexEnd, width, height, fps;
@ -16,7 +16,7 @@ public class PipedStream {
} }
public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, int bitrate, public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, int bitrate,
int initStart, int initEnd, int indexStart, int indexEnd, String codec) { int initStart, int initEnd, int indexStart, int indexEnd, String codec, String audioTrackId, String audioTrackName) {
this.url = url; this.url = url;
this.format = format; this.format = format;
this.quality = quality; this.quality = quality;
@ -28,10 +28,12 @@ public class PipedStream {
this.indexStart = indexStart; this.indexStart = indexStart;
this.indexEnd = indexEnd; this.indexEnd = indexEnd;
this.codec = codec; this.codec = codec;
this.audioTrackId = audioTrackId;
this.audioTrackName = audioTrackName;
} }
public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, int bitrate, public PipedStream(String url, String format, String quality, String mimeType, boolean videoOnly, int bitrate,
int initStart, int initEnd, int indexStart, int indexEnd, String codec, int width, int height, int fps) { int initStart, int initEnd, int indexStart, int indexEnd, String codec, int width, int height, int fps) {
this.url = url; this.url = url;
this.format = format; this.format = format;
this.quality = quality; this.quality = quality;

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