Skip to content

Commit 14f6f1b

Browse files
committed
Generify related streams calls and rename method
1 parent 705f6c6 commit 14f6f1b

16 files changed

Lines changed: 34 additions & 30 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampStreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public StreamType getStreamType() {
245245
}
246246

247247
@Override
248-
public StreamInfoItemsCollector getRelatedStreams() {
248+
public StreamInfoItemsCollector getRelatedItems() {
249249
return null;
250250
}
251251

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public StreamType getStreamType() throws ParsingException {
240240

241241
@Nullable
242242
@Override
243-
public StreamInfoItemsCollector getRelatedStreams() {
243+
public StreamInfoItemsCollector getRelatedItems() {
244244
return null;
245245
}
246246

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public StreamType getStreamType() {
219219

220220
@Nullable
221221
@Override
222-
public StreamInfoItemsCollector getRelatedStreams() {
222+
public StreamInfoItemsCollector getRelatedItems() {
223223
return null;
224224
}
225225

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ public StreamType getStreamType() {
263263

264264
@Nullable
265265
@Override
266-
public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException {
266+
public StreamInfoItemsCollector getRelatedItems() throws IOException, ExtractionException {
267267
final List<String> tags = getTags();
268268
final String apiUrl;
269269
if (tags.isEmpty()) {
270270
apiUrl = baseUrl + "/api/v1/accounts/" + JsonUtils.getString(json, "account.name")
271271
+ "@" + JsonUtils.getString(json, "account.host") +
272272
"/videos?start=0&count=8";
273273
} else {
274-
apiUrl = getRelatedStreamsUrl(tags);
274+
apiUrl = getRelatedItemsUrl(tags);
275275
}
276276

277277
if (Utils.isBlank(apiUrl)) {
@@ -311,7 +311,7 @@ public List<MetaInfo> getMetaInfo() {
311311
return Collections.emptyList();
312312
}
313313

314-
private String getRelatedStreamsUrl(final List<String> tags) throws UnsupportedEncodingException {
314+
private String getRelatedItemsUrl(final List<String> tags) throws UnsupportedEncodingException {
315315
final String url = baseUrl + PeertubeSearchQueryHandlerFactory.SEARCH_ENDPOINT;
316316
final StringBuilder params = new StringBuilder();
317317
params.append("start=0&count=8&sort=-createdAt");

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public StreamType getStreamType() {
353353

354354
@Nullable
355355
@Override
356-
public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException {
356+
public StreamInfoItemsCollector getRelatedItems() throws IOException, ExtractionException {
357357
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
358358

359359
final String apiUrl = "https://api-v2.soundcloud.com/tracks/" + urlEncode(getId())

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ private StreamInfoItemExtractor getNextStream() throws ExtractionException {
643643

644644
@Nullable
645645
@Override
646-
public StreamInfoItemsCollector getRelatedStreams() throws ExtractionException {
646+
public StreamInfoItemsCollector getRelatedItems() throws ExtractionException {
647647
assertPageFetched();
648648

649649
if (getAgeLimit() != NO_AGE_LIMIT) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
2121
*/
2222

23+
import org.schabi.newpipe.extractor.InfoItem;
24+
import org.schabi.newpipe.extractor.InfoItemsCollector;
25+
import org.schabi.newpipe.extractor.InfoItemExtractor;
2326
import org.schabi.newpipe.extractor.Extractor;
2427
import org.schabi.newpipe.extractor.MediaFormat;
2528
import org.schabi.newpipe.extractor.MetaInfo;
@@ -331,7 +334,8 @@ public StreamExtractor(StreamingService service, LinkHandler linkHandler) {
331334
* @throws ExtractionException
332335
*/
333336
@Nullable
334-
public abstract StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException;
337+
public abstract InfoItemsCollector<? extends InfoItem, ? extends InfoItemExtractor>
338+
getRelatedItems() throws IOException, ExtractionException;
335339

336340
/**
337341
* Should return a list of Frameset object that contains preview of stream frames

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtra
334334
streamInfo.addError(e);
335335
}
336336

337-
streamInfo.setRelatedStreams(ExtractorHelper.getRelatedVideosOrLogError(streamInfo, extractor));
337+
streamInfo.setRelatedItems(ExtractorHelper.getRelatedItemsOrLogError(streamInfo, extractor));
338338

339339
return streamInfo;
340340
}
@@ -370,7 +370,7 @@ private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtra
370370

371371

372372
private String hlsUrl = "";
373-
private List<InfoItem> relatedStreams = new ArrayList<>();
373+
private List<InfoItem> relatedItems = new ArrayList<>();
374374

375375
private long startPosition = 0;
376376
private List<SubtitlesStream> subtitles = new ArrayList<>();
@@ -602,12 +602,12 @@ public void setHlsUrl(String hlsUrl) {
602602
this.hlsUrl = hlsUrl;
603603
}
604604

605-
public List<InfoItem> getRelatedStreams() {
606-
return relatedStreams;
605+
public List<InfoItem> getRelatedItems() {
606+
return relatedItems;
607607
}
608608

609-
public void setRelatedStreams(List<InfoItem> relatedStreams) {
610-
this.relatedStreams = relatedStreams;
609+
public void setRelatedItems(List<InfoItem> relatedItems) {
610+
this.relatedItems = relatedItems;
611611
}
612612

613613
public long getStartPosition() {

extractor/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public static <T extends InfoItem> InfoItemsPage<T> getItemsPageOrLogError(Info
2727
}
2828

2929

30-
public static List<InfoItem> getRelatedVideosOrLogError(StreamInfo info, StreamExtractor extractor) {
30+
public static List<InfoItem> getRelatedItemsOrLogError(StreamInfo info, StreamExtractor extractor) {
3131
try {
32-
InfoItemsCollector<? extends InfoItem, ?> collector = extractor.getRelatedStreams();
32+
InfoItemsCollector<? extends InfoItem, ?> collector = extractor.getRelatedItems();
3333
if (collector == null) return Collections.emptyList();
3434
info.addAllErrors(collector.getErrors());
3535

extractor/src/test/java/org/schabi/newpipe/extractor/services/BaseStreamExtractorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface BaseStreamExtractorTest extends BaseExtractorTest {
1717
void testTextualUploadDate() throws Exception;
1818
void testLikeCount() throws Exception;
1919
void testDislikeCount() throws Exception;
20-
void testRelatedStreams() throws Exception;
20+
void testRelatedItems() throws Exception;
2121
void testAgeLimit() throws Exception;
2222
void testErrorMessage() throws Exception;
2323
void testAudioStreams() throws Exception;

0 commit comments

Comments
 (0)