Package org.schabi.newpipe.extractor
Class StreamingService
- java.lang.Object
-
- org.schabi.newpipe.extractor.StreamingService
-
- Direct Known Subclasses:
BandcampService
,MediaCCCService
,PeertubeService
,SoundcloudService
,YoutubeService
public abstract class StreamingService extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StreamingService.LinkType
LinkType will be used to determine which type of URL you are handling, and therefore which part of NewPipe should handle a certain URL.static class
StreamingService.ServiceInfo
This class holds meta information about the service implementation.
-
Constructor Summary
Constructors Constructor Description StreamingService(int id, java.lang.String name, java.util.List<StreamingService.ServiceInfo.MediaCapability> capabilities)
Creates a new Streaming service.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.String
getBaseUrl()
ChannelExtractor
getChannelExtractor(java.lang.String url)
ChannelExtractor
getChannelExtractor(java.lang.String id, java.util.List<java.lang.String> contentFilter, java.lang.String sortFilter)
abstract ChannelExtractor
getChannelExtractor(ListLinkHandler linkHandler)
Must create a new instance of a ChannelExtractor implementation.abstract ListLinkHandlerFactory
getChannelLHFactory()
Must return a new instance of an implementation of ListLinkHandlerFactory for channels.abstract ChannelTabExtractor
getChannelTabExtractor(ListLinkHandler linkHandler)
Must create a new instance of a ChannelTabExtractor implementation.ChannelTabExtractor
getChannelTabExtractorFromId(java.lang.String id, java.lang.String tab)
ChannelTabExtractor
getChannelTabExtractorFromIdAndBaseUrl(java.lang.String id, java.lang.String tab, java.lang.String baseUrl)
abstract ListLinkHandlerFactory
getChannelTabLHFactory()
Must return a new instance of an implementation of ListLinkHandlerFactory for channel tabs.CommentsExtractor
getCommentsExtractor(java.lang.String url)
abstract CommentsExtractor
getCommentsExtractor(ListLinkHandler linkHandler)
abstract ListLinkHandlerFactory
getCommentsLHFactory()
ContentCountry
getContentCountry()
Returns the country that should be used to fetch content in this service.FeedExtractor
getFeedExtractor(java.lang.String url)
This method decides which strategy will be chosen to fetch the feed.abstract KioskList
getKioskList()
Must create a new instance of a KioskList implementation.StreamingService.LinkType
getLinkTypeByUrl(java.lang.String url)
Figures out where the link is pointing to (a channel, a video, a playlist, etc.)Localization
getLocalization()
Returns the localization that should be used in this service.PlaylistExtractor
getPlaylistExtractor(java.lang.String url)
PlaylistExtractor
getPlaylistExtractor(java.lang.String id, java.util.List<java.lang.String> contentFilter, java.lang.String sortFilter)
abstract PlaylistExtractor
getPlaylistExtractor(ListLinkHandler linkHandler)
Must crete a new instance of a PlaylistExtractor implementation.abstract ListLinkHandlerFactory
getPlaylistLHFactory()
Must return a new instance of an implementation of ListLinkHandlerFactory for playlists.SearchExtractor
getSearchExtractor(java.lang.String query)
SearchExtractor
getSearchExtractor(java.lang.String query, java.util.List<java.lang.String> contentFilter, java.lang.String sortFilter)
abstract SearchExtractor
getSearchExtractor(SearchQueryHandler queryHandler)
Must create a new instance of a SearchExtractor implementation.abstract SearchQueryHandlerFactory
getSearchQHFactory()
Must return an instance of an implementation of SearchQueryHandlerFactory.int
getServiceId()
StreamingService.ServiceInfo
getServiceInfo()
StreamExtractor
getStreamExtractor(java.lang.String url)
abstract StreamExtractor
getStreamExtractor(LinkHandler linkHandler)
Must create a new instance of a StreamExtractor implementation.abstract LinkHandlerFactory
getStreamLHFactory()
Must return a new instance of an implementation of LinkHandlerFactory for streams.abstract SubscriptionExtractor
getSubscriptionExtractor()
Outdated or obsolete.abstract SuggestionExtractor
getSuggestionExtractor()
Must create a new instance of a SuggestionExtractor implementation.java.util.List<ContentCountry>
getSupportedCountries()
Returns a list of countries that this service supports.java.util.List<Localization>
getSupportedLocalizations()
Returns a list of localizations that this service supports.TimeAgoParser
getTimeAgoParser(Localization localization)
Get an instance of the time ago parser using the patterns related to the passed localization.java.lang.String
toString()
-
-
-
Constructor Detail
-
StreamingService
public StreamingService(int id, java.lang.String name, java.util.List<StreamingService.ServiceInfo.MediaCapability> capabilities)
Creates a new Streaming service. If you Implement one do not set id within your implementation of this extractor, instead set the id when you put the extractor intoServiceList
All other parameters can be set directly from the overriding constructor.- Parameters:
id
- the number of the service to identify him within the NewPipe frontendname
- the name of the servicecapabilities
- the type of media this service can handle
-
-
Method Detail
-
getServiceId
public final int getServiceId()
-
getServiceInfo
public StreamingService.ServiceInfo getServiceInfo()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getBaseUrl
public abstract java.lang.String getBaseUrl()
-
getStreamLHFactory
public abstract LinkHandlerFactory getStreamLHFactory()
Must return a new instance of an implementation of LinkHandlerFactory for streams.- Returns:
- an instance of a LinkHandlerFactory for streams
-
getChannelLHFactory
public abstract ListLinkHandlerFactory getChannelLHFactory()
Must return a new instance of an implementation of ListLinkHandlerFactory for channels. If support for channels is not given null must be returned.- Returns:
- an instance of a ListLinkHandlerFactory for channels or null
-
getChannelTabLHFactory
public abstract ListLinkHandlerFactory getChannelTabLHFactory()
Must return a new instance of an implementation of ListLinkHandlerFactory for channel tabs. If support for channel tabs is not given null must be returned.- Returns:
- an instance of a ListLinkHandlerFactory for channels or null
-
getPlaylistLHFactory
public abstract ListLinkHandlerFactory getPlaylistLHFactory()
Must return a new instance of an implementation of ListLinkHandlerFactory for playlists. If support for playlists is not given null must be returned.- Returns:
- an instance of a ListLinkHandlerFactory for playlists or null
-
getSearchQHFactory
public abstract SearchQueryHandlerFactory getSearchQHFactory()
Must return an instance of an implementation of SearchQueryHandlerFactory.- Returns:
- an instance of a SearchQueryHandlerFactory
-
getCommentsLHFactory
public abstract ListLinkHandlerFactory getCommentsLHFactory()
-
getSearchExtractor
public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler)
Must create a new instance of a SearchExtractor implementation.- Parameters:
queryHandler
- specifies the keyword lock for, and the filters which should be applied.- Returns:
- a new SearchExtractor instance
-
getSuggestionExtractor
public abstract SuggestionExtractor getSuggestionExtractor()
Must create a new instance of a SuggestionExtractor implementation.- Returns:
- a new SuggestionExtractor instance
-
getSubscriptionExtractor
public abstract SubscriptionExtractor getSubscriptionExtractor()
Outdated or obsolete. null can be returned.- Returns:
- just null
-
getFeedExtractor
@Nullable public FeedExtractor getFeedExtractor(java.lang.String url) throws ExtractionException
This method decides which strategy will be chosen to fetch the feed. In YouTube, for example, a separate feed exists which is lightweight and made specifically to be used like this.In services which there's no other way to retrieve them, null should be returned.
- Returns:
- a
FeedExtractor
instance or null. - Throws:
ExtractionException
-
getKioskList
public abstract KioskList getKioskList() throws ExtractionException
Must create a new instance of a KioskList implementation.- Returns:
- a new KioskList instance
- Throws:
ExtractionException
-
getChannelExtractor
public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) throws ExtractionException
Must create a new instance of a ChannelExtractor implementation.- Parameters:
linkHandler
- is pointing to the channel which should be handled by this new instance.- Returns:
- a new ChannelExtractor
- Throws:
ExtractionException
-
getChannelTabExtractor
public abstract ChannelTabExtractor getChannelTabExtractor(ListLinkHandler linkHandler) throws ExtractionException
Must create a new instance of a ChannelTabExtractor implementation.- Parameters:
linkHandler
- is pointing to the channel which should be handled by this new instance.- Returns:
- a new ChannelTabExtractor
- Throws:
ExtractionException
-
getPlaylistExtractor
public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler) throws ExtractionException
Must crete a new instance of a PlaylistExtractor implementation.- Parameters:
linkHandler
- is pointing to the playlist which should be handled by this new instance.- Returns:
- a new PlaylistExtractor
- Throws:
ExtractionException
-
getStreamExtractor
public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException
Must create a new instance of a StreamExtractor implementation.- Parameters:
linkHandler
- is pointing to the stream which should be handled by this new instance.- Returns:
- a new StreamExtractor
- Throws:
ExtractionException
-
getCommentsExtractor
public abstract CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler) throws ExtractionException
- Throws:
ExtractionException
-
getSearchExtractor
public SearchExtractor getSearchExtractor(java.lang.String query, java.util.List<java.lang.String> contentFilter, java.lang.String sortFilter) throws ExtractionException
- Throws:
ExtractionException
-
getChannelExtractor
public ChannelExtractor getChannelExtractor(java.lang.String id, java.util.List<java.lang.String> contentFilter, java.lang.String sortFilter) throws ExtractionException
- Throws:
ExtractionException
-
getPlaylistExtractor
public PlaylistExtractor getPlaylistExtractor(java.lang.String id, java.util.List<java.lang.String> contentFilter, java.lang.String sortFilter) throws ExtractionException
- Throws:
ExtractionException
-
getSearchExtractor
public SearchExtractor getSearchExtractor(java.lang.String query) throws ExtractionException
- Throws:
ExtractionException
-
getChannelExtractor
public ChannelExtractor getChannelExtractor(java.lang.String url) throws ExtractionException
- Throws:
ExtractionException
-
getChannelTabExtractorFromId
public ChannelTabExtractor getChannelTabExtractorFromId(java.lang.String id, java.lang.String tab) throws ExtractionException
- Throws:
ExtractionException
-
getChannelTabExtractorFromIdAndBaseUrl
public ChannelTabExtractor getChannelTabExtractorFromIdAndBaseUrl(java.lang.String id, java.lang.String tab, java.lang.String baseUrl) throws ExtractionException
- Throws:
ExtractionException
-
getPlaylistExtractor
public PlaylistExtractor getPlaylistExtractor(java.lang.String url) throws ExtractionException
- Throws:
ExtractionException
-
getStreamExtractor
public StreamExtractor getStreamExtractor(java.lang.String url) throws ExtractionException
- Throws:
ExtractionException
-
getCommentsExtractor
public CommentsExtractor getCommentsExtractor(java.lang.String url) throws ExtractionException
- Throws:
ExtractionException
-
getLinkTypeByUrl
public final StreamingService.LinkType getLinkTypeByUrl(java.lang.String url) throws ParsingException
Figures out where the link is pointing to (a channel, a video, a playlist, etc.)- Parameters:
url
- the url on which it should be decided of which link type it is- Returns:
- the link type of url
- Throws:
ParsingException
-
getSupportedLocalizations
public java.util.List<Localization> getSupportedLocalizations()
Returns a list of localizations that this service supports.
-
getSupportedCountries
public java.util.List<ContentCountry> getSupportedCountries()
Returns a list of countries that this service supports.
-
getLocalization
public Localization getLocalization()
Returns the localization that should be used in this service. It will get which localization the user prefer (usingNewPipe.getPreferredLocalization()
), then it will:- Check if the exactly localization is supported by this service.
- If not, check if a less specific localization is available, using only the language code.
- Fallback to the
default
localization.
-
getContentCountry
public ContentCountry getContentCountry()
Returns the country that should be used to fetch content in this service. It will get which country the user prefer (usingNewPipe.getPreferredContentCountry()
), then it will:- Check if the country is supported by this service.
- If not, fallback to the
default
country.
-
getTimeAgoParser
public TimeAgoParser getTimeAgoParser(Localization localization)
Get an instance of the time ago parser using the patterns related to the passed localization.
Just likegetLocalization()
, it will also try to fallback to a less specific localization if the exact one is not available/supported.- Throws:
java.lang.IllegalArgumentException
- if the localization is not supported (parsing patterns are not present).
-
-