2017-03-01 23:17:52 +05:30
|
|
|
package org.schabi.newpipe.extractor;
|
|
|
|
|
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
2017-06-29 23:42:55 +05:30
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
2017-03-01 23:17:52 +05:30
|
|
|
import org.schabi.newpipe.extractor.search.SearchEngine;
|
2017-06-29 23:42:55 +05:30
|
|
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
2017-03-01 23:17:52 +05:30
|
|
|
|
|
|
|
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-10 04:13:04 +05:30
|
|
|
|
2017-03-01 23:17:52 +05:30
|
|
|
public abstract UrlIdHandler getStreamUrlIdHandlerInstance();
|
|
|
|
public abstract UrlIdHandler getChannelUrlIdHandlerInstance();
|
2017-06-29 23:42:55 +05:30
|
|
|
public abstract UrlIdHandler getPlaylistUrlIdHandlerInstance();
|
2017-07-10 04:13:04 +05:30
|
|
|
public abstract SearchEngine getSearchEngineInstance();
|
|
|
|
public abstract SuggestionExtractor getSuggestionExtractorInstance();
|
|
|
|
public abstract StreamExtractor getStreamExtractorInstance(String url) throws IOException, ExtractionException;
|
2017-06-29 23:42:55 +05:30
|
|
|
public abstract ChannelExtractor getChannelExtractorInstance(String url) throws ExtractionException, IOException;
|
|
|
|
public abstract PlaylistExtractor getPlaylistExtractorInstance(String url) throws ExtractionException, IOException;
|
2017-03-01 23:17:52 +05:30
|
|
|
|
2017-06-29 23:42:55 +05:30
|
|
|
|
2017-03-01 23:17:52 +05:30
|
|
|
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 23:42:55 +05:30
|
|
|
UrlIdHandler pH = getPlaylistUrlIdHandlerInstance();
|
2017-03-01 23:17:52 +05:30
|
|
|
|
2017-06-29 23:42:55 +05:30
|
|
|
if (sH.acceptUrl(url)) {
|
2017-03-01 23:17:52 +05:30
|
|
|
return LinkType.STREAM;
|
2017-06-29 23:42:55 +05:30
|
|
|
} else if (cH.acceptUrl(url)) {
|
2017-03-01 23:17:52 +05:30
|
|
|
return LinkType.CHANNEL;
|
2017-03-12 20:45:51 +05:30
|
|
|
} else if (pH.acceptUrl(url)) {
|
|
|
|
return LinkType.PLAYLIST;
|
2017-03-01 23:17:52 +05:30
|
|
|
} else {
|
|
|
|
return LinkType.NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|