Skip to content

Commit 02228dc

Browse files
committed
Fixed checkstyle problems
1 parent b90a0df commit 02228dc

File tree

17 files changed

+66
-51
lines changed

17 files changed

+66
-51
lines changed

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/AbstractYoutubeDashManifestCreator.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -478,20 +478,23 @@ protected void generateSegmentTimelineElement()
478478

479479
// region initResponse
480480

481+
@SuppressWarnings("checkstyle:FinalParameters")
481482
@Nonnull
482-
protected Response getInitializationResponse(@Nonnull String baseStreamingUrl) {
483+
protected Response getInitializationResponse(@Nonnull final String baseStreamingUrl) {
483484
final boolean isHtml5StreamingUrl = isWebStreamingUrl(baseStreamingUrl)
484485
|| isTvHtml5SimplyEmbeddedPlayerStreamingUrl(baseStreamingUrl);
485486
final boolean isAndroidStreamingUrl = isAndroidStreamingUrl(baseStreamingUrl);
486487
final boolean isIosStreamingUrl = isIosStreamingUrl(baseStreamingUrl);
488+
489+
String streamingUrl = baseStreamingUrl;
487490
if (isHtml5StreamingUrl) {
488-
baseStreamingUrl += ALR_YES;
491+
streamingUrl += ALR_YES;
489492
}
490-
baseStreamingUrl = appendBaseStreamingUrlParams(baseStreamingUrl);
493+
streamingUrl = appendBaseStreamingUrlParams(streamingUrl);
491494

492495
final Downloader downloader = NewPipe.getDownloader();
493496
if (isHtml5StreamingUrl) {
494-
return getStreamingWebUrlWithoutRedirects(downloader, baseStreamingUrl);
497+
return getStreamingWebUrlWithoutRedirects(downloader, streamingUrl);
495498
} else if (isAndroidStreamingUrl || isIosStreamingUrl) {
496499
try {
497500
final Map<String, List<String>> headers = new HashMap<>();
@@ -500,15 +503,15 @@ protected Response getInitializationResponse(@Nonnull String baseStreamingUrl) {
500503
? getAndroidUserAgent(null)
501504
: getIosUserAgent(null)));
502505
final byte[] emptyBody = "".getBytes(StandardCharsets.UTF_8);
503-
return downloader.post(baseStreamingUrl, headers, emptyBody);
506+
return downloader.post(streamingUrl, headers, emptyBody);
504507
} catch (final IOException | ExtractionException e) {
505508
throw new DashManifestCreationException("Could not get the "
506509
+ (isIosStreamingUrl ? "IOS" : "ANDROID") + " streaming URL response", e);
507510
}
508511
}
509512

510513
try {
511-
return downloader.get(baseStreamingUrl);
514+
return downloader.get(streamingUrl);
512515
} catch (final IOException | ExtractionException e) {
513516
throw new DashManifestCreationException("Could not get the streaming URL response", e);
514517
}
@@ -517,13 +520,15 @@ protected Response getInitializationResponse(@Nonnull String baseStreamingUrl) {
517520
@Nonnull
518521
protected Response getStreamingWebUrlWithoutRedirects(
519522
@Nonnull final Downloader downloader,
520-
@Nonnull String streamingUrl) {
523+
@Nonnull final String streamingUrl) {
521524
try {
522525
final Map<String, List<String>> headers = new HashMap<>();
523526
addClientInfoHeaders(headers);
524527

528+
String currentStreamingUrl = streamingUrl;
529+
525530
for (int r = 0; r < MAXIMUM_REDIRECT_COUNT; r++) {
526-
final Response response = downloader.get(streamingUrl, headers);
531+
final Response response = downloader.get(currentStreamingUrl, headers);
527532

528533
final int responseCode = response.responseCode();
529534
if (responseCode != 200) {
@@ -544,7 +549,7 @@ protected Response getStreamingWebUrlWithoutRedirects(
544549
return response;
545550
}
546551

547-
streamingUrl = response.responseBody();
552+
currentStreamingUrl = response.responseBody();
548553
}
549554

550555
throw new DashManifestCreationException("Too many redirects");

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/YoutubeOtfDashManifestCreator.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ public String generateManifest() {
3535

3636
final int responseCode = response.responseCode();
3737
if (responseCode != 200) {
38-
throw new DashManifestCreationException("Could not get the initialization URL: " +
39-
"response code "
40-
+ responseCode);
38+
throw new DashManifestCreationException("Could not get the initialization URL: "
39+
+ "response code " + responseCode);
4140
}
4241

4342
final String[] segmentDurations;
@@ -150,13 +149,13 @@ protected long getStreamDuration(@Nonnull final String[] segmentDurations) {
150149
})
151150
.sum();
152151
} catch (final NumberFormatException e) {
153-
throw new DashManifestCreationException("Could not get stream length from sequences " +
154-
"list", e);
152+
throw new DashManifestCreationException(
153+
"Could not get stream length from sequences list", e);
155154
}
156155
}
157156

158-
protected Stream<String[]> streamAndSplitSegmentDurations(@Nonnull final String[] segmentDurations) {
159-
return Stream.of(segmentDurations)
157+
protected Stream<String[]> streamAndSplitSegmentDurations(@Nonnull final String[] durations) {
158+
return Stream.of(durations)
160159
.map(segDuration -> segDuration.split("\\(r="));
161160
}
162161
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/YoutubePostLiveStreamDvrDashManifestCreator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
import javax.annotation.Nonnull;
1717

18-
public class YoutubePostLiveStreamDvrDashManifestCreator extends AbstractYoutubeDashManifestCreator {
18+
public class YoutubePostLiveStreamDvrDashManifestCreator
19+
extends AbstractYoutubeDashManifestCreator {
1920

2021
public YoutubePostLiveStreamDvrDashManifestCreator(@Nonnull final ItagInfo<?> itagInfo,
2122
final long durationSecondsFallback) {

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/YoutubeProgressiveDashManifestCreator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public String generateManifest() {
2929
} else if (durationSecondsFallback > 0) {
3030
streamDurationMs = durationSecondsFallback * 1000;
3131
} else {
32-
throw DashManifestCreationException.couldNotAddElement(MPD, "the duration of the " +
33-
"stream could not be determined and durationSecondsFallback is <= 0");
32+
throw DashManifestCreationException.couldNotAddElement(MPD,
33+
"unable to determine duration and fallback is invalid");
3434
}
3535

3636
generateDocumentAndCommonElements(streamDurationMs);

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/itag/delivery/simpleimpl/SimpleProgressiveHTTPItagFormatDeliveryData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.schabi.newpipe.extractor.services.youtube.itag.delivery.ProgressiveHTTPItagFormatDeliveryData;
44

5-
public class SimpleProgressiveHTTPItagFormatDeliveryData implements ProgressiveHTTPItagFormatDeliveryData {
5+
public class SimpleProgressiveHTTPItagFormatDeliveryData
6+
implements ProgressiveHTTPItagFormatDeliveryData {
67
// Just a marker for now
78
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/itag/format/registry/ItagFormatRegistry.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
import java.util.stream.Stream;
2222

23+
// CHECKSTYLE:OFF - Link is too long
2324
// https://github.com/ytdl-org/youtube-dl/blob/9aa8e5340f3d5ece372b983f8e399277ca1f1fe4/youtube_dl/extractor/youtube.py#L1195
25+
// CHECKSTYLE:ON
2426
public final class ItagFormatRegistry {
2527

2628
public static final VideoAudioItagFormat[] VIDEO_AUDIO_FORMATS = new VideoAudioItagFormat[]{
@@ -35,7 +37,9 @@ public final class ItagFormatRegistry {
3537
new SimpleVideoAudioItagFormat(35, MPEG_4, fromHeightWidth(480, 854), 128),
3638

3739
// Itag 36 is no longer used because the height is unstable and it's not returned by YT
40+
// CHECKSTYLE:OFF - Link is too long
3841
// see also: https://github.com/ytdl-org/youtube-dl/blob/9aa8e5340f3d5ece372b983f8e399277ca1f1fe4/youtube_dl/extractor/youtube.py#L1204
42+
// CHECKSTYLE:ON
3943
new SimpleVideoAudioItagFormat(37, MPEG_4, fromHeightWidth(1080, 1920), 192),
4044
new SimpleVideoAudioItagFormat(38, MPEG_4, fromHeightWidth(3072, 4092), 192),
4145

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/itag/info/ItagInfoRange.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public int end() {
1919

2020
@Override
2121
public String toString() {
22-
return "ItagInfoRange{" +
23-
"start=" + start +
24-
", end=" + end +
25-
'}';
22+
return "ItagInfoRange{"
23+
+ "start=" + start
24+
+ ", end=" + end
25+
+ '}';
2626
}
2727
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public class StreamInfo extends Info {
9999
private List<StreamSegment> streamSegments = new ArrayList<>();
100100
private List<MetaInfo> metaInfo = new ArrayList<>();
101101

102+
@SuppressWarnings("checkstyle:ParameterNumber")
102103
public StreamInfo(final int serviceId,
103104
final String url,
104105
final String originalUrl,
@@ -554,8 +555,8 @@ private static void extractStreams(final StreamInfo streamInfo,
554555
&& streamInfo.getDashMpdUrl().trim().isEmpty()
555556
&& streamInfo.getHlsMasterPlaylistUrl().trim().isEmpty()
556557
) {
557-
throw new StreamExtractException("Could not get any required streaming-data. " +
558-
"See error variable to get further details.");
558+
throw new StreamExtractException("Could not get any required streaming-data. "
559+
+ "See error variable to get further details.");
559560
}
560561
}
561562

extractor/src/main/java/org/schabi/newpipe/extractor/streamdata/delivery/dashmanifestcreator/DashManifestCreationException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* while creating a manifest.
88
*/
99
public class DashManifestCreationException extends RuntimeException {
10-
10+
1111
public DashManifestCreationException(final String message) {
1212
super(message);
1313
}
@@ -51,6 +51,7 @@ public static DashManifestCreationException couldNotAddElement(final String elem
5151
@Nonnull
5252
public static DashManifestCreationException couldNotAddElement(final String element,
5353
final String reason) {
54-
return new DashManifestCreationException("Could not add " + element + " element: " + reason);
54+
return new DashManifestCreationException(
55+
"Could not add " + element + " element: " + reason);
5556
}
5657
}

extractor/src/main/java/org/schabi/newpipe/extractor/streamdata/delivery/simpleimpl/SimpleDASHManifestDeliveryDataImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ public String getCachedDashManifestAsString() {
4444
}
4545
return cachedDashManifest;
4646
}
47-
}
47+
}

0 commit comments

Comments
 (0)