mirror of
https://github.com/TeamNewPipe/NewPipeExtractor
synced 2025-08-29 13:27:38 +00:00
[YouTube] Add trending movies and shows trailers extractor
This kiosk also returns some videos for unsupported YouTube Charts countries, even if there are fewer than in a supported country.
This commit is contained in:
parent
e643024ff0
commit
f4203e632d
@ -38,6 +38,7 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSuggestio
|
|||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingExtractor;
|
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.extractors.kiosk.YoutubeLiveExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingGamingVideosExtractor;
|
import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingGamingVideosExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingMoviesAndShowsTrailersExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingPodcastsEpisodesExtractor;
|
import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingPodcastsEpisodesExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
|
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.YoutubeChannelTabLinkHandlerFactory;
|
||||||
@ -48,6 +49,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQu
|
|||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingGamingVideosLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingGamingVideosLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory;
|
||||||
|
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingMoviesAndShowsTrailersLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingPodcastsEpisodesLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingPodcastsEpisodesLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||||
@ -167,6 +169,8 @@ public class YoutubeService extends StreamingService {
|
|||||||
YoutubeTrendingPodcastsEpisodesLinkHandlerFactory.INSTANCE;
|
YoutubeTrendingPodcastsEpisodesLinkHandlerFactory.INSTANCE;
|
||||||
final ListLinkHandlerFactory trendingGamingVideosLHF =
|
final ListLinkHandlerFactory trendingGamingVideosLHF =
|
||||||
YoutubeTrendingGamingVideosLinkHandlerFactory.INSTANCE;
|
YoutubeTrendingGamingVideosLinkHandlerFactory.INSTANCE;
|
||||||
|
final ListLinkHandlerFactory trendingMoviesAndShowsLHF =
|
||||||
|
YoutubeTrendingMoviesAndShowsTrailersLinkHandlerFactory.INSTANCE;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
list.addKioskEntry(
|
list.addKioskEntry(
|
||||||
@ -193,6 +197,15 @@ public class YoutubeService extends StreamingService {
|
|||||||
trendingGamingVideosLHF,
|
trendingGamingVideosLHF,
|
||||||
YoutubeTrendingGamingVideosLinkHandlerFactory.KIOSK_ID
|
YoutubeTrendingGamingVideosLinkHandlerFactory.KIOSK_ID
|
||||||
);
|
);
|
||||||
|
list.addKioskEntry(
|
||||||
|
(streamingService, url, id) ->
|
||||||
|
new YoutubeTrendingMoviesAndShowsTrailersExtractor(
|
||||||
|
YoutubeService.this,
|
||||||
|
trendingMoviesAndShowsLHF.fromUrl(url),
|
||||||
|
id),
|
||||||
|
trendingMoviesAndShowsLHF,
|
||||||
|
YoutubeTrendingMoviesAndShowsTrailersLinkHandlerFactory.KIOSK_ID
|
||||||
|
);
|
||||||
list.addKioskEntry(
|
list.addKioskEntry(
|
||||||
(streamingService, url, id) -> new YoutubeTrendingExtractor(
|
(streamingService, url, id) -> new YoutubeTrendingExtractor(
|
||||||
YoutubeService.this,
|
YoutubeService.this,
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package org.schabi.newpipe.extractor.services.youtube.extractors.kiosk;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class YoutubeTrendingMoviesAndShowsTrailersExtractor
|
||||||
|
extends YoutubeChartsBaseKioskExtractor {
|
||||||
|
|
||||||
|
public YoutubeTrendingMoviesAndShowsTrailersExtractor(final StreamingService streamingService,
|
||||||
|
final ListLinkHandler linkHandler,
|
||||||
|
final String kioskId) {
|
||||||
|
super(streamingService, linkHandler, kioskId, "TRENDING_MOVIES");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getName() throws ParsingException {
|
||||||
|
// This is the official YouTube Charts name, even if shows' trailers are returned too
|
||||||
|
return "Trending Movie Trailers";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public final class YoutubeTrendingMoviesAndShowsTrailersLinkHandlerFactory
|
||||||
|
extends ListLinkHandlerFactory {
|
||||||
|
|
||||||
|
public static final String KIOSK_ID = "trending_movies_and_shows";
|
||||||
|
|
||||||
|
public static final YoutubeTrendingMoviesAndShowsTrailersLinkHandlerFactory INSTANCE =
|
||||||
|
new YoutubeTrendingMoviesAndShowsTrailersLinkHandlerFactory();
|
||||||
|
|
||||||
|
private static final String PATH = "/charts/TrendingTrailers";
|
||||||
|
|
||||||
|
private YoutubeTrendingMoviesAndShowsTrailersLinkHandlerFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUrl(final String id,
|
||||||
|
final List<String> contentFilter,
|
||||||
|
final String sortFilter)
|
||||||
|
throws ParsingException, UnsupportedOperationException {
|
||||||
|
return "https://charts.youtube.com" + PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId(final String url) throws ParsingException, UnsupportedOperationException {
|
||||||
|
return KIOSK_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onAcceptUrl(final String url) throws ParsingException {
|
||||||
|
final URL urlObj;
|
||||||
|
try {
|
||||||
|
urlObj = Utils.stringToURL(url);
|
||||||
|
} catch (final MalformedURLException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Utils.isHTTP(urlObj)
|
||||||
|
&& "charts.youtube.com".equals(urlObj.getHost().toLowerCase(Locale.ROOT))
|
||||||
|
&& PATH.equals(urlObj.getPath());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user