2017-03-01 17:47:52 +00:00
|
|
|
package org.schabi.newpipe.extractor;
|
|
|
|
|
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
2017-06-29 18:12:55 +00:00
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
2017-03-01 17:47:52 +00:00
|
|
|
import org.schabi.newpipe.extractor.search.SearchEngine;
|
2017-06-29 18:12:55 +00:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
2017-03-01 17:47:52 +00:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
public abstract class StreamingService {
|
|
|
|
public class ServiceInfo {
|
|
|
|
public String name = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum LinkType {
|
|
|
|
NONE,
|
|
|
|
STREAM,
|
|
|
|
CHANNEL,
|
|
|
|
PLAYLIST
|
|
|
|
}
|
|
|
|
|
|
|
|
private int serviceId;
|
|
|
|
|
|
|
|
public StreamingService(int id) {
|
|
|
|
serviceId = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract ServiceInfo getServiceInfo();
|
2017-07-09 22:43:04 +00:00
|
|
|
|
2017-03-01 17:47:52 +00:00
|
|
|
public abstract UrlIdHandler getStreamUrlIdHandlerInstance();
|
|
|
|
public abstract UrlIdHandler getChannelUrlIdHandlerInstance();
|
2017-06-29 18:12:55 +00:00
|
|
|
public abstract UrlIdHandler getPlaylistUrlIdHandlerInstance();
|
2017-07-09 22:43:04 +00:00
|
|
|
public abstract SearchEngine getSearchEngineInstance();
|
|
|
|
public abstract SuggestionExtractor getSuggestionExtractorInstance();
|
|
|
|
public abstract StreamExtractor getStreamExtractorInstance(String url) throws IOException, ExtractionException;
|
2017-06-29 18:12:55 +00:00
|
|
|
public abstract ChannelExtractor getChannelExtractorInstance(String url) throws ExtractionException, IOException;
|
|
|
|
public abstract PlaylistExtractor getPlaylistExtractorInstance(String url) throws ExtractionException, IOException;
|
2017-03-01 17:47:52 +00:00
|
|
|
|
2017-06-29 18:12:55 +00:00
|
|
|
|
2017-03-01 17:47:52 +00:00
|
|
|
public final int getServiceId() {
|
|
|
|
return serviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* figure out where the link is pointing to (a channel, video, playlist, etc.)
|
|
|
|
*/
|
|
|
|
public final LinkType getLinkTypeByUrl(String url) {
|
|
|
|
UrlIdHandler sH = getStreamUrlIdHandlerInstance();
|
|
|
|
UrlIdHandler cH = getChannelUrlIdHandlerInstance();
|
2017-06-29 18:12:55 +00:00
|
|
|
UrlIdHandler pH = getPlaylistUrlIdHandlerInstance();
|
2017-03-01 17:47:52 +00:00
|
|
|
|
2017-06-29 18:12:55 +00:00
|
|
|
if (sH.acceptUrl(url)) {
|
2017-03-01 17:47:52 +00:00
|
|
|
return LinkType.STREAM;
|
2017-06-29 18:12:55 +00:00
|
|
|
} else if (cH.acceptUrl(url)) {
|
2017-03-01 17:47:52 +00:00
|
|
|
return LinkType.CHANNEL;
|
2017-03-12 15:15:51 +00:00
|
|
|
} else if (pH.acceptUrl(url)) {
|
|
|
|
return LinkType.PLAYLIST;
|
2017-03-01 17:47:52 +00:00
|
|
|
} else {
|
|
|
|
return LinkType.NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|