Skip to content

Commit 64dae72

Browse files
FireMasterKStypox
authored andcommitted
Fix all checkstyle issues.
1 parent b0bb101 commit 64dae72

3 files changed

Lines changed: 61 additions & 29 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/PoTokenProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/**
66
* An interface to provide poTokens to YouTube player requests.
77
*
8-
* @implNote This interface is expected to be thread-safe, as it may be accessed by multiple threads.
98
*
109
* <p>
1110
* On some major clients, YouTube requires that the integrity of the device passes some checks to
@@ -21,6 +20,9 @@
2120
* <p>
2221
* These tokens may have a role in triggering the sign in requirement.
2322
* </p>
23+
*
24+
* @implNote This interface is expected to be thread-safe,
25+
* as it may be accessed by multiple threads.
2426
*/
2527
public interface PoTokenProvider {
2628

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamHelper.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public static JsonObject getWebFullPlayerResponse(
6464
@Nonnull final String videoId,
6565
@Nonnull final PoTokenResult webPoTokenResult) throws IOException, ExtractionException {
6666
final byte[] body = JsonWriter.string(
67-
prepareDesktopJsonBuilder(localization, contentCountry, webPoTokenResult.visitorData)
67+
prepareDesktopJsonBuilder(
68+
localization,
69+
contentCountry,
70+
webPoTokenResult.visitorData
71+
)
6872
.value(VIDEO_ID, videoId)
6973
.value(CONTENT_CHECK_OK, true)
7074
.value(RACY_CHECK_OK, true)
@@ -80,14 +84,20 @@ public static JsonObject getWebFullPlayerResponse(
8084
url, getYouTubeHeaders(), body, localization)));
8185
}
8286

83-
public static JsonObject getAndroidPlayerResponse(@Nonnull final ContentCountry contentCountry,
84-
@Nonnull final Localization localization,
85-
@Nonnull final String videoId,
86-
@Nonnull final String androidCpn,
87-
@Nonnull final PoTokenResult androidPoTokenResult)
87+
public static JsonObject getAndroidPlayerResponse(
88+
@Nonnull final ContentCountry contentCountry,
89+
@Nonnull final Localization localization,
90+
@Nonnull final String videoId,
91+
@Nonnull final String androidCpn,
92+
@Nonnull final PoTokenResult androidPoTokenResult
93+
)
8894
throws IOException, ExtractionException {
8995
final byte[] mobileBody = JsonWriter.string(
90-
prepareAndroidMobileJsonBuilder(localization, contentCountry, androidPoTokenResult.visitorData)
96+
prepareAndroidMobileJsonBuilder(
97+
localization,
98+
contentCountry,
99+
androidPoTokenResult.visitorData
100+
)
91101
.value(VIDEO_ID, videoId)
92102
.value(CPN, androidCpn)
93103
.value(CONTENT_CHECK_OK, true)
@@ -105,10 +115,12 @@ public static JsonObject getAndroidPlayerResponse(@Nonnull final ContentCountry
105115
"&t=" + generateTParameter() + "&id=" + videoId);
106116
}
107117

108-
public static JsonObject getAndroidReelPlayerResponse(@Nonnull final ContentCountry contentCountry,
109-
@Nonnull final Localization localization,
110-
@Nonnull final String videoId,
111-
@Nonnull final String androidCpn)
118+
public static JsonObject getAndroidReelPlayerResponse(
119+
@Nonnull final ContentCountry contentCountry,
120+
@Nonnull final Localization localization,
121+
@Nonnull final String videoId,
122+
@Nonnull final String androidCpn
123+
)
112124
throws IOException, ExtractionException {
113125
final byte[] mobileBody = JsonWriter.string(
114126
prepareAndroidMobileJsonBuilder(localization, contentCountry, null)

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

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,27 @@
4545
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
4646
import org.schabi.newpipe.extractor.StreamingService;
4747
import org.schabi.newpipe.extractor.downloader.Downloader;
48-
import org.schabi.newpipe.extractor.exceptions.*;
48+
import org.schabi.newpipe.extractor.exceptions.AgeRestrictedContentException;
49+
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
50+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
51+
import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException;
52+
import org.schabi.newpipe.extractor.exceptions.PaidContentException;
53+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
54+
import org.schabi.newpipe.extractor.exceptions.PrivateContentException;
55+
import org.schabi.newpipe.extractor.exceptions.YoutubeMusicPremiumContentException;
4956
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
5057
import org.schabi.newpipe.extractor.localization.ContentCountry;
5158
import org.schabi.newpipe.extractor.localization.DateWrapper;
5259
import org.schabi.newpipe.extractor.localization.Localization;
5360
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
5461
import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager;
55-
import org.schabi.newpipe.extractor.services.youtube.*;
62+
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
63+
import org.schabi.newpipe.extractor.services.youtube.PoTokenProvider;
64+
import org.schabi.newpipe.extractor.services.youtube.PoTokenResult;
65+
import org.schabi.newpipe.extractor.services.youtube.YoutubeJavaScriptPlayerManager;
66+
import org.schabi.newpipe.extractor.services.youtube.YoutubeMetaInfoHelper;
67+
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
68+
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamHelper;
5669
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
5770
import org.schabi.newpipe.extractor.stream.AudioStream;
5871
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
@@ -792,9 +805,9 @@ public void onFetchPage(@Nonnull final Downloader downloader)
792805
throw new ExtractionException("IOS player response is not valid");
793806
}
794807

795-
final JsonObject iosStreamingData = iosPlayerResponse.getObject(STREAMING_DATA);
796-
if (!isNullOrEmpty(iosStreamingData)) {
797-
this.iosStreamingData = iosStreamingData;
808+
final JsonObject iosStreamingDataLocal = iosPlayerResponse.getObject(STREAMING_DATA);
809+
if (!isNullOrEmpty(iosStreamingDataLocal)) {
810+
this.iosStreamingData = iosStreamingDataLocal;
798811
if (!forceFetchIosClient) {
799812
playerCaptionsTracklistRenderer = iosPlayerResponse.getObject("captions")
800813
.getObject("playerCaptionsTracklistRenderer");
@@ -839,7 +852,9 @@ private static void checkPlayabilityStatus(final JsonObject youtubePlayerRespons
839852
throw new PrivateContentException("This video is private.");
840853
}
841854
} else if (reason.contains("age")) {
842-
throw new AgeRestrictedContentException("Age-restricted videos cannot be watched anonymously");
855+
throw new AgeRestrictedContentException(
856+
"Age-restricted videos cannot be watched anonymously"
857+
);
843858
}
844859
}
845860

@@ -877,7 +892,8 @@ private static void checkPlayabilityStatus(final JsonObject youtubePlayerRespons
877892
private void fetchWebClient(@Nonnull final Localization localization,
878893
@Nonnull final ContentCountry contentCountry,
879894
@Nonnull final String videoId,
880-
@Nullable final PoTokenResult webPoTokenResult) throws IOException, ExtractionException {
895+
@Nullable final PoTokenResult webPoTokenResult
896+
) throws IOException, ExtractionException {
881897
final JsonObject webPlayerResponse;
882898
if (webPoTokenResult == null) {
883899
webPlayerResponse = YoutubeStreamHelper.getWebMetadataPlayerResponse(
@@ -927,10 +943,10 @@ private void fetchAndroidClient(@Nonnull final Localization localization,
927943
}
928944

929945
if (!isPlayerResponseNotValid(androidPlayerResponse, videoId)) {
930-
final JsonObject androidStreamingData =
946+
final JsonObject androidStreamingDataLocal =
931947
androidPlayerResponse.getObject(STREAMING_DATA);
932-
if (!isNullOrEmpty(androidStreamingData)) {
933-
this.androidStreamingData = androidStreamingData;
948+
if (!isNullOrEmpty(androidStreamingDataLocal)) {
949+
this.androidStreamingData = androidStreamingDataLocal;
934950
if (isNullOrEmpty(playerCaptionsTracklistRenderer)) {
935951
playerCaptionsTracklistRenderer =
936952
androidPlayerResponse.getObject("captions")
@@ -1519,9 +1535,10 @@ public List<MetaInfo> getMetaInfo() throws ParsingException {
15191535
* Sets the {@link PoTokenProvider} instance to be used for fetching poTokens.
15201536
*
15211537
* <p>
1522-
* This method allows setting an implementation of {@link PoTokenProvider} which will be used
1523-
* to obtain poTokens required for YouTube player requests. These tokens are used by YouTube to verify the
1524-
* integrity of the device and may be necessary for playback at times.
1538+
* This method allows setting an implementation of {@link PoTokenProvider} which will
1539+
* be used to obtain poTokens required for YouTube player requests. These tokens are
1540+
* used by YouTube to verify the integrity of the device and may be necessary for
1541+
* playback at times.
15251542
* </p>
15261543
*
15271544
* @param poTokenProvider the {@link PoTokenProvider} instance to set
@@ -1535,13 +1552,14 @@ public static void setPoTokenProvider(@Nullable final PoTokenProvider poTokenPro
15351552
*
15361553
* <p>
15371554
* This method allows setting a flag to force the fetching of the iOS player response, even if a
1538-
* valid webPoTokenResult is available. This can be useful in scenarios where streams from the iOS player
1539-
* response is preferred.
1555+
* valid webPoTokenResult is available. This can be useful in scenarios where streams from the
1556+
* iOS player response is preferred.
15401557
* </p>
15411558
*
1542-
* @param forceFetchIosClient a boolean flag indicating whether to force fetch the iOS player response
1559+
* @param forceFetchIosClient a boolean flag indicating whether to force fetch the iOS
1560+
* player response
15431561
*/
1544-
public static void setForceFetchIosClient(boolean forceFetchIosClient) {
1562+
public static void setForceFetchIosClient(final boolean forceFetchIosClient) {
15451563
YoutubeStreamExtractor.forceFetchIosClient = forceFetchIosClient;
15461564
}
15471565
}

0 commit comments

Comments
 (0)