Merge branch 'master' into master
This commit is contained in:
commit
43ffeac023
|
@ -1,6 +1,6 @@
|
||||||
# NewPipe Extractor
|
# NewPipe Extractor
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/TeamNewPipe/NewPipeExtractor.svg?branch=master)](https://travis-ci.org/TeamNewPipe/NewPipeExtractor) [![JIT Pack Badge](https://jitpack.io/v/TeamNewPipe/NewPipeExtractor.svg)](https://jitpack.io/#TeamNewPipe/NewPipeExtractor) [Documentation](https://teamnewpipe.github.io/NewPipeExtractor/javadoc/)
|
[![Build Status](https://travis-ci.org/TeamNewPipe/NewPipeExtractor.svg?branch=master)](https://travis-ci.org/TeamNewPipe/NewPipeExtractor) [![JIT Pack Badge](https://jitpack.io/v/TeamNewPipe/NewPipeExtractor.svg)](https://jitpack.io/#TeamNewPipe/NewPipeExtractor) [Documentation](https://teamnewpipe.github.io/documentation/)
|
||||||
|
|
||||||
NewPipe Extractor is a library for extracting things from streaming sites. It is a core component of [NewPipe](https://github.com/TeamNewPipe/NewPipe), but could be used independently.
|
NewPipe Extractor is a library for extracting things from streaming sites. It is a core component of [NewPipe](https://github.com/TeamNewPipe/NewPipe), but could be used independently.
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,24 @@ import java.util.List;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Collections.unmodifiableList;
|
import static java.util.Collections.unmodifiableList;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Christian Schabesberger 2018 <chris.schabesberger@mailbox.org>
|
||||||
|
* ServiceList.java is part of NewPipe.
|
||||||
|
*
|
||||||
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* NewPipe is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of supported services.
|
* A list of supported services.
|
||||||
*/
|
*/
|
||||||
|
@ -19,6 +37,10 @@ public final class ServiceList {
|
||||||
public static final YoutubeService YouTube;
|
public static final YoutubeService YouTube;
|
||||||
public static final SoundcloudService SoundCloud;
|
public static final SoundcloudService SoundCloud;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When creating a new service, put this service in the end of this list,
|
||||||
|
* and give it the next free id.
|
||||||
|
*/
|
||||||
private static final List<StreamingService> SERVICES = unmodifiableList(
|
private static final List<StreamingService> SERVICES = unmodifiableList(
|
||||||
asList(
|
asList(
|
||||||
YouTube = new YoutubeService(0),
|
YouTube = new YoutubeService(0),
|
||||||
|
|
|
@ -14,11 +14,38 @@ import org.schabi.newpipe.extractor.utils.Localization;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) Christian Schabesberger 2018 <chris.schabesberger@mailbox.org>
|
||||||
|
* StreamingService.java is part of NewPipe.
|
||||||
|
*
|
||||||
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* NewPipe is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
public abstract class StreamingService {
|
public abstract class StreamingService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class holds meta information about the service implementation.
|
||||||
|
*/
|
||||||
public static class ServiceInfo {
|
public static class ServiceInfo {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final List<MediaCapability> mediaCapabilities;
|
private final List<MediaCapability> mediaCapabilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of a ServiceInfo
|
||||||
|
* @param name the name of the service
|
||||||
|
* @param mediaCapabilities the type of media this service can handle
|
||||||
|
*/
|
||||||
public ServiceInfo(String name, List<MediaCapability> mediaCapabilities) {
|
public ServiceInfo(String name, List<MediaCapability> mediaCapabilities) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.mediaCapabilities = Collections.unmodifiableList(mediaCapabilities);
|
this.mediaCapabilities = Collections.unmodifiableList(mediaCapabilities);
|
||||||
|
@ -37,6 +64,10 @@ public abstract class StreamingService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LinkType will be used to determine which type of URL you are handling, and therefore which part
|
||||||
|
* of NewPipe should handle a certain URL.
|
||||||
|
*/
|
||||||
public enum LinkType {
|
public enum LinkType {
|
||||||
NONE,
|
NONE,
|
||||||
STREAM,
|
STREAM,
|
||||||
|
@ -47,6 +78,16 @@ public abstract class StreamingService {
|
||||||
private final int serviceId;
|
private final int serviceId;
|
||||||
private final ServiceInfo serviceInfo;
|
private final ServiceInfo serviceInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 into
|
||||||
|
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/ServiceList.html">ServiceList</a>.
|
||||||
|
* All other parameters can be set directly from the overriding constructor.
|
||||||
|
* @param id the number of the service to identify him within the NewPipe frontend
|
||||||
|
* @param name the name of the service
|
||||||
|
* @param capabilities the type of media this service can handle
|
||||||
|
*/
|
||||||
public StreamingService(int id, String name, List<ServiceInfo.MediaCapability> capabilities) {
|
public StreamingService(int id, String name, List<ServiceInfo.MediaCapability> capabilities) {
|
||||||
this.serviceId = id;
|
this.serviceId = id;
|
||||||
this.serviceInfo = new ServiceInfo(name, capabilities);
|
this.serviceInfo = new ServiceInfo(name, capabilities);
|
||||||
|
@ -68,24 +109,93 @@ public abstract class StreamingService {
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
// Url Id handler
|
// Url Id handler
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must return a new instance of an implementation of LinkHandlerFactory for streams.
|
||||||
|
* @return an instance of a LinkHandlerFactory for streams
|
||||||
|
*/
|
||||||
public abstract LinkHandlerFactory getStreamLHFactory();
|
public abstract LinkHandlerFactory getStreamLHFactory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must return a new instance of an implementation of ListLinkHandlerFactory for channels.
|
||||||
|
* If support for channels is not given null must be returned.
|
||||||
|
* @return an instance of a ListLinkHandlerFactory for channels or null
|
||||||
|
*/
|
||||||
public abstract ListLinkHandlerFactory getChannelLHFactory();
|
public abstract ListLinkHandlerFactory getChannelLHFactory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must return a new instance of an implementation of ListLinkHandlerFactory for playlists.
|
||||||
|
* If support for playlists is not given null must be returned.
|
||||||
|
* @return an instance of a ListLinkHandlerFactory for playlists or null
|
||||||
|
*/
|
||||||
public abstract ListLinkHandlerFactory getPlaylistLHFactory();
|
public abstract ListLinkHandlerFactory getPlaylistLHFactory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must return an instance of an implementation of SearchQueryHandlerFactory.
|
||||||
|
* @return an instance of a SearchQueryHandlerFactory
|
||||||
|
*/
|
||||||
public abstract SearchQueryHandlerFactory getSearchQHFactory();
|
public abstract SearchQueryHandlerFactory getSearchQHFactory();
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
// Extractor
|
// Extractor
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must create a new instance of a SearchExtractor implementation.
|
||||||
|
* @param queryHandler specifies the keyword lock for, and the filters which should be applied.
|
||||||
|
* @param localization specifies the language/country for the extractor.
|
||||||
|
* @return a new SearchExtractor instance
|
||||||
|
*/
|
||||||
public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization);
|
public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must create a new instance of a SuggestionExtractor implementation.
|
||||||
|
* @param localization specifies the language/country for the extractor.
|
||||||
|
* @return a new SuggestionExtractor instance
|
||||||
|
*/
|
||||||
public abstract SuggestionExtractor getSuggestionExtractor(Localization localization);
|
public abstract SuggestionExtractor getSuggestionExtractor(Localization localization);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outdated or obsolete. null can be returned.
|
||||||
|
* @return just null
|
||||||
|
*/
|
||||||
public abstract SubscriptionExtractor getSubscriptionExtractor();
|
public abstract SubscriptionExtractor getSubscriptionExtractor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must create a new instance of a KioskList implementation.
|
||||||
|
* @return a new KioskList instance
|
||||||
|
* @throws ExtractionException
|
||||||
|
*/
|
||||||
public abstract KioskList getKioskList() throws ExtractionException;
|
public abstract KioskList getKioskList() throws ExtractionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must create a new instance of a ChannelExtractor implementation.
|
||||||
|
* @param linkHandler is pointing to the channel which should be handled by this new instance.
|
||||||
|
* @param localization specifies the language used for the request.
|
||||||
|
* @return a new ChannelExtractor
|
||||||
|
* @throws ExtractionException
|
||||||
|
*/
|
||||||
public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler,
|
public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler,
|
||||||
Localization localization) throws ExtractionException;
|
Localization localization) throws ExtractionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must crete a new instance of a PlaylistExtractor implementation.
|
||||||
|
* @param linkHandler is pointing to the playlist which should be handled by this new instance.
|
||||||
|
* @param localization specifies the language used for the request.
|
||||||
|
* @return a new PlaylistExtractor
|
||||||
|
* @throws ExtractionException
|
||||||
|
*/
|
||||||
public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler,
|
public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler,
|
||||||
Localization localization) throws ExtractionException;
|
Localization localization) throws ExtractionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must create a new instance of a StreamExtractor implementation.
|
||||||
|
* @param linkHandler is pointing to the stream which should be handled by this new instance.
|
||||||
|
* @param localization specifies the language used for the request.
|
||||||
|
* @return a new StreamExtractor
|
||||||
|
* @throws ExtractionException
|
||||||
|
*/
|
||||||
public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler,
|
public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler,
|
||||||
Localization localization) throws ExtractionException;
|
Localization localization) throws ExtractionException;
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
|
@ -165,9 +275,11 @@ public abstract class StreamingService {
|
||||||
return getStreamExtractor(getStreamLHFactory().fromUrl(url), NewPipe.getPreferredLocalization());
|
return getStreamExtractor(getStreamLHFactory().fromUrl(url), NewPipe.getPreferredLocalization());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* figure out where the link is pointing to (a channel, video, playlist, etc.)
|
* Figures out where the link is pointing to (a channel, a video, a playlist, etc.)
|
||||||
|
* @param url the url on which it should be decided of which link type it is
|
||||||
|
* @return the link type of url
|
||||||
|
* @throws ParsingException
|
||||||
*/
|
*/
|
||||||
public final LinkType getLinkTypeByUrl(String url) throws ParsingException {
|
public final LinkType getLinkTypeByUrl(String url) throws ParsingException {
|
||||||
LinkHandlerFactory sH = getStreamLHFactory();
|
LinkHandlerFactory sH = getStreamLHFactory();
|
||||||
|
|
Loading…
Reference in New Issue