2020import org .schabi .newpipe .extractor .subscription .SubscriptionExtractor ;
2121import org .schabi .newpipe .extractor .utils .Localization ;
2222
23+ /*
24+ * Copyright (C) Christian Schabesberger 2018 <chris.schabesberger@mailbox.org>
25+ * StreamingService.java is part of NewPipe.
26+ *
27+ * NewPipe is free software: you can redistribute it and/or modify
28+ * it under the terms of the GNU General Public License as published by
29+ * the Free Software Foundation, either version 3 of the License, or
30+ * (at your option) any later version.
31+ *
32+ * NewPipe is distributed in the hope that it will be useful,
33+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
34+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35+ * GNU General Public License for more details.
36+ *
37+ * You should have received a copy of the GNU General Public License
38+ * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
39+ */
40+
2341public abstract class StreamingService {
42+
43+ /**
44+ * This class holds meta information about the service implementation.
45+ */
2446 public static class ServiceInfo {
2547 private final String name ;
2648 private final List <MediaCapability > mediaCapabilities ;
2749
50+ /**
51+ * Creates a new instance of a ServiceInfo
52+ * @param name the name of the service
53+ * @param mediaCapabilities the type of media this service can handle
54+ */
2855 public ServiceInfo (String name , List <MediaCapability > mediaCapabilities ) {
2956 this .name = name ;
3057 this .mediaCapabilities = Collections .unmodifiableList (mediaCapabilities );
@@ -43,6 +70,10 @@ public enum MediaCapability {
4370 }
4471 }
4572
73+ /**
74+ * LinkType will be used to determine which type of URL you are handling, and therefore which part
75+ * of NewPipe should handle a certain URL.
76+ */
4677 public enum LinkType {
4778 NONE ,
4879 STREAM ,
@@ -53,6 +84,16 @@ public enum LinkType {
5384 private final int serviceId ;
5485 private final ServiceInfo serviceInfo ;
5586
87+ /**
88+ * Creates a new Streaming service.
89+ * If you Implement one do not set id within your implementation of this extractor, instead
90+ * set the id when you put the extractor into
91+ * <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/ServiceList.html">ServiceList</a>.
92+ * All other parameters can be set directly from the overriding constructor.
93+ * @param id the number of the service to identify him within the NewPipe frontend
94+ * @param name the name of the service
95+ * @param capabilities the type of media this service can handle
96+ */
5697 public StreamingService (int id , String name , List <ServiceInfo .MediaCapability > capabilities ) {
5798 this .serviceId = id ;
5899 this .serviceInfo = new ServiceInfo (name , capabilities );
@@ -74,25 +115,94 @@ public String toString() {
74115 ////////////////////////////////////////////
75116 // Url Id handler
76117 ////////////////////////////////////////////
118+
119+ /**
120+ * Must return a new instance of an implementation of LinkHandlerFactory for streams.
121+ * @return an instance of a LinkHandlerFactory for streams
122+ */
77123 public abstract LinkHandlerFactory getStreamLHFactory ();
124+
125+ /**
126+ * Must return a new instance of an implementation of ListLinkHandlerFactory for channels.
127+ * If support for channels is not given null must be returned.
128+ * @return an instance of a ListLinkHandlerFactory for channels or null
129+ */
78130 public abstract ListLinkHandlerFactory getChannelLHFactory ();
131+
132+ /**
133+ * Must return a new instance of an implementation of ListLinkHandlerFactory for playlists.
134+ * If support for playlists is not given null must be returned.
135+ * @return an instance of a ListLinkHandlerFactory for playlists or null
136+ */
79137 public abstract ListLinkHandlerFactory getPlaylistLHFactory ();
138+
139+ /**
140+ * Must return an instance of an implementation of SearchQueryHandlerFactory.
141+ * @return an instance of a SearchQueryHandlerFactory
142+ */
80143 public abstract SearchQueryHandlerFactory getSearchQHFactory ();
81144 public abstract ListLinkHandlerFactory getCommentsLHFactory ();
82145
83146
84147 ////////////////////////////////////////////
85148 // Extractor
86149 ////////////////////////////////////////////
150+
151+ /**
152+ * Must create a new instance of a SearchExtractor implementation.
153+ * @param queryHandler specifies the keyword lock for, and the filters which should be applied.
154+ * @param localization specifies the language/country for the extractor.
155+ * @return a new SearchExtractor instance
156+ */
87157 public abstract SearchExtractor getSearchExtractor (SearchQueryHandler queryHandler , Localization localization );
158+
159+ /**
160+ * Must create a new instance of a SuggestionExtractor implementation.
161+ * @param localization specifies the language/country for the extractor.
162+ * @return a new SuggestionExtractor instance
163+ */
88164 public abstract SuggestionExtractor getSuggestionExtractor (Localization localization );
165+
166+ /**
167+ * Outdated or obsolete. null can be returned.
168+ * @return just null
169+ */
89170 public abstract SubscriptionExtractor getSubscriptionExtractor ();
171+
172+ /**
173+ * Must create a new instance of a KioskList implementation.
174+ * @return a new KioskList instance
175+ * @throws ExtractionException
176+ */
90177 public abstract KioskList getKioskList () throws ExtractionException ;
91178
179+ /**
180+ * Must create a new instance of a ChannelExtractor implementation.
181+ * @param linkHandler is pointing to the channel which should be handled by this new instance.
182+ * @param localization specifies the language used for the request.
183+ * @return a new ChannelExtractor
184+ * @throws ExtractionException
185+ */
92186 public abstract ChannelExtractor getChannelExtractor (ListLinkHandler linkHandler ,
93187 Localization localization ) throws ExtractionException ;
188+
189+ /**
190+ * Must crete a new instance of a PlaylistExtractor implementation.
191+ * @param linkHandler is pointing to the playlist which should be handled by this new instance.
192+ * @param localization specifies the language used for the request.
193+ * @return a new PlaylistExtractor
194+ * @throws ExtractionException
195+ */
94196 public abstract PlaylistExtractor getPlaylistExtractor (ListLinkHandler linkHandler ,
95197 Localization localization ) throws ExtractionException ;
198+
199+ /**
200+ * Must create a new instance of a StreamExtractor implementation.
201+ * @param linkHandler is pointing to the stream which should be handled by this new instance.
202+ * @param localization specifies the language used for the request.
203+ * @return a new StreamExtractor
204+ * @throws ExtractionException
205+ */
96206 public abstract StreamExtractor getStreamExtractor (LinkHandler linkHandler ,
97207 Localization localization ) throws ExtractionException ;
98208 public abstract CommentsExtractor getCommentsExtractor (ListLinkHandler linkHandler ,
@@ -192,6 +302,11 @@ public CommentsExtractor getCommentsExtractor(String url) throws ExtractionExcep
192302
193303 /**
194304 * figure out where the link is pointing to (a channel, video, playlist, etc.)
305+ /**
306+ * Figures out where the link is pointing to (a channel, a video, a playlist, etc.)
307+ * @param url the url on which it should be decided of which link type it is
308+ * @return the link type of url
309+ * @throws ParsingException
195310 */
196311 public final LinkType getLinkTypeByUrl (String url ) throws ParsingException {
197312 LinkHandlerFactory sH = getStreamLHFactory ();
0 commit comments