mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2025-04-29 08:20:30 +05:30
Improve livestream detection.
This commit is contained in:
parent
d92797834c
commit
cc3976b454
@ -1,5 +1,7 @@
|
|||||||
package me.kavin.piped.utils;
|
package me.kavin.piped.utils;
|
||||||
|
|
||||||
|
import static me.kavin.piped.consts.Constants.YOUTUBE_SERVICE;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -51,6 +53,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
|||||||
import org.schabi.newpipe.extractor.search.SearchInfo;
|
import org.schabi.newpipe.extractor.search.SearchInfo;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
|
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
@ -149,11 +152,7 @@ public class ResponseHelper {
|
|||||||
if (lbryURL != null)
|
if (lbryURL != null)
|
||||||
videoStreams.add(new PipedStream(lbryURL, "MP4", "LBRY", "video/mp4", false));
|
videoStreams.add(new PipedStream(lbryURL, "MP4", "LBRY", "video/mp4", false));
|
||||||
|
|
||||||
final String hls;
|
boolean livestream = info.getStreamType() == StreamType.LIVE_STREAM;
|
||||||
boolean livestream = false;
|
|
||||||
|
|
||||||
if ((hls = info.getHlsUrl()) != null && !hls.isEmpty())
|
|
||||||
livestream = true;
|
|
||||||
|
|
||||||
if (!livestream) {
|
if (!livestream) {
|
||||||
info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(rewriteURL(stream.getUrl()),
|
info.getVideoOnlyStreams().forEach(stream -> videoStreams.add(new PipedStream(rewriteURL(stream.getUrl()),
|
||||||
@ -191,8 +190,8 @@ public class ResponseHelper {
|
|||||||
info.getTextualUploadDate(), info.getUploaderName(), substringYouTube(info.getUploaderUrl()),
|
info.getTextualUploadDate(), info.getUploaderName(), substringYouTube(info.getUploaderUrl()),
|
||||||
rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(),
|
rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(),
|
||||||
info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.isUploaderVerified(),
|
info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.isUploaderVerified(),
|
||||||
audioStreams, videoStreams, relatedStreams, subtitles, livestream, hls, info.getDashMpdUrl(),
|
audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteURL(info.getHlsUrl()),
|
||||||
futureLbryId.get());
|
rewriteURL(info.getDashMpdUrl()), futureLbryId.get());
|
||||||
|
|
||||||
return Constants.mapper.writeValueAsBytes(streams);
|
return Constants.mapper.writeValueAsBytes(streams);
|
||||||
|
|
||||||
@ -253,7 +252,7 @@ public class ResponseHelper {
|
|||||||
|
|
||||||
Page prevpage = Constants.mapper.readValue(prevpageStr, Page.class);
|
Page prevpage = Constants.mapper.readValue(prevpageStr, Page.class);
|
||||||
|
|
||||||
InfoItemsPage<StreamInfoItem> info = ChannelInfo.getMoreItems(Constants.YOUTUBE_SERVICE,
|
InfoItemsPage<StreamInfoItem> info = ChannelInfo.getMoreItems(YOUTUBE_SERVICE,
|
||||||
"https://youtube.com/channel/" + channelId, prevpage);
|
"https://youtube.com/channel/" + channelId, prevpage);
|
||||||
|
|
||||||
final List<StreamItem> relatedStreams = new ObjectArrayList<>();
|
final List<StreamItem> relatedStreams = new ObjectArrayList<>();
|
||||||
@ -280,7 +279,7 @@ public class ResponseHelper {
|
|||||||
|
|
||||||
final List<StreamItem> relatedStreams = new ObjectArrayList<>();
|
final List<StreamItem> relatedStreams = new ObjectArrayList<>();
|
||||||
|
|
||||||
KioskList kioskList = Constants.YOUTUBE_SERVICE.getKioskList();
|
KioskList kioskList = YOUTUBE_SERVICE.getKioskList();
|
||||||
kioskList.forceContentCountry(new ContentCountry(region));
|
kioskList.forceContentCountry(new ContentCountry(region));
|
||||||
KioskExtractor<?> extractor = kioskList.getDefaultKioskExtractor();
|
KioskExtractor<?> extractor = kioskList.getDefaultKioskExtractor();
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
@ -321,7 +320,7 @@ public class ResponseHelper {
|
|||||||
|
|
||||||
Page prevpage = Constants.mapper.readValue(prevpageStr, Page.class);
|
Page prevpage = Constants.mapper.readValue(prevpageStr, Page.class);
|
||||||
|
|
||||||
InfoItemsPage<StreamInfoItem> info = PlaylistInfo.getMoreItems(Constants.YOUTUBE_SERVICE,
|
InfoItemsPage<StreamInfoItem> info = PlaylistInfo.getMoreItems(YOUTUBE_SERVICE,
|
||||||
"https://www.youtube.com/playlist?list=" + playlistId, prevpage);
|
"https://www.youtube.com/playlist?list=" + playlistId, prevpage);
|
||||||
|
|
||||||
final List<StreamItem> relatedStreams = new ObjectArrayList<>();
|
final List<StreamItem> relatedStreams = new ObjectArrayList<>();
|
||||||
@ -372,16 +371,15 @@ public class ResponseHelper {
|
|||||||
public static final byte[] suggestionsResponse(String query)
|
public static final byte[] suggestionsResponse(String query)
|
||||||
throws JsonProcessingException, IOException, ExtractionException {
|
throws JsonProcessingException, IOException, ExtractionException {
|
||||||
|
|
||||||
return Constants.mapper
|
return Constants.mapper.writeValueAsBytes(YOUTUBE_SERVICE.getSuggestionExtractor().suggestionList(query));
|
||||||
.writeValueAsBytes(Constants.YOUTUBE_SERVICE.getSuggestionExtractor().suggestionList(query));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final byte[] searchResponse(String q, String filter)
|
public static final byte[] searchResponse(String q, String filter)
|
||||||
throws IOException, ExtractionException, InterruptedException {
|
throws IOException, ExtractionException, InterruptedException {
|
||||||
|
|
||||||
final SearchInfo info = SearchInfo.getInfo(Constants.YOUTUBE_SERVICE,
|
final SearchInfo info = SearchInfo.getInfo(YOUTUBE_SERVICE,
|
||||||
Constants.YOUTUBE_SERVICE.getSearchQHFactory().fromQuery(q, Collections.singletonList(filter), null));
|
YOUTUBE_SERVICE.getSearchQHFactory().fromQuery(q, Collections.singletonList(filter), null));
|
||||||
|
|
||||||
ObjectArrayList<Object> items = new ObjectArrayList<>();
|
ObjectArrayList<Object> items = new ObjectArrayList<>();
|
||||||
|
|
||||||
@ -418,9 +416,8 @@ public class ResponseHelper {
|
|||||||
|
|
||||||
Page prevpage = Constants.mapper.readValue(prevpageStr, Page.class);
|
Page prevpage = Constants.mapper.readValue(prevpageStr, Page.class);
|
||||||
|
|
||||||
InfoItemsPage<InfoItem> pages = SearchInfo.getMoreItems(Constants.YOUTUBE_SERVICE,
|
InfoItemsPage<InfoItem> pages = SearchInfo.getMoreItems(YOUTUBE_SERVICE,
|
||||||
Constants.YOUTUBE_SERVICE.getSearchQHFactory().fromQuery(q, Collections.singletonList(filter), null),
|
YOUTUBE_SERVICE.getSearchQHFactory().fromQuery(q, Collections.singletonList(filter), null), prevpage);
|
||||||
prevpage);
|
|
||||||
|
|
||||||
ObjectArrayList<Object> items = new ObjectArrayList<>();
|
ObjectArrayList<Object> items = new ObjectArrayList<>();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user