Skip to content

Commit 8a9ebcc

Browse files
committed
[YouTube] Update InnerTube clients' version and devices' OS version and model
1 parent eac850c commit 8a9ebcc

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private YoutubeParsingHelper() {
152152
* The client version for InnerTube requests with the {@code WEB} client, used as the last
153153
* fallback if the extraction of the real one failed.
154154
*/
155-
private static final String HARDCODED_CLIENT_VERSION = "2.20220809.02.00";
155+
private static final String HARDCODED_CLIENT_VERSION = "2.20231208.01.00";
156156

157157
/**
158158
* The InnerTube API key which should be used by YouTube's desktop website, used as a fallback
@@ -169,7 +169,7 @@ private YoutubeParsingHelper() {
169169
* such as <a href="https://www.apkmirror.com/apk/google-inc/youtube/">APKMirror</a>.
170170
* </p>
171171
*/
172-
private static final String ANDROID_YOUTUBE_CLIENT_VERSION = "17.31.35";
172+
private static final String ANDROID_YOUTUBE_CLIENT_VERSION = "18.48.37";
173173

174174
/**
175175
* The InnerTube API key used by the {@code ANDROID} client. Found with the help of
@@ -187,7 +187,7 @@ private YoutubeParsingHelper() {
187187
* Store page of the YouTube app</a>, in the {@code What’s New} section.
188188
* </p>
189189
*/
190-
private static final String IOS_YOUTUBE_CLIENT_VERSION = "17.31.4";
190+
private static final String IOS_YOUTUBE_CLIENT_VERSION = "18.48.3";
191191

192192
/**
193193
* The InnerTube API key used by the {@code iOS} client. Found with the help of
@@ -204,7 +204,7 @@ private YoutubeParsingHelper() {
204204
private static String key;
205205

206206
private static final String[] HARDCODED_YOUTUBE_MUSIC_KEY =
207-
{"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30", "67", "1.20220808.01.00"};
207+
{"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30", "67", "1.20231204.01.00"};
208208
private static String[] youtubeMusicKey;
209209

210210
private static boolean keyAndVersionExtracted = false;
@@ -228,14 +228,14 @@ private YoutubeParsingHelper() {
228228
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
229229

230230
/**
231-
* The device machine id for the iPhone 13, used to get 60fps with the {@code iOS} client.
231+
* The device machine id for the iPhone 15, used to get 60fps with the {@code iOS} client.
232232
*
233233
* <p>
234234
* See <a href="https://gist.github.com/adamawolf/3048717">this GitHub Gist</a> for more
235235
* information.
236236
* </p>
237237
*/
238-
private static final String IOS_DEVICE_MODEL = "iPhone14,5";
238+
private static final String IOS_DEVICE_MODEL = "iPhone15,4";
239239

240240
private static Random numberGenerator = new Random();
241241

@@ -1329,19 +1329,19 @@ public static JsonBuilder<JsonObject> prepareAndroidMobileJsonBuilder(
13291329
.value("clientVersion", ANDROID_YOUTUBE_CLIENT_VERSION)
13301330
.value("platform", "MOBILE")
13311331
.value("osName", "Android")
1332-
.value("osVersion", "12")
1332+
.value("osVersion", "14")
13331333
/*
13341334
A valid Android SDK version is required to be sure to get a valid player
13351335
response
1336-
If this parameter is not provided, the player response may be replaced by
1337-
the one of a 5-minute video saying the message "The following content is
1338-
not available on this app. Watch this content on the latest version on
1339-
YouTube"
1336+
If this parameter is not provided, the player response is replaced by an
1337+
error saying the message "The following content is not available on this
1338+
app. Watch this content on the latest version on YouTube" (it was
1339+
previously a 5-minute video with this message)
13401340
See https://github.com/TeamNewPipe/NewPipe/issues/8713
13411341
The Android SDK version corresponding to the Android version used in
13421342
requests is sent
13431343
*/
1344-
.value("androidSdkVersion", 31)
1344+
.value("androidSdkVersion", 34)
13451345
.value("hl", localization.getLocalizationCode())
13461346
.value("gl", contentCountry.getCountryCode())
13471347
.end()
@@ -1369,11 +1369,14 @@ public static JsonBuilder<JsonObject> prepareIosMobileJsonBuilder(
13691369
.value("deviceModel", IOS_DEVICE_MODEL)
13701370
.value("platform", "MOBILE")
13711371
.value("osName", "iOS")
1372-
// The value of this field seems to use the following structure:
1373-
// "iOS version.0.build version"
1374-
// The build version corresponding to the iOS version used can be found on
1375-
// https://www.theiphonewiki.com/wiki/Firmware/iPhone/15.x#iPhone_13
1376-
.value("osVersion", "15.6.0.19G71")
1372+
/*
1373+
The value of this field seems to use the following structure:
1374+
"iOS major version.minor version.patch version.build version", where
1375+
"patch version" is equal to 0 if it isn't set
1376+
The build version corresponding to the iOS version used can be found on
1377+
https://theapplewiki.com/wiki/Firmware/iPhone/17.x#iPhone_15
1378+
*/
1379+
.value("osVersion", "17.1.2.21B101")
13771380
.value("hl", localization.getLocalizationCode())
13781381
.value("gl", contentCountry.getCountryCode())
13791382
.end()
@@ -1458,9 +1461,9 @@ public static byte[] createDesktopPlayerBody(
14581461
*/
14591462
@Nonnull
14601463
public static String getAndroidUserAgent(@Nullable final Localization localization) {
1461-
// Spoofing an Android 12 device with the hardcoded version of the Android app
1464+
// Spoofing an Android 14 device with the hardcoded version of the Android app
14621465
return "com.google.android.youtube/" + ANDROID_YOUTUBE_CLIENT_VERSION
1463-
+ " (Linux; U; Android 12; "
1466+
+ " (Linux; U; Android 14; "
14641467
+ (localization != null ? localization : Localization.DEFAULT).getCountryCode()
14651468
+ ") gzip";
14661469
}
@@ -1480,9 +1483,9 @@ public static String getAndroidUserAgent(@Nullable final Localization localizati
14801483
*/
14811484
@Nonnull
14821485
public static String getIosUserAgent(@Nullable final Localization localization) {
1483-
// Spoofing an iPhone 13 running iOS 15.6 with the hardcoded version of the iOS app
1486+
// Spoofing an iPhone 15 running iOS 17.1.2 with the hardcoded version of the iOS app
14841487
return "com.google.ios.youtube/" + IOS_YOUTUBE_CLIENT_VERSION
1485-
+ "(" + IOS_DEVICE_MODEL + "; U; CPU iOS 15_6 like Mac OS X; "
1488+
+ "(" + IOS_DEVICE_MODEL + "; U; CPU iOS 17_1_2 like Mac OS X; "
14861489
+ (localization != null ? localization : Localization.DEFAULT).getCountryCode()
14871490
+ ")";
14881491
}

0 commit comments

Comments
 (0)