@@ -134,7 +134,7 @@ private YoutubeParsingHelper() {
134134 public static final String CONTENT_CHECK_OK = "contentCheckOk" ;
135135
136136 /**
137- * A parameter which may be send by official clients named {@code racyCheckOk}.
137+ * A parameter which may be sent by official clients named {@code racyCheckOk}.
138138 *
139139 * <p>
140140 * What this parameter does is not really known, but it seems to be linked to sensitive
@@ -146,50 +146,60 @@ private YoutubeParsingHelper() {
146146 /**
147147 * The client version for InnerTube requests with the {@code WEB} client, used as the last
148148 * fallback if the extraction of the real one failed.
149- *
150- * You can get it directly either into YouTube pages or the service worker JavaScript file
151- * ({@code https://www.youtube.com/sw.js}) (also applies for YouTube Music).
152149 */
153- private static final String HARDCODED_CLIENT_VERSION = "2.20220315.01.00" ;
150+ private static final String HARDCODED_CLIENT_VERSION = "2.20220808.01.00" ;
151+
152+ /**
153+ * The InnerTube API key which should be used by YouTube's desktop website, used as a fallback
154+ * if the extraction of the real one failed.
155+ */
154156 private static final String HARDCODED_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8" ;
155157
156158 /**
157- * The InnerTube API key used by the {@code ANDROID} client. Found with the help of
158- * reverse-engineering app network requests.
159+ * The hardcoded client version of the Android app used for InnerTube requests with this
160+ * client.
161+ *
162+ * <p>
163+ * It can be extracted by getting the latest release version of the app in an APK repository
164+ * such as <a href="https://www.apkmirror.com/apk/google-inc/youtube/">APKMirror</a>.
165+ * </p>
159166 */
160- private static final String ANDROID_YOUTUBE_KEY = "AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w " ;
167+ private static final String ANDROID_YOUTUBE_CLIENT_VERSION = "17.31.35 " ;
161168
162169 /**
163- * The InnerTube API key used by the {@code iOS } client. Found with the help of
170+ * The InnerTube API key used by the {@code ANDROID } client. Found with the help of
164171 * reverse-engineering app network requests.
165172 */
166- private static final String IOS_YOUTUBE_KEY = "AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc " ;
173+ private static final String ANDROID_YOUTUBE_KEY = "AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w " ;
167174
168175 /**
169- * The hardcoded client version of the Android app used for InnerTube requests with this
176+ * The hardcoded client version of the iOS app used for InnerTube requests with this
170177 * client.
171178 *
172179 * <p>
173- * It can be extracted by getting the latest release version of the app in an APK repository
174- * such as APKMirror.
180+ * It can be extracted by getting the latest release version of the app on
181+ * <a href="https://apps.apple.com/us/app/youtube-watch-listen-stream/id544007664/">the App
182+ * Store page of the YouTube app</a>, in the {@code What’s New} section.
175183 * </p>
176- *
177- * @implNote This version is also used for the {@code iOS} client, as getting the app version
178- * without an iPhone device is not so easily.
179184 */
180- private static final String MOBILE_YOUTUBE_CLIENT_VERSION = "17.10.35 " ;
185+ private static final String IOS_YOUTUBE_CLIENT_VERSION = "17.30.3 " ;
181186
182187 /**
183- * The hardcoded client version of the Android app used for InnerTube requests with this
184- * client.
188+ * The InnerTube API key used by the {@code iOS} client. Found with the help of
189+ * reverse-engineering app network requests.
190+ */
191+ private static final String IOS_YOUTUBE_KEY = "AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc" ;
192+
193+ /**
194+ * The hardcoded client version used for InnerTube requests with the TV HTML5 embed client.
185195 */
186196 private static final String TVHTML5_SIMPLY_EMBED_CLIENT_VERSION = "2.0" ;
187197
188198 private static String clientVersion ;
189199 private static String key ;
190200
191201 private static final String [] HARDCODED_YOUTUBE_MUSIC_KEY =
192- {"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30" , "67" , "1.20220309 .01.00" };
202+ {"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30" , "67" , "1.20220803 .01.00" };
193203 private static String [] youtubeMusicKey ;
194204
195205 private static boolean keyAndVersionExtracted = false ;
@@ -1123,7 +1133,7 @@ public static JsonBuilder<JsonObject> prepareAndroidMobileJsonBuilder(
11231133 .object ("context" )
11241134 .object ("client" )
11251135 .value ("clientName" , "ANDROID" )
1126- .value ("clientVersion" , MOBILE_YOUTUBE_CLIENT_VERSION )
1136+ .value ("clientVersion" , ANDROID_YOUTUBE_CLIENT_VERSION )
11271137 .value ("platform" , "MOBILE" )
11281138 .value ("hl" , localization .getLocalizationCode ())
11291139 .value ("gl" , contentCountry .getCountryCode ())
@@ -1146,7 +1156,7 @@ public static JsonBuilder<JsonObject> prepareIosMobileJsonBuilder(
11461156 .object ("context" )
11471157 .object ("client" )
11481158 .value ("clientName" , "IOS" )
1149- .value ("clientVersion" , MOBILE_YOUTUBE_CLIENT_VERSION )
1159+ .value ("clientVersion" , IOS_YOUTUBE_CLIENT_VERSION )
11501160 // Device model is required to get 60fps streams
11511161 .value ("deviceModel" , IOS_DEVICE_MODEL )
11521162 .value ("platform" , "MOBILE" )
@@ -1223,8 +1233,10 @@ public static byte[] createDesktopPlayerBody(
12231233 * Get the user-agent string used as the user-agent for InnerTube requests with the Android
12241234 * client.
12251235 *
1236+ * <p>
12261237 * If the {@link Localization} provided is {@code null}, fallbacks to
12271238 * {@link Localization#DEFAULT the default one}.
1239+ * </p>
12281240 *
12291241 * @param localization the {@link Localization} to set in the user-agent
12301242 * @return the Android user-agent used for InnerTube requests with the Android client,
@@ -1233,7 +1245,7 @@ public static byte[] createDesktopPlayerBody(
12331245 @ Nonnull
12341246 public static String getAndroidUserAgent (@ Nullable final Localization localization ) {
12351247 // Spoofing an Android 12 device with the hardcoded version of the Android app
1236- return "com.google.android.youtube/" + MOBILE_YOUTUBE_CLIENT_VERSION
1248+ return "com.google.android.youtube/" + ANDROID_YOUTUBE_CLIENT_VERSION
12371249 + " (Linux; U; Android 12; "
12381250 + (localization != null ? localization : Localization .DEFAULT ).getCountryCode ()
12391251 + ") gzip" ;
@@ -1243,8 +1255,10 @@ public static String getAndroidUserAgent(@Nullable final Localization localizati
12431255 * Get the user-agent string used as the user-agent for InnerTube requests with the iOS
12441256 * client.
12451257 *
1258+ * <p>
12461259 * If the {@link Localization} provided is {@code null}, fallbacks to
12471260 * {@link Localization#DEFAULT the default one}.
1261+ * </p>
12481262 *
12491263 * @param localization the {@link Localization} to set in the user-agent
12501264 * @return the iOS user-agent used for InnerTube requests with the iOS client, depending on the
@@ -1253,7 +1267,7 @@ public static String getAndroidUserAgent(@Nullable final Localization localizati
12531267 @ Nonnull
12541268 public static String getIosUserAgent (@ Nullable final Localization localization ) {
12551269 // Spoofing an iPhone running iOS 15.4 with the hardcoded mobile client version
1256- return "com.google.ios.youtube/" + MOBILE_YOUTUBE_CLIENT_VERSION
1270+ return "com.google.ios.youtube/" + IOS_YOUTUBE_CLIENT_VERSION
12571271 + "(" + IOS_DEVICE_MODEL + "; U; CPU iOS 15_4 like Mac OS X; "
12581272 + (localization != null ? localization : Localization .DEFAULT ).getCountryCode ()
12591273 + ")" ;
0 commit comments