Skip to content

Commit 89a0923

Browse files
litetexTobiGr
andcommitted
Improved code style
From review: * Fix format * Use ``extractorUrl`` name * YoutubeStreamLinkHandlerFactoryTest setup with no downloader Co-Authored-By: Tobi <TobiGr@users.noreply.github.com>
1 parent b46169b commit 89a0923

5 files changed

Lines changed: 35 additions & 33 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected T extractor() {
2121
try {
2222
initExtractor();
2323
} catch (final Exception ex) {
24-
if(ex instanceof RuntimeException) {
24+
if (ex instanceof RuntimeException) {
2525
throw (RuntimeException)ex;
2626
}
2727
throw new RuntimeException("Failed to init extractor", ex);

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,16 @@ abstract static class Base extends DefaultSimpleExtractorTest<YoutubeChannelExtr
140140

141141
@Override
142142
protected YoutubeChannelExtractor createExtractor() throws Exception {
143-
return (YoutubeChannelExtractor) YouTube.getChannelExtractor(urlForExtractor());
143+
return (YoutubeChannelExtractor) YouTube.getChannelExtractor(extractorUrl());
144144
}
145145

146-
protected abstract String urlForExtractor();
146+
protected abstract String extractorUrl();
147147
}
148148

149149
public static class Gronkh extends Base {
150150

151151
@Override
152-
protected String urlForExtractor() {
152+
protected String extractorUrl() {
153153
return "http://www.youtube.com/@Gronkh";
154154
}
155155

@@ -238,7 +238,7 @@ public void testTags() throws Exception {
238238
// YouTube RED/Premium ad blocking test
239239
public static class VSauce extends Base {
240240
@Override
241-
protected String urlForExtractor() {
241+
protected String extractorUrl() {
242242
return "https://www.youtube.com/user/Vsauce";
243243
}
244244

@@ -328,7 +328,7 @@ public void testTags() throws Exception {
328328

329329
public static class Kurzgesagt extends Base {
330330
@Override
331-
protected String urlForExtractor() {
331+
protected String extractorUrl() {
332332
return "https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q";
333333
}
334334

@@ -454,7 +454,7 @@ void testGetPageInNewExtractor() throws Exception {
454454

455455
public static class CaptainDisillusion extends Base {
456456
@Override
457-
protected String urlForExtractor() {
457+
protected String extractorUrl() {
458458
return "https://www.youtube.com/user/CaptainDisillusion/videos";
459459
}
460460

@@ -544,7 +544,7 @@ public void testTags() throws Exception {
544544

545545
public static class RandomChannel extends Base {
546546
@Override
547-
protected String urlForExtractor() {
547+
protected String extractorUrl() {
548548
return "https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w";
549549
}
550550

@@ -633,7 +633,7 @@ public void testTags() throws Exception {
633633
public static class CarouselHeader extends Base {
634634

635635
@Override
636-
protected String urlForExtractor() {
636+
protected String extractorUrl() {
637637
return "https://www.youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw";
638638
}
639639

@@ -730,7 +730,7 @@ public void testTags() throws Exception {
730730
static class AgeRestrictedChannel extends Base {
731731

732732
@Override
733-
protected String urlForExtractor() {
733+
protected String extractorUrl() {
734734
return "https://www.youtube.com/channel/UCbfnHqxXs_K3kvaH-WlNlig";
735735
}
736736

@@ -838,7 +838,7 @@ public void testTags() throws Exception {
838838
static class InteractiveTabbedHeader extends Base {
839839

840840
@Override
841-
protected String urlForExtractor() {
841+
protected String extractorUrl() {
842842
return "https://www.youtube.com/channel/UCQvWX73GQygcwXOTSf_VDVg";
843843
}
844844

@@ -934,7 +934,7 @@ public void testOriginalUrl() throws Exception {
934934
static class ChannelWithPronouns extends Base {
935935

936936
@Override
937-
protected String urlForExtractor() {
937+
protected String extractorUrl() {
938938
return "https://www.youtube.com/@ShempOfficial";
939939
}
940940

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ abstract static class Base extends DefaultSimpleExtractorTest<YoutubeCommentsExt
3333

3434
@Override
3535
protected YoutubeCommentsExtractor createExtractor() throws Exception {
36-
return (YoutubeCommentsExtractor) YouTube.getCommentsExtractor(urlForExtractor());
36+
return (YoutubeCommentsExtractor) YouTube.getCommentsExtractor(extractorUrl());
3737
}
3838

39-
protected abstract String urlForExtractor();
39+
protected abstract String extractorUrl();
4040
}
4141

4242
/**
@@ -47,7 +47,7 @@ public static class Thomas extends Base {
4747
private static final String commentContent = "Category: Education";
4848

4949
@Override
50-
protected String urlForExtractor() {
50+
protected String extractorUrl() {
5151
return URL;
5252
}
5353

@@ -131,7 +131,7 @@ public static class EmptyComment extends Base {
131131
private final static String URL = "https://www.youtube.com/watch?v=VM_6n762j6M";
132132

133133
@Override
134-
protected String urlForExtractor() {
134+
protected String extractorUrl() {
135135
return URL;
136136
}
137137

@@ -165,7 +165,7 @@ public static class HeartedByCreator extends Base {
165165
private final static String URL = "https://www.youtube.com/watch?v=tR11b7uh17Y";
166166

167167
@Override
168-
protected String urlForExtractor() {
168+
protected String extractorUrl() {
169169
return URL;
170170
}
171171

@@ -202,7 +202,7 @@ public static class Pinned extends Base {
202202
private final static String URL = "https://www.youtube.com/watch?v=bjFtFMilb34";
203203

204204
@Override
205-
protected String urlForExtractor() {
205+
protected String extractorUrl() {
206206
return URL;
207207
}
208208

@@ -238,7 +238,7 @@ public static class LikesVotes extends Base {
238238
private final static String URL = "https://www.youtube.com/watch?v=QqsLTNkzvaY";
239239

240240
@Override
241-
protected String urlForExtractor() {
241+
protected String extractorUrl() {
242242
return URL;
243243
}
244244

@@ -264,7 +264,7 @@ public static class LocalizedVoteCount extends Base {
264264
private final static String URL = "https://www.youtube.com/watch?v=QqsLTNkzvaY";
265265

266266
@Override
267-
protected String urlForExtractor() {
267+
protected String extractorUrl() {
268268
return URL;
269269
}
270270

@@ -292,7 +292,7 @@ public static class RepliesTest extends Base {
292292
private final static String URL = "https://www.youtube.com/watch?v=xaQJbozY_Is";
293293

294294
@Override
295-
protected String urlForExtractor() {
295+
protected String extractorUrl() {
296296
return URL;
297297
}
298298

@@ -334,7 +334,7 @@ public static class ChannelOwnerTest extends Base {
334334
private final static String URL = "https://www.youtube.com/watch?v=bem4adjGKjE";
335335

336336
@Override
337-
protected String urlForExtractor() {
337+
protected String extractorUrl() {
338338
return URL;
339339
}
340340

@@ -372,7 +372,7 @@ public static class CreatorReply extends Base {
372372
private final static String URL = "https://www.youtube.com/watch?v=bem4adjGKjE";
373373

374374
@Override
375-
protected String urlForExtractor() {
375+
protected String extractorUrl() {
376376
return URL;
377377
}
378378

@@ -411,7 +411,7 @@ public static class Formatting extends Base {
411411
private final static String URL = "https://www.youtube.com/watch?v=zYpyS2HaZHM";
412412

413413
@Override
414-
protected String urlForExtractor() {
414+
protected String extractorUrl() {
415415
return URL;
416416
}
417417

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ public void setUp() throws Exception {
4747

4848
@Override
4949
protected YoutubeMixPlaylistExtractor createExtractor() throws Exception {
50-
return (YoutubeMixPlaylistExtractor) YouTube.getPlaylistExtractor(urlForExtractor());
50+
return (YoutubeMixPlaylistExtractor) YouTube.getPlaylistExtractor(extractorUrl());
5151
}
5252

53-
protected abstract String urlForExtractor();
53+
protected abstract String extractorUrl();
5454
}
5555

5656
public static class Mix extends Base {
5757
private static final String VIDEO_ID = "FAqYW76GLPA";
5858
private static final String VIDEO_TITLE = "Mix – ";
5959

6060
@Override
61-
protected String urlForExtractor() {
61+
protected String extractorUrl() {
6262
return "https://www.youtube.com/watch?v=" + VIDEO_ID + "&list=RD" + VIDEO_ID;
6363
}
6464

@@ -145,7 +145,7 @@ public static class MixWithIndex extends Base {
145145
private static final String VIDEO_ID_AT_INDEX = "F90Cw4l-8NY";
146146

147147
@Override
148-
protected String urlForExtractor() {
148+
protected String extractorUrl() {
149149
return "https://www.youtube.com/watch?v=" + VIDEO_ID_AT_INDEX
150150
+ "&list=RD" + VIDEO_ID + "&index=" + INDEX;
151151
}
@@ -225,7 +225,7 @@ public static class MyMix extends Base {
225225
private static final String VIDEO_ID = "YVkUvmDQ3HY";
226226

227227
@Override
228-
protected String urlForExtractor() {
228+
protected String extractorUrl() {
229229
return "https://www.youtube.com/watch?v=" + VIDEO_ID
230230
+ "&list=RDMM" + VIDEO_ID;
231231
}
@@ -309,7 +309,7 @@ public static class InvalidPageEmpty extends Base {
309309
private static final String VIDEO_ID = "QMVCAPd5cwBcg";
310310

311311
@Override
312-
protected String urlForExtractor() {
312+
protected String extractorUrl() {
313313
return "https://www.youtube.com/watch?v=" + VIDEO_ID
314314
+ "&list=RD" + VIDEO_ID;
315315
}
@@ -322,7 +322,7 @@ void getPageEmptyUrl() {
322322

323323
public static class InvalidVideoId extends Base {
324324
@Override
325-
protected String urlForExtractor() {
325+
protected String extractorUrl() {
326326
return "https://www.youtube.com/watch?v=" + "abcde"
327327
+ "&list=RD" + "abcde";
328328
}
@@ -343,7 +343,7 @@ public static class GenreMix extends Base {
343343
private static final String MIX_TITLE = "Mix – Electronic music";
344344

345345
@Override
346-
protected String urlForExtractor() {
346+
protected String extractorUrl() {
347347
return "https://www.youtube.com/watch?v=" + VIDEO_ID
348348
+ "&list=RDGMEMYH9CUrFO7CfLJpaD7UR85w";
349349
}
@@ -427,7 +427,7 @@ public static class Music extends Base {
427427
private static final String MIX_TITLE = "Mix – Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)";
428428

429429
@Override
430-
protected String urlForExtractor() {
430+
protected String extractorUrl() {
431431
return "https://m.youtube.com/watch?v=" + VIDEO_ID
432432
+ "&list=RDAMVM" + VIDEO_ID;
433433
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.junit.jupiter.params.ParameterizedTest;
1010
import org.junit.jupiter.params.provider.CsvSource;
1111
import org.junit.jupiter.params.provider.ValueSource;
12+
import org.schabi.newpipe.extractor.InitNewPipeTest;
1213
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
1314
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1415
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
@@ -22,6 +23,7 @@ public class YoutubeStreamLinkHandlerFactoryTest {
2223

2324
@BeforeAll
2425
public static void setUp() throws Exception {
26+
InitNewPipeTest.initEmpty();
2527
linkHandler = YoutubeStreamLinkHandlerFactory.getInstance();
2628
}
2729

0 commit comments

Comments
 (0)