4545import org .schabi .newpipe .extractor .MultiInfoItemsCollector ;
4646import org .schabi .newpipe .extractor .StreamingService ;
4747import 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 ;
4956import org .schabi .newpipe .extractor .linkhandler .LinkHandler ;
5057import org .schabi .newpipe .extractor .localization .ContentCountry ;
5158import org .schabi .newpipe .extractor .localization .DateWrapper ;
5259import org .schabi .newpipe .extractor .localization .Localization ;
5360import org .schabi .newpipe .extractor .localization .TimeAgoParser ;
5461import 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 ;
5669import org .schabi .newpipe .extractor .services .youtube .linkHandler .YoutubeChannelLinkHandlerFactory ;
5770import org .schabi .newpipe .extractor .stream .AudioStream ;
5871import 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