2222
2323import org .schabi .newpipe .extractor .Extractor ;
2424import org .schabi .newpipe .extractor .StreamingService ;
25- import org .schabi .newpipe .extractor .Subtitles ;
2625import org .schabi .newpipe .extractor .exceptions .ExtractionException ;
2726import org .schabi .newpipe .extractor .exceptions .ParsingException ;
2827import org .schabi .newpipe .extractor .linkhandler .LinkHandler ;
3433import java .util .List ;
3534
3635/**
37- * Scrapes information from a video streaming service (eg, YouTube).
36+ * Scrapes information from a video/audio streaming service (eg, YouTube).
3837 */
3938public abstract class StreamExtractor extends Extractor {
4039
@@ -44,22 +43,234 @@ public StreamExtractor(StreamingService service, LinkHandler linkHandler, Locali
4443 super (service , linkHandler , localization );
4544 }
4645
46+ /**
47+ * The day on which the stream got uploaded/created. The return information should be in the format
48+ * dd.mm.yyyy, however it NewPipe will not crash if its not.
49+ * @return The day on which the stream got uploaded.
50+ * @throws ParsingException
51+ */
4752 @ Nonnull
4853 public abstract String getUploadDate () throws ParsingException ;
54+
55+ /**
56+ * This will return the url to the thumbnail of the stream. Try to return the medium resolution here.
57+ * @return The url of the thumbnail.
58+ * @throws ParsingException
59+ */
4960 @ Nonnull
5061 public abstract String getThumbnailUrl () throws ParsingException ;
62+
63+ /**
64+ * This is the stream description. On YouTube this is the video description. You can return simple HTML here.
65+ * @return The description of the stream/video.
66+ * @throws ParsingException
67+ */
5168 @ Nonnull
5269 public abstract String getDescription () throws ParsingException ;
5370
5471 /**
55- * Get the age limit
72+ * Get the age limit.
5673 * @return The age which limits the content or {@value NO_AGE_LIMIT} if there is no limit
5774 * @throws ParsingException if an error occurs while parsing
5875 */
5976 public abstract int getAgeLimit () throws ParsingException ;
6077
78+ /**
79+ * This should return the length of a video in seconds.
80+ * @return The length of the stream in seconds.
81+ * @throws ParsingException
82+ */
6183 public abstract long getLength () throws ParsingException ;
84+
85+ /**
86+ * If the url you are currently handling contains a time stamp/seek, you can return the
87+ * position it represents here.
88+ * If the url has no time stamp simply return zero.
89+ * @return the timestamp in seconds
90+ * @throws ParsingException
91+ */
6292 public abstract long getTimeStamp () throws ParsingException ;
93+
94+ /**
95+ * The count of how many people have watched the video/listened to the audio stream.
96+ * If the current stream has no view count or its not available simply return -1
97+ * @return amount of views.
98+ * @throws ParsingException
99+ */
100+ public abstract long getViewCount () throws ParsingException ;
101+
102+ /**
103+ * The Amount of likes a video/audio stream got.
104+ * If the current stream has no likes or its not available simply return -1
105+ * @return the amount of likes the stream got
106+ * @throws ParsingException
107+ */
108+ public abstract long getLikeCount () throws ParsingException ;
109+
110+ /**
111+ * The Amount of dislikes a video/audio stream got.
112+ * If the current stream has no dislikes or its not available simply return -1
113+ * @return the amount of likes the stream got
114+ * @throws ParsingException
115+ */
116+ public abstract long getDislikeCount () throws ParsingException ;
117+
118+ /**
119+ * The Url to the page of the creator/uploader of the stream. This must not be a homepage,
120+ * but the page offered by the service the extractor handles. This url will be handled by the
121+ * <a href="https://teamnewpipe.github.io/documentation/03_Implement_a_service/#channel">ChannelExtractor</a>,
122+ * so be sure to implement that one before you return a value here, otherwise NewPipe will crash if one selects
123+ * this url.
124+ * @return the url to the page of the creator/uploader of the stream or an empty String
125+ * @throws ParsingException
126+ */
127+ @ Nonnull
128+ public abstract String getUploaderUrl () throws ParsingException ;
129+
130+ /**
131+ * The name of the creator/uploader of the stream.
132+ * If the name is not available you can simply return an empty string.
133+ * @return the name of the creator/uploader of the stream or an empty String
134+ * @throws ParsingException
135+ */
136+ @ Nonnull
137+ public abstract String getUploaderName () throws ParsingException ;
138+
139+ /**
140+ * The url to the image file/profile picture/avatar of the creator/uploader of the stream.
141+ * If the url is not available you can return an empty String.
142+ * @return The url of the image file of the uploader or an empty String
143+ * @throws ParsingException
144+ */
145+ @ Nonnull
146+ public abstract String getUploaderAvatarUrl () throws ParsingException ;
147+
148+ /**
149+ * Get the dash mpd url. If you don't know what a dash MPD is you can read about it
150+ * <a href="https://www.brendanlong.com/the-structure-of-an-mpeg-dash-mpd.html">here</a>.
151+ * @return the url as a string or an empty string
152+ * @throws ParsingException if an error occurs while reading
153+ */
154+ @ Nonnull public abstract String getDashMpdUrl () throws ParsingException ;
155+
156+ /**
157+ * I am not sure if this is in use, and how this is used. However the frontend is missing support
158+ * for HLS streams. Prove me if I am wrong. Please open an
159+ * <a href="https://github.com/teamnewpipe/newpipe/issues">issue</a>,
160+ * or fix this description if you know whats up with this.
161+ * @return The Url to the hls stream.
162+ * @throws ParsingException
163+ */
164+ @ Nonnull public abstract String getHlsUrl () throws ParsingException ;
165+
166+ /**
167+ * This should return a list of available
168+ * <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/AudioStream.html">AudioStream</a>s
169+ * You can also return null or an empty list, however be aware that if you don't return anything
170+ * in getVideoStreams(), getVideoOnlyStreams() and getDashMpdUrl() either the Collector will handle this as
171+ * a failed extraction procedure.
172+ * @return a list of audio only streams in the format of AudioStream
173+ * @throws IOException
174+ * @throws ExtractionException
175+ */
176+ public abstract List <AudioStream > getAudioStreams () throws IOException , ExtractionException ;
177+
178+ /**
179+ * This should return a list of available
180+ * <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/VideoStream.html">VideoStream</a>s
181+ * Be aware this is the list of video streams which do contain an audio stream.
182+ * You can also return null or an empty list, however be aware that if you don't return anything
183+ * in getAudioStreams(), getVideoOnlyStreams() and getDashMpdUrl() either the Collector will handle this as
184+ * a failed extraction procedure.
185+ * @return a list of combined video and streams in the format of AudioStream
186+ * @throws IOException
187+ * @throws ExtractionException
188+ */
189+ public abstract List <VideoStream > getVideoStreams () throws IOException , ExtractionException ;
190+
191+ /**
192+ * This should return a list of available
193+ * <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/VideoStream.html">VideoStream</a>s.
194+ * Be aware this is the list of video streams which do NOT contain an audio stream.
195+ * You can also return null or an empty list, however be aware that if you don't return anything
196+ * in getAudioStreams(), getVideoStreams() and getDashMpdUrl() either the Collector will handle this as
197+ * a failed extraction procedure.
198+ * @return a list of video and streams in the format of AudioStream
199+ * @throws IOException
200+ * @throws ExtractionException
201+ */
202+ public abstract List <VideoStream > getVideoOnlyStreams () throws IOException , ExtractionException ;
203+
204+ /**
205+ * This will return a list of available
206+ * <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/Subtitles.html">Subtitles</a>s.
207+ * If no subtitles are available an empty list can returned.
208+ * @return a list of available subtitles or an empty list
209+ * @throws IOException
210+ * @throws ExtractionException
211+ */
212+ @ Nonnull
213+ public abstract List <Subtitles > getSubtitlesDefault () throws IOException , ExtractionException ;
214+
215+ /**
216+ * This will return a list of available
217+ * <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/Subtitles.html">Subtitles</a>s.
218+ * given by a specific type.
219+ * If no subtitles in that specific format are available an empty list can returned.
220+ * @return a list of available subtitles or an empty list
221+ * @throws IOException
222+ * @throws ExtractionException
223+ */
224+ @ Nonnull
225+ public abstract List <Subtitles > getSubtitles (SubtitlesFormat format ) throws IOException , ExtractionException ;
226+
227+ /**
228+ * Get the <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/">StreamType</a>.
229+ * @return the type of the stream
230+ * @throws ParsingException
231+ */
232+ public abstract StreamType getStreamType () throws ParsingException ;
233+
234+ /**
235+ * should return the url of the next stream. NewPipe will automatically play
236+ * the next stream if the user wants that.
237+ * If the next stream is is not available simply return null
238+ * @return the InfoItem of the next stream
239+ * @throws IOException
240+ * @throws ExtractionException
241+ */
242+ public abstract StreamInfoItem getNextStream () throws IOException , ExtractionException ;
243+
244+ /**
245+ * Should return a list of streams related to the current handled. Many services show suggested
246+ * streams. If you don't like suggested streams you should implement them anyway since they can
247+ * be disabled by the user later in the frontend.
248+ * This list MUST NOT contain the next available video as this should be return through getNextStream()
249+ * If is is not available simply return null
250+ * @return a list of InfoItems showing the related videos/streams
251+ * @throws IOException
252+ * @throws ExtractionException
253+ */
254+ public abstract StreamInfoItemsCollector getRelatedStreams () throws IOException , ExtractionException ;
255+
256+ /**
257+ * Should analyse the webpage's document and extracts any error message there might be. (e.g. GEMA block)
258+ *
259+ * @return Error message; null if there is no error message.
260+ */
261+ public abstract String getErrorMessage ();
262+
263+ //////////////////////////////////////////////////////////////////
264+ /// Helper
265+ //////////////////////////////////////////////////////////////////
266+
267+ /**
268+ * Override this function if the format of time stamp in the url is not the same format as that form youtube.
269+ * Honestly I don't even know the time stamp fromat of youtube.
270+ * @param regexPattern
271+ * @return the sime stamp/seek for the video in seconds
272+ * @throws ParsingException
273+ */
63274 protected long getTimestampSeconds (String regexPattern ) throws ParsingException {
64275 String timeStamp ;
65276 try {
@@ -104,42 +315,4 @@ protected long getTimestampSeconds(String regexPattern) throws ParsingException
104315 } else {
105316 return 0 ;
106317 }};
107-
108- public abstract long getViewCount () throws ParsingException ;
109- public abstract long getLikeCount () throws ParsingException ;
110- public abstract long getDislikeCount () throws ParsingException ;
111-
112- @ Nonnull
113- public abstract String getUploaderUrl () throws ParsingException ;
114- @ Nonnull
115- public abstract String getUploaderName () throws ParsingException ;
116- @ Nonnull
117- public abstract String getUploaderAvatarUrl () throws ParsingException ;
118-
119- /**
120- * Get the dash mpd url
121- * @return the url as a string or an empty string
122- * @throws ParsingException if an error occurs while reading
123- */
124- @ Nonnull public abstract String getDashMpdUrl () throws ParsingException ;
125- @ Nonnull public abstract String getHlsUrl () throws ParsingException ;
126- public abstract List <AudioStream > getAudioStreams () throws IOException , ExtractionException ;
127- public abstract List <VideoStream > getVideoStreams () throws IOException , ExtractionException ;
128- public abstract List <VideoStream > getVideoOnlyStreams () throws IOException , ExtractionException ;
129-
130- @ Nonnull
131- public abstract List <Subtitles > getSubtitlesDefault () throws IOException , ExtractionException ;
132- @ Nonnull
133- public abstract List <Subtitles > getSubtitles (SubtitlesFormat format ) throws IOException , ExtractionException ;
134-
135- public abstract StreamType getStreamType () throws ParsingException ;
136- public abstract StreamInfoItem getNextVideo () throws IOException , ExtractionException ;
137- public abstract StreamInfoItemsCollector getRelatedVideos () throws IOException , ExtractionException ;
138-
139- /**
140- * Analyses the webpage's document and extracts any error message there might be.
141- *
142- * @return Error message; null if there is no error message.
143- */
144- public abstract String getErrorMessage ();
145318}
0 commit comments