Skip to content

Commit a6a63e9

Browse files
committed
Let isHardcodedClientVersionValid() throw IOException
1 parent 45df824 commit a6a63e9

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public static JsonObject getInitialData(String html) throws ParsingException {
178178
}
179179
}
180180

181-
public static boolean isHardcodedClientVersionValid() {
181+
public static boolean isHardcodedClientVersionValid() throws IOException {
182182
try {
183183
final String url = "https://www.youtube.com/results?search_query=test&pbj=1";
184184

@@ -190,7 +190,7 @@ public static boolean isHardcodedClientVersionValid() {
190190
if (response.length() > 50) { // ensure to have a valid response
191191
return true;
192192
}
193-
} catch (Exception ignored) {}
193+
} catch (ReCaptchaException ignored) {}
194194

195195
return false;
196196
}
@@ -200,7 +200,7 @@ public static boolean isHardcodedClientVersionValid() {
200200
* @return
201201
* @throws ParsingException
202202
*/
203-
public static String getClientVersion() throws ParsingException {
203+
public static String getClientVersion() throws ParsingException, IOException {
204204
if (clientVersion != null && !clientVersion.isEmpty()) return clientVersion;
205205

206206
if (isHardcodedClientVersionValid()) {
@@ -350,8 +350,7 @@ public static String fixThumbnailUrl(String thumbnailUrl) {
350350
public static JsonArray getJsonResponse(String url, Localization localization) throws IOException, ExtractionException {
351351
Map<String, List<String>> headers = new HashMap<>();
352352
headers.put("X-YouTube-Client-Name", Collections.singletonList("1"));
353-
headers.put("X-YouTube-Client-Version",
354-
Collections.singletonList(YoutubeParsingHelper.getClientVersion()));
353+
headers.put("X-YouTube-Client-Version", Collections.singletonList(getClientVersion()));
355354
final String response = getDownloader().get(url, headers, localization).responseBody();
356355

357356
if (response.length() < 50) { // ensure to have a valid response

0 commit comments

Comments
 (0)