Skip to content

Commit 9d80985

Browse files
committed
Replace avatar and thumbnail URLs attributes and methods to List<Image> in Extractors
1 parent 0f4a5a8 commit 9d80985

3 files changed

Lines changed: 66 additions & 46 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
package org.schabi.newpipe.extractor.channel;
2-
3-
import org.schabi.newpipe.extractor.Extractor;
4-
import org.schabi.newpipe.extractor.StreamingService;
5-
import org.schabi.newpipe.extractor.exceptions.ParsingException;
6-
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
7-
8-
import javax.annotation.Nonnull;
9-
import java.util.List;
10-
111
/*
122
* Created by Christian Schabesberger on 25.07.16.
133
*
144
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
15-
* ChannelExtractor.java is part of NewPipe.
5+
* ChannelExtractor.java is part of NewPipe Extractor.
166
*
17-
* NewPipe is free software: you can redistribute it and/or modify
7+
* NewPipe Extractor is free software: you can redistribute it and/or modify
188
* it under the terms of the GNU General Public License as published by
199
* the Free Software Foundation, either version 3 of the License, or
2010
* (at your option) any later version.
2111
*
22-
* NewPipe is distributed in the hope that it will be useful,
12+
* NewPipe Extractor is distributed in the hope that it will be useful,
2313
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2414
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2515
* GNU General Public License for more details.
2616
*
2717
* You should have received a copy of the GNU General Public License
28-
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
18+
* along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.
2919
*/
3020

21+
package org.schabi.newpipe.extractor.channel;
22+
23+
import org.schabi.newpipe.extractor.Extractor;
24+
import org.schabi.newpipe.extractor.Image;
25+
import org.schabi.newpipe.extractor.StreamingService;
26+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
27+
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
28+
29+
import javax.annotation.Nonnull;
30+
import java.util.List;
31+
3132
public abstract class ChannelExtractor extends Extractor {
3233

3334
public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;
@@ -36,14 +37,17 @@ protected ChannelExtractor(final StreamingService service, final ListLinkHandler
3637
super(service, linkHandler);
3738
}
3839

39-
public abstract String getAvatarUrl() throws ParsingException;
40-
public abstract String getBannerUrl() throws ParsingException;
40+
@Nonnull
41+
public abstract List<Image> getAvatars() throws ParsingException;
42+
@Nonnull
43+
public abstract List<Image> getBanners() throws ParsingException;
4144
public abstract String getFeedUrl() throws ParsingException;
4245
public abstract long getSubscriberCount() throws ParsingException;
4346
public abstract String getDescription() throws ParsingException;
4447
public abstract String getParentChannelName() throws ParsingException;
4548
public abstract String getParentChannelUrl() throws ParsingException;
46-
public abstract String getParentChannelAvatarUrl() throws ParsingException;
49+
@Nonnull
50+
public abstract List<Image> getParentChannelAvatars() throws ParsingException;
4751
public abstract boolean isVerified() throws ParsingException;
4852
@Nonnull
4953
public abstract List<ListLinkHandler> getTabs() throws ParsingException;

extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java

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

3+
import org.schabi.newpipe.extractor.Image;
34
import org.schabi.newpipe.extractor.ListExtractor;
45
import org.schabi.newpipe.extractor.StreamingService;
56
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -9,6 +10,9 @@
910

1011
import javax.annotation.Nonnull;
1112

13+
import java.util.Collections;
14+
import java.util.List;
15+
1216
public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
1317

1418
public PlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
@@ -17,7 +21,8 @@ public PlaylistExtractor(final StreamingService service, final ListLinkHandler l
1721

1822
public abstract String getUploaderUrl() throws ParsingException;
1923
public abstract String getUploaderName() throws ParsingException;
20-
public abstract String getUploaderAvatarUrl() throws ParsingException;
24+
@Nonnull
25+
public abstract List<Image> getUploaderAvatars() throws ParsingException;
2126
public abstract boolean isUploaderVerified() throws ParsingException;
2227

2328
public abstract long getStreamCount() throws ParsingException;
@@ -26,15 +31,13 @@ public PlaylistExtractor(final StreamingService service, final ListLinkHandler l
2631
public abstract Description getDescription() throws ParsingException;
2732

2833
@Nonnull
29-
public String getThumbnailUrl() throws ParsingException {
30-
return "";
34+
public List<Image> getThumbnails() throws ParsingException {
35+
return Collections.emptyList();
3136
}
3237

3338
@Nonnull
34-
public String getBannerUrl() throws ParsingException {
35-
// Banner can't be handled by frontend right now.
36-
// Whoever is willing to implement this should also implement it in the frontend.
37-
return "";
39+
public List<Image> getBanners() throws ParsingException {
40+
return List.of();
3841
}
3942

4043
@Nonnull
@@ -48,8 +51,8 @@ public String getSubChannelUrl() throws ParsingException {
4851
}
4952

5053
@Nonnull
51-
public String getSubChannelAvatarUrl() throws ParsingException {
52-
return "";
54+
public List<Image> getSubChannelAvatars() throws ParsingException {
55+
return List.of();
5356
}
5457

5558
public PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {

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

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
package org.schabi.newpipe.extractor.stream;
2-
31
/*
42
* Created by Christian Schabesberger on 10.08.18.
53
*
64
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
7-
* StreamExtractor.java is part of NewPipe.
5+
* StreamExtractor.java is part of NewPipe Extractor.
86
*
9-
* NewPipe is free software: you can redistribute it and/or modify
7+
* NewPipe Extractor is free software: you can redistribute it and/or modify
108
* it under the terms of the GNU General Public License as published by
119
* the Free Software Foundation, either version 3 of the License, or
1210
* (at your option) any later version.
1311
*
14-
* NewPipe is distributed in the hope that it will be useful,
12+
* NewPipe Extractor is distributed in the hope that it will be useful,
1513
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1614
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1715
* GNU General Public License for more details.
1816
*
1917
* You should have received a copy of the GNU General Public License
20-
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
18+
* along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.
2119
*/
2220

21+
package org.schabi.newpipe.extractor.stream;
22+
23+
import org.schabi.newpipe.extractor.Image;
2324
import org.schabi.newpipe.extractor.InfoItem;
2425
import org.schabi.newpipe.extractor.InfoItemsCollector;
2526
import org.schabi.newpipe.extractor.InfoItemExtractor;
@@ -87,13 +88,12 @@ public DateWrapper getUploadDate() throws ParsingException {
8788
}
8889

8990
/**
90-
* This will return the url to the thumbnail of the stream. Try to return the medium resolution
91-
* here.
91+
* This will return the thumbnails of the stream.
9292
*
93-
* @return The url of the thumbnail.
93+
* @return the thumbnails of the stream
9494
*/
9595
@Nonnull
96-
public abstract String getThumbnailUrl() throws ParsingException;
96+
public abstract List<Image> getThumbnails() throws ParsingException;
9797

9898
/**
9999
* This is the stream description.
@@ -208,14 +208,18 @@ public long getUploaderSubscriberCount() throws ParsingException {
208208
}
209209

210210
/**
211-
* The url to the image file/profile picture/avatar of the creator/uploader of the stream.
212-
* If the url is not available you can return an empty String.
211+
* The image files/profile pictures/avatars of the creator/uploader of the stream.
213212
*
214-
* @return The url of the image file of the uploader or an empty String
213+
* <p>
214+
* If they are not available in the stream on specific cases, you must return an empty list for
215+
* these ones, like it is made by default.
216+
* </p>
217+
*
218+
* @return the avatars of the sub-channel of the stream or an empty list (default)
215219
*/
216220
@Nonnull
217-
public String getUploaderAvatarUrl() throws ParsingException {
218-
return "";
221+
public List<Image> getUploaderAvatars() throws ParsingException {
222+
return List.of();
219223
}
220224

221225
/**
@@ -243,14 +247,23 @@ public String getSubChannelName() throws ParsingException {
243247
}
244248

245249
/**
246-
* The url to the image file/profile picture/avatar of the sub-channel of the stream.
247-
* If the url is not available you can return an empty String.
250+
* The avatars of the sub-channel of the stream.
248251
*
249-
* @return The url of the image file of the sub-channel or an empty String
252+
* <p>
253+
* If they are not available in the stream on specific cases, you must return an empty list for
254+
* these ones, like it is made by default.
255+
* </p>
256+
*
257+
* <p>
258+
* If the concept of sub-channels doesn't apply to the stream's service, keep the default
259+
* implementation.
260+
* </p>
261+
*
262+
* @return the avatars of the sub-channel of the stream or an empty list (default)
250263
*/
251264
@Nonnull
252-
public String getSubChannelAvatarUrl() throws ParsingException {
253-
return "";
265+
public List<Image> getSubChannelAvatars() throws ParsingException {
266+
return List.of();
254267
}
255268

256269
/**

0 commit comments

Comments
 (0)