Skip to content

Commit d56b880

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

3 files changed

Lines changed: 133 additions & 130 deletions

File tree

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

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
1-
package org.schabi.newpipe.extractor.channel;
2-
3-
import org.schabi.newpipe.extractor.Info;
4-
import org.schabi.newpipe.extractor.NewPipe;
5-
import org.schabi.newpipe.extractor.StreamingService;
6-
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
7-
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
8-
9-
import java.io.IOException;
10-
import java.util.List;
11-
12-
import javax.annotation.Nonnull;
13-
141
/*
152
* Created by Christian Schabesberger on 31.07.16.
163
*
174
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
18-
* ChannelInfo.java is part of NewPipe.
5+
* ChannelInfo.java is part of NewPipe Extractor.
196
*
20-
* NewPipe is free software: you can redistribute it and/or modify
7+
* NewPipe Extractor is free software: you can redistribute it and/or modify
218
* it under the terms of the GNU General Public License as published by
229
* the Free Software Foundation, either version 3 of the License, or
2310
* (at your option) any later version.
2411
*
25-
* NewPipe is distributed in the hope that it will be useful,
12+
* NewPipe Extractor is distributed in the hope that it will be useful,
2613
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2714
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2815
* GNU General Public License for more details.
2916
*
3017
* You should have received a copy of the GNU General Public License
31-
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
18+
* along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.
3219
*/
3320

21+
package org.schabi.newpipe.extractor.channel;
22+
23+
import org.schabi.newpipe.extractor.Info;
24+
import org.schabi.newpipe.extractor.Image;
25+
import org.schabi.newpipe.extractor.NewPipe;
26+
import org.schabi.newpipe.extractor.StreamingService;
27+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
28+
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
29+
30+
import java.io.IOException;
31+
import java.util.List;
32+
33+
import javax.annotation.Nonnull;
34+
3435
public class ChannelInfo extends Info {
3536

3637
public ChannelInfo(final int serviceId,
@@ -64,13 +65,13 @@ public static ChannelInfo getInfo(final ChannelExtractor extractor)
6465
final ChannelInfo info = new ChannelInfo(serviceId, id, url, originalUrl, name);
6566

6667
try {
67-
info.setAvatarUrl(extractor.getAvatarUrl());
68+
info.setAvatars(extractor.getAvatars());
6869
} catch (final Exception e) {
6970
info.addError(e);
7071
}
7172

7273
try {
73-
info.setBannerUrl(extractor.getBannerUrl());
74+
info.setBanners(extractor.getBanners());
7475
} catch (final Exception e) {
7576
info.addError(e);
7677
}
@@ -106,7 +107,7 @@ public static ChannelInfo getInfo(final ChannelExtractor extractor)
106107
}
107108

108109
try {
109-
info.setParentChannelAvatarUrl(extractor.getParentChannelAvatarUrl());
110+
info.setParentChannelAvatars(extractor.getParentChannelAvatars());
110111
} catch (final Exception e) {
111112
info.addError(e);
112113
}
@@ -132,15 +133,18 @@ public static ChannelInfo getInfo(final ChannelExtractor extractor)
132133
return info;
133134
}
134135

135-
private String avatarUrl;
136136
private String parentChannelName;
137137
private String parentChannelUrl;
138-
private String parentChannelAvatarUrl;
139-
private String bannerUrl;
140138
private String feedUrl;
141139
private long subscriberCount = -1;
142140
private String description;
143141
private String[] donationLinks;
142+
@Nonnull
143+
private List<Image> avatars = List.of();
144+
@Nonnull
145+
private List<Image> banners = List.of();
146+
@Nonnull
147+
private List<Image> parentChannelAvatars = List.of();
144148
private boolean verified;
145149
private List<ListLinkHandler> tabs = List.of();
146150
private List<String> tags = List.of();
@@ -161,28 +165,31 @@ public void setParentChannelUrl(final String parentChannelUrl) {
161165
this.parentChannelUrl = parentChannelUrl;
162166
}
163167

164-
public String getParentChannelAvatarUrl() {
165-
return parentChannelAvatarUrl;
168+
@Nonnull
169+
public List<Image> getParentChannelAvatars() {
170+
return parentChannelAvatars;
166171
}
167172

168-
public void setParentChannelAvatarUrl(final String parentChannelAvatarUrl) {
169-
this.parentChannelAvatarUrl = parentChannelAvatarUrl;
173+
public void setParentChannelAvatars(@Nonnull final List<Image> parentChannelAvatars) {
174+
this.parentChannelAvatars = parentChannelAvatars;
170175
}
171176

172-
public String getAvatarUrl() {
173-
return avatarUrl;
177+
@Nonnull
178+
public List<Image> getAvatars() {
179+
return avatars;
174180
}
175181

176-
public void setAvatarUrl(final String avatarUrl) {
177-
this.avatarUrl = avatarUrl;
182+
public void setAvatars(@Nonnull final List<Image> avatars) {
183+
this.avatars = avatars;
178184
}
179185

180-
public String getBannerUrl() {
181-
return bannerUrl;
186+
@Nonnull
187+
public List<Image> getBanners() {
188+
return banners;
182189
}
183190

184-
public void setBannerUrl(final String bannerUrl) {
185-
this.bannerUrl = bannerUrl;
191+
public void setBanners(@Nonnull final List<Image> banners) {
192+
this.banners = banners;
186193
}
187194

188195
public String getFeedUrl() {

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

Lines changed: 37 additions & 30 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.InfoItemsPage;
45
import org.schabi.newpipe.extractor.ListInfo;
56
import org.schabi.newpipe.extractor.NewPipe;
@@ -12,6 +13,7 @@
1213
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1314
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
1415

16+
import javax.annotation.Nonnull;
1517
import java.io.IOException;
1618
import java.util.ArrayList;
1719
import java.util.List;
@@ -109,26 +111,23 @@ public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
109111
info.addError(e);
110112
}
111113
try {
112-
info.setThumbnailUrl(extractor.getThumbnailUrl());
114+
info.setThumbnails(extractor.getThumbnails());
113115
} catch (final Exception e) {
114116
info.addError(e);
115117
}
116118
try {
117119
info.setUploaderUrl(extractor.getUploaderUrl());
118120
} catch (final Exception e) {
119-
info.setUploaderUrl("");
120121
uploaderParsingErrors.add(e);
121122
}
122123
try {
123124
info.setUploaderName(extractor.getUploaderName());
124125
} catch (final Exception e) {
125-
info.setUploaderName("");
126126
uploaderParsingErrors.add(e);
127127
}
128128
try {
129-
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
129+
info.setUploaderAvatars(extractor.getUploaderAvatars());
130130
} catch (final Exception e) {
131-
info.setUploaderAvatarUrl("");
132131
uploaderParsingErrors.add(e);
133132
}
134133
try {
@@ -142,12 +141,12 @@ public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
142141
uploaderParsingErrors.add(e);
143142
}
144143
try {
145-
info.setSubChannelAvatarUrl(extractor.getSubChannelAvatarUrl());
144+
info.setSubChannelAvatars(extractor.getSubChannelAvatars());
146145
} catch (final Exception e) {
147146
uploaderParsingErrors.add(e);
148147
}
149148
try {
150-
info.setBannerUrl(extractor.getBannerUrl());
149+
info.setBanners(extractor.getBanners());
151150
} catch (final Exception e) {
152151
info.addError(e);
153152
}
@@ -171,32 +170,38 @@ public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
171170
return info;
172171
}
173172

174-
private String thumbnailUrl;
175-
private String bannerUrl;
176-
private String uploaderUrl;
177-
private String uploaderName;
178-
private String uploaderAvatarUrl;
173+
private String uploaderUrl = "";
174+
private String uploaderName = "";
179175
private String subChannelUrl;
180176
private String subChannelName;
181-
private String subChannelAvatarUrl;
182-
private long streamCount = 0;
183177
private Description description;
178+
@Nonnull
179+
private List<Image> banners = List.of();
180+
@Nonnull
181+
private List<Image> subChannelAvatars = List.of();
182+
@Nonnull
183+
private List<Image> thumbnails = List.of();
184+
@Nonnull
185+
private List<Image> uploaderAvatars = List.of();
186+
private long streamCount;
184187
private PlaylistType playlistType;
185188

186-
public String getThumbnailUrl() {
187-
return thumbnailUrl;
189+
@Nonnull
190+
public List<Image> getThumbnails() {
191+
return thumbnails;
188192
}
189193

190-
public void setThumbnailUrl(final String thumbnailUrl) {
191-
this.thumbnailUrl = thumbnailUrl;
194+
public void setThumbnails(@Nonnull final List<Image> thumbnails) {
195+
this.thumbnails = thumbnails;
192196
}
193197

194-
public String getBannerUrl() {
195-
return bannerUrl;
198+
@Nonnull
199+
public List<Image> getBanners() {
200+
return banners;
196201
}
197202

198-
public void setBannerUrl(final String bannerUrl) {
199-
this.bannerUrl = bannerUrl;
203+
public void setBanners(@Nonnull final List<Image> banners) {
204+
this.banners = banners;
200205
}
201206

202207
public String getUploaderUrl() {
@@ -215,12 +220,13 @@ public void setUploaderName(final String uploaderName) {
215220
this.uploaderName = uploaderName;
216221
}
217222

218-
public String getUploaderAvatarUrl() {
219-
return uploaderAvatarUrl;
223+
@Nonnull
224+
public List<Image> getUploaderAvatars() {
225+
return uploaderAvatars;
220226
}
221227

222-
public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
223-
this.uploaderAvatarUrl = uploaderAvatarUrl;
228+
public void setUploaderAvatars(@Nonnull final List<Image> uploaderAvatars) {
229+
this.uploaderAvatars = uploaderAvatars;
224230
}
225231

226232
public String getSubChannelUrl() {
@@ -239,12 +245,13 @@ public void setSubChannelName(final String subChannelName) {
239245
this.subChannelName = subChannelName;
240246
}
241247

242-
public String getSubChannelAvatarUrl() {
243-
return subChannelAvatarUrl;
248+
@Nonnull
249+
public List<Image> getSubChannelAvatars() {
250+
return subChannelAvatars;
244251
}
245252

246-
public void setSubChannelAvatarUrl(final String subChannelAvatarUrl) {
247-
this.subChannelAvatarUrl = subChannelAvatarUrl;
253+
public void setSubChannelAvatars(@Nonnull final List<Image> subChannelAvatars) {
254+
this.subChannelAvatars = subChannelAvatars;
248255
}
249256

250257
public long getStreamCount() {

0 commit comments

Comments
 (0)