2
0
mirror of https://github.com/TeamNewPipe/NewPipeExtractor synced 2025-08-22 09:57:38 +00:00

[YouTube] Add running lives extractor from Live system channel

This commit is contained in:
AudricV 2025-07-26 23:02:00 +02:00
parent 3d0e302230
commit d38d64708d
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
3 changed files with 82 additions and 4 deletions

View File

@ -36,9 +36,11 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExt
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSubscriptionExtractor;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSuggestionExtractor;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingExtractor;
import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeLiveExtractor;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelTabLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeCommentsLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeLiveLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
@ -154,17 +156,26 @@ public class YoutubeService extends StreamingService {
@Override
public KioskList getKioskList() throws ExtractionException {
final KioskList list = new KioskList(this);
final ListLinkHandlerFactory h = YoutubeTrendingLinkHandlerFactory.getInstance();
final ListLinkHandlerFactory trendingLHF = YoutubeTrendingLinkHandlerFactory.getInstance();
final ListLinkHandlerFactory runningLivesLHF =
YoutubeLiveLinkHandlerFactory.INSTANCE;
// add kiosks here e.g.:
try {
list.addKioskEntry(
(streamingService, url, id) -> new YoutubeLiveExtractor(
YoutubeService.this,
runningLivesLHF.fromUrl(url),
id),
runningLivesLHF,
YoutubeLiveLinkHandlerFactory.KIOSK_ID
);
list.addKioskEntry(
(streamingService, url, id) -> new YoutubeTrendingExtractor(
YoutubeService.this,
h.fromUrl(url),
trendingLHF.fromUrl(url),
id
),
h,
trendingLHF,
YoutubeTrendingExtractor.KIOSK_ID
);
list.setDefaultKiosk(YoutubeTrendingExtractor.KIOSK_ID);

View File

@ -0,0 +1,14 @@
package org.schabi.newpipe.extractor.services.youtube.extractors.kiosk;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
public class YoutubeLiveExtractor extends YoutubeDesktopBaseKioskExtractor {
public YoutubeLiveExtractor(final StreamingService streamingService,
final ListLinkHandler linkHandler,
final String kioskId) {
super(streamingService, linkHandler, kioskId, "UC4R8DWoMoI7CAwX8_LjQHig",
"EgdsaXZldGFikgEDCKEK");
}
}

View File

@ -0,0 +1,53 @@
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isInvidiousURL;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isYoutubeURL;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
import org.schabi.newpipe.extractor.utils.Utils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
public final class YoutubeLiveLinkHandlerFactory extends ListLinkHandlerFactory {
public static final String KIOSK_ID = "live";
public static final YoutubeLiveLinkHandlerFactory INSTANCE =
new YoutubeLiveLinkHandlerFactory();
private static final String LIVE_CHANNEL_PATH = "/channel/UC4R8DWoMoI7CAwX8_LjQHig/livetab";
private static final String LIVE_CHANNEL_TAB_PARAMS = "ss=CKEK";
private YoutubeLiveLinkHandlerFactory() {
}
@Override
public String getUrl(final String id,
final List<String> contentFilters,
final String sortFilter)
throws ParsingException, UnsupportedOperationException {
return "https://www.youtube.com" + LIVE_CHANNEL_PATH + "?" + LIVE_CHANNEL_TAB_PARAMS;
}
@Override
public String getId(final String url) throws ParsingException, UnsupportedOperationException {
return KIOSK_ID;
}
@Override
public boolean onAcceptUrl(final String url) {
final URL urlObj;
try {
urlObj = Utils.stringToURL(url);
} catch (final MalformedURLException e) {
return false;
}
return Utils.isHTTP(urlObj) && (isYoutubeURL(urlObj) || isInvidiousURL(urlObj))
&& LIVE_CHANNEL_PATH.equals(urlObj.getPath())
&& LIVE_CHANNEL_TAB_PARAMS.equals(urlObj.getQuery());
}
}