1414import java .util .Collections ;
1515import java .util .List ;
1616
17+ /*
18+ * Copyright (C) Christian Schabesberger 2018 <chris.schabesberger@mailbox.org>
19+ * StreamingService.java is part of NewPipe.
20+ *
21+ * NewPipe is free software: you can redistribute it and/or modify
22+ * it under the terms of the GNU General Public License as published by
23+ * the Free Software Foundation, either version 3 of the License, or
24+ * (at your option) any later version.
25+ *
26+ * NewPipe is distributed in the hope that it will be useful,
27+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+ * GNU General Public License for more details.
30+ *
31+ * You should have received a copy of the GNU General Public License
32+ * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
33+ */
34+
1735public abstract class StreamingService {
36+
37+ /**
38+ * This class holds meta information about the service implementation.
39+ */
1840 public static class ServiceInfo {
1941 private final String name ;
2042 private final List <MediaCapability > mediaCapabilities ;
2143
44+ /**
45+ * Creates a new instance of a ServiceInfo
46+ * @param name the name of the service
47+ * @param mediaCapabilities the type of media this service can handle
48+ */
2249 public ServiceInfo (String name , List <MediaCapability > mediaCapabilities ) {
2350 this .name = name ;
2451 this .mediaCapabilities = Collections .unmodifiableList (mediaCapabilities );
@@ -37,6 +64,10 @@ public enum MediaCapability {
3764 }
3865 }
3966
67+ /**
68+ * LinkType will be used to determine which type of URL you are handling, and therefore which part
69+ * of NewPipe should handle a certain URL.
70+ */
4071 public enum LinkType {
4172 NONE ,
4273 STREAM ,
@@ -47,6 +78,16 @@ public enum LinkType {
4778 private final int serviceId ;
4879 private final ServiceInfo serviceInfo ;
4980
81+ /**
82+ * Creates a new Streaming service.
83+ * If you Implement one do not set id within your implementation of this extractor, instead
84+ * set the id when you put the extractor into
85+ * <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/ServiceList.html">ServiceList</a>.
86+ * All other parameters can be set directly from the overriding constructor.
87+ * @param id the number of the service to identify him within the NewPipe frontend
88+ * @param name the name of the service
89+ * @param capabilities the type of media this service can handle
90+ */
5091 public StreamingService (int id , String name , List <ServiceInfo .MediaCapability > capabilities ) {
5192 this .serviceId = id ;
5293 this .serviceInfo = new ServiceInfo (name , capabilities );
@@ -68,24 +109,93 @@ public String toString() {
68109 ////////////////////////////////////////////
69110 // Url Id handler
70111 ////////////////////////////////////////////
112+
113+ /**
114+ * Must return a new instance of an implementation of LinkHandlerFactory for streams.
115+ * @return an instance of a LinkHandlerFactory for streams
116+ */
71117 public abstract LinkHandlerFactory getStreamLHFactory ();
118+
119+ /**
120+ * Must return a new instance of an implementation of ListLinkHandlerFactory for channels.
121+ * If support for channels is not given null must be returned.
122+ * @return an instance of a ListLinkHandlerFactory for channels or null
123+ */
72124 public abstract ListLinkHandlerFactory getChannelLHFactory ();
125+
126+ /**
127+ * Must return a new instance of an implementation of ListLinkHandlerFactory for playlists.
128+ * If support for playlists is not given null must be returned.
129+ * @return an instance of a ListLinkHandlerFactory for playlists or null
130+ */
73131 public abstract ListLinkHandlerFactory getPlaylistLHFactory ();
132+
133+ /**
134+ * Must return an instance of an implementation of SearchQueryHandlerFactory.
135+ * @return an instance of a SearchQueryHandlerFactory
136+ */
74137 public abstract SearchQueryHandlerFactory getSearchQHFactory ();
75138
76139
77140 ////////////////////////////////////////////
78141 // Extractor
79142 ////////////////////////////////////////////
143+
144+ /**
145+ * Must create a new instance of a SearchExtractor implementation.
146+ * @param queryHandler specifies the keyword lock for, and the filters which should be applied.
147+ * @param localization specifies the language/country for the extractor.
148+ * @return a new SearchExtractor instance
149+ */
80150 public abstract SearchExtractor getSearchExtractor (SearchQueryHandler queryHandler , Localization localization );
151+
152+ /**
153+ * Must create a new instance of a SuggestionExtractor implementation.
154+ * @param localization specifies the language/country for the extractor.
155+ * @return a new SuggestionExtractor instance
156+ */
81157 public abstract SuggestionExtractor getSuggestionExtractor (Localization localization );
158+
159+ /**
160+ * Outdated or obsolete. null can be returned.
161+ * @return just null
162+ */
82163 public abstract SubscriptionExtractor getSubscriptionExtractor ();
164+
165+ /**
166+ * Must create a new instance of a KioskList implementation.
167+ * @return a new KioskList instance
168+ * @throws ExtractionException
169+ */
83170 public abstract KioskList getKioskList () throws ExtractionException ;
84171
172+ /**
173+ * Must create a new instance of a ChannelExtractor implementation.
174+ * @param linkHandler is pointing to the channel which should be handled by this new instance.
175+ * @param localization specifies the language used for the request.
176+ * @return a new ChannelExtractor
177+ * @throws ExtractionException
178+ */
85179 public abstract ChannelExtractor getChannelExtractor (ListLinkHandler linkHandler ,
86180 Localization localization ) throws ExtractionException ;
181+
182+ /**
183+ * Must crete a new instance of a PlaylistExtractor implementation.
184+ * @param linkHandler is pointing to the playlist which should be handled by this new instance.
185+ * @param localization specifies the language used for the request.
186+ * @return a new PlaylistExtractor
187+ * @throws ExtractionException
188+ */
87189 public abstract PlaylistExtractor getPlaylistExtractor (ListLinkHandler linkHandler ,
88190 Localization localization ) throws ExtractionException ;
191+
192+ /**
193+ * Must create a new instance of a StreamExtractor implementation.
194+ * @param linkHandler is pointing to the stream which should be handled by this new instance.
195+ * @param localization specifies the language used for the request.
196+ * @return a new StreamExtractor
197+ * @throws ExtractionException
198+ */
89199 public abstract StreamExtractor getStreamExtractor (LinkHandler linkHandler ,
90200 Localization localization ) throws ExtractionException ;
91201 ////////////////////////////////////////////
@@ -165,9 +275,11 @@ public StreamExtractor getStreamExtractor(String url) throws ExtractionException
165275 return getStreamExtractor (getStreamLHFactory ().fromUrl (url ), NewPipe .getPreferredLocalization ());
166276 }
167277
168-
169278 /**
170- * figure out where the link is pointing to (a channel, video, playlist, etc.)
279+ * Figures out where the link is pointing to (a channel, a video, a playlist, etc.)
280+ * @param url the url on which it should be decided of which link type it is
281+ * @return the link type of url
282+ * @throws ParsingException
171283 */
172284 public final LinkType getLinkTypeByUrl (String url ) throws ParsingException {
173285 LinkHandlerFactory sH = getStreamLHFactory ();
0 commit comments