4848import org .schabi .newpipe .extractor .stream .AudioTrackType ;
4949import org .schabi .newpipe .extractor .utils .JsonUtils ;
5050import org .schabi .newpipe .extractor .utils .Parser ;
51+ import org .schabi .newpipe .extractor .utils .ProtoBuilder ;
5152import org .schabi .newpipe .extractor .utils .RandomStringFromAlphabetGenerator ;
5253import org .schabi .newpipe .extractor .utils .Utils ;
5354
@@ -212,7 +213,7 @@ private YoutubeParsingHelper() {
212213 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ;
213214
214215 /**
215- * The device machine id for the iPhone 15 , used to get 60fps with the {@code iOS} client.
216+ * The device machine id for the iPhone 16 , used to get 60fps with the {@code iOS} client.
216217 *
217218 * <p>
218219 * See <a href="https://gist.github.com/adamawolf/3048717">this GitHub Gist</a> for more
@@ -222,23 +223,23 @@ private YoutubeParsingHelper() {
222223 private static final String IOS_DEVICE_MODEL = "iPhone16,2" ;
223224
224225 /**
225- * Spoofing an iPhone 15 Pro Max running iOS 17.5.1 with the hardcoded version of the iOS app.
226+ * Spoofing an iPhone 16 Pro Max running iOS 18.1.0 with the hardcoded version of the iOS app.
226227 * To be used for the {@code "osVersion"} field in JSON POST requests.
227228 * <p>
228229 * The value of this field seems to use the following structure:
229230 * "iOS major version.minor version.patch version.build version", where
230231 * "patch version" is equal to 0 if it isn't set
231232 * The build version corresponding to the iOS version used can be found on
232- * <a href="https://theapplewiki.com/wiki/Firmware/iPhone/17 .x#iPhone_15_Pro_Max ">
233- * https://theapplewiki.com/wiki/Firmware/iPhone/17 .x#iPhone_15_Pro_Max </a>
233+ * <a href="https://theapplewiki.com/wiki/Firmware/iPhone/18 .x#iPhone_16_Pro_Max ">
234+ * https://theapplewiki.com/wiki/Firmware/iPhone/18 .x#iPhone_16_Pro_Max </a>
234235 * </p>
235236 *
236237 * @see #IOS_USER_AGENT_VERSION
237238 */
238239 private static final String IOS_OS_VERSION = "18.1.0.22B83" ;
239240
240241 /**
241- * Spoofing an iPhone 15 running iOS 17.5.1 with the hardcoded version of the iOS app. To be
242+ * Spoofing an iPhone 15 running iOS 18.1.0 with the hardcoded version of the iOS app. To be
242243 * used in the user agent for requests.
243244 *
244245 * @see #IOS_OS_VERSION
@@ -306,7 +307,7 @@ public static boolean isY2ubeURL(@Nonnull final URL url) {
306307 public static String randomVisitorData (final ContentCountry country ) {
307308 final ProtoBuilder pbE2 = new ProtoBuilder ();
308309 pbE2 .string (2 , "" );
309- pbE2 .varint (4 , numberGenerator .nextInt (1 , 256 ) );
310+ pbE2 .varint (4 , numberGenerator .nextInt (255 ) + 1 );
310311
311312 final ProtoBuilder pbE = new ProtoBuilder ();
312313 pbE .string (1 , country .getCountryCode ());
@@ -1181,10 +1182,11 @@ public static JsonBuilder<JsonObject> prepareDesktopJsonBuilder(
11811182 public static JsonBuilder <JsonObject > prepareDesktopJsonBuilder (
11821183 @ Nonnull final Localization localization ,
11831184 @ Nonnull final ContentCountry contentCountry ,
1184- @ Nullable String visitorData )
1185+ @ Nullable final String visitorData )
11851186 throws IOException , ExtractionException {
1186- if (visitorData == null ) {
1187- visitorData = randomVisitorData (contentCountry );
1187+ String vData = visitorData ;
1188+ if (vData == null ) {
1189+ vData = randomVisitorData (contentCountry );
11881190 }
11891191
11901192 // @formatter:off
@@ -1198,7 +1200,7 @@ public static JsonBuilder<JsonObject> prepareDesktopJsonBuilder(
11981200 .value ("originalUrl" , "https://www.youtube.com" )
11991201 .value ("platform" , "DESKTOP" )
12001202 .value ("utcOffsetMinutes" , 0 )
1201- .value ("visitorData" , visitorData )
1203+ .value ("visitorData" , vData )
12021204 .end ()
12031205 .object ("request" )
12041206 .array ("internalExperimentFlags" )
0 commit comments