Skip to content

Commit ca1d4a6

Browse files
committed
Replace avatar and thumbnail URLs attributes and methods to List<Image> in InfoItemExtractors
1 parent 2f3ee8a commit ca1d4a6

3 files changed

Lines changed: 41 additions & 28 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import org.schabi.newpipe.extractor.exceptions.ParsingException;
44

5+
import javax.annotation.Nonnull;
6+
import java.util.List;
7+
58
public interface InfoItemExtractor {
69
String getName() throws ParsingException;
710
String getUrl() throws ParsingException;
8-
String getThumbnailUrl() throws ParsingException;
11+
@Nonnull
12+
List<Image> getThumbnails() throws ParsingException;
913
}

extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.extractor.comments;
22

3+
import org.schabi.newpipe.extractor.Image;
34
import org.schabi.newpipe.extractor.InfoItemExtractor;
45
import org.schabi.newpipe.extractor.Page;
56
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -8,7 +9,9 @@
89
import org.schabi.newpipe.extractor.stream.Description;
910
import org.schabi.newpipe.extractor.stream.StreamExtractor;
1011

12+
import javax.annotation.Nonnull;
1113
import javax.annotation.Nullable;
14+
import java.util.List;
1215

1316
public interface CommentsInfoItemExtractor extends InfoItemExtractor {
1417

@@ -77,8 +80,9 @@ default String getUploaderName() throws ParsingException {
7780
return "";
7881
}
7982

80-
default String getUploaderAvatarUrl() throws ParsingException {
81-
return "";
83+
@Nonnull
84+
default List<Image> getUploaderAvatars() throws ParsingException {
85+
return List.of();
8286
}
8387

8488
/**

extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,95 @@
1-
package org.schabi.newpipe.extractor.stream;
2-
3-
import org.schabi.newpipe.extractor.InfoItemExtractor;
4-
import org.schabi.newpipe.extractor.exceptions.ParsingException;
5-
import org.schabi.newpipe.extractor.localization.DateWrapper;
6-
7-
import javax.annotation.Nullable;
8-
91
/*
102
* Created by Christian Schabesberger on 28.02.16.
113
*
124
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
13-
* StreamInfoItemExtractor.java is part of NewPipe.
5+
* StreamInfoItemExtractor.java is part of NewPipe Extractor.
146
*
15-
* NewPipe is free software: you can redistribute it and/or modify
7+
* NewPipe Extractor is free software: you can redistribute it and/or modify
168
* it under the terms of the GNU General Public License as published by
179
* the Free Software Foundation, either version 3 of the License, or
1810
* (at your option) any later version.
1911
*
20-
* NewPipe is distributed in the hope that it will be useful,
12+
* NewPipe Extractor is distributed in the hope that it will be useful,
2113
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2214
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2315
* GNU General Public License for more details.
2416
*
2517
* You should have received a copy of the GNU General Public License
26-
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
18+
* along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.
2719
*/
2820

29-
public interface StreamInfoItemExtractor extends InfoItemExtractor {
21+
package org.schabi.newpipe.extractor.stream;
3022

23+
import org.schabi.newpipe.extractor.Image;
24+
import org.schabi.newpipe.extractor.InfoItemExtractor;
25+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
26+
import org.schabi.newpipe.extractor.localization.DateWrapper;
27+
28+
import javax.annotation.Nonnull;
29+
import javax.annotation.Nullable;
30+
import java.util.List;
31+
32+
public interface StreamInfoItemExtractor extends InfoItemExtractor {
3133

3234
/**
3335
* Get the stream type
3436
*
3537
* @return the stream type
36-
* @throws ParsingException thrown if there is an error in the extraction
38+
* @throws ParsingException if there is an error in the extraction
3739
*/
3840
StreamType getStreamType() throws ParsingException;
3941

4042
/**
4143
* Check if the stream is an ad.
4244
*
4345
* @return {@code true} if the stream is an ad.
44-
* @throws ParsingException thrown if there is an error in the extraction
46+
* @throws ParsingException if there is an error in the extraction
4547
*/
4648
boolean isAd() throws ParsingException;
4749

4850
/**
4951
* Get the stream duration in seconds
5052
*
5153
* @return the stream duration in seconds
52-
* @throws ParsingException thrown if there is an error in the extraction
54+
* @throws ParsingException if there is an error in the extraction
5355
*/
5456
long getDuration() throws ParsingException;
5557

5658
/**
5759
* Parses the number of views
5860
*
5961
* @return the number of views or -1 for live streams
60-
* @throws ParsingException thrown if there is an error in the extraction
62+
* @throws ParsingException if there is an error in the extraction
6163
*/
6264
long getViewCount() throws ParsingException;
6365

6466
/**
6567
* Get the uploader name
6668
*
6769
* @return the uploader name
68-
* @throws ParsingException if parsing fails
70+
* @throws ParsingException if there is an error in the extraction
6971
*/
7072
String getUploaderName() throws ParsingException;
7173

7274
String getUploaderUrl() throws ParsingException;
7375

7476
/**
75-
* Get the uploader's avatar
77+
* Get the uploader avatars.
7678
*
77-
* @return The uploader's avatar url or {@code null} if not provided by the service.
79+
* @return the uploader avatars or an empty list if not provided by the service
7880
* @throws ParsingException if there is an error in the extraction
7981
*/
80-
@Nullable
81-
String getUploaderAvatarUrl() throws ParsingException;
82+
@Nonnull
83+
default List<Image> getUploaderAvatars() throws ParsingException {
84+
return List.of();
85+
}
8286

8387
/**
8488
* Whether the uploader has been verified by the service's provider.
8589
* If there is no verification implemented, return <code>false</code>.
8690
*
8791
* @return whether the uploader has been verified by the service's provider
88-
* @throws ParsingException
92+
* @throws ParsingException if there is an error in the extraction
8993
*/
9094
boolean isUploaderVerified() throws ParsingException;
9195

@@ -109,8 +113,8 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor {
109113
* </p>
110114
*
111115
* @return The date and time (can be approximated) this item was uploaded or {@code null}.
112-
* @throws ParsingException if there is an error in the extraction
113-
* or the extracted date couldn't be parsed.
116+
* @throws ParsingException if there is an error in the extraction or the extracted date
117+
* couldn't be parsed
114118
* @see #getTextualUploadDate()
115119
*/
116120
@Nullable
@@ -137,6 +141,7 @@ default String getShortDescription() throws ParsingException {
137141
* </p>
138142
*
139143
* @return whether the stream is a short-form content
144+
* @throws ParsingException if there is an error in the extraction
140145
*/
141146
default boolean isShortFormContent() throws ParsingException {
142147
return false;

0 commit comments

Comments
 (0)