Skip to content

Commit 06689a2

Browse files
committed
Add url to ReCaptchaException
Sometimes YouTube introduces recaptchas only on some pages. By adding an url to the ReCaptchaException the NewPipe app is able to use that url to load the page that originally caused the problem. Also removed every instance of exception caught and rethrown with a different description: it makes no sense and it removes part of the useful stacktrace.
1 parent 5f65788 commit 06689a2

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/ReCaptchaException.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@
2121
*/
2222

2323
public class ReCaptchaException extends ExtractionException {
24-
public ReCaptchaException(String message) {
24+
private String url;
25+
26+
public ReCaptchaException(String message, String url) {
2527
super(message);
28+
this.url = url;
29+
}
30+
31+
public String getUrl() {
32+
return url;
2633
}
2734
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,6 @@ private EmbeddedInfo getEmbeddedInfo() throws ParsingException, ReCaptchaExcepti
714714
} catch (IOException e) {
715715
throw new ParsingException(
716716
"Could load decryption code form restricted video for the Youtube service.", e);
717-
} catch (ReCaptchaException e) {
718-
throw new ReCaptchaException("reCaptcha Challenge requested");
719717
}
720718
}
721719

extractor/src/main/java/org/schabi/newpipe/extractor/utils/DashMpdParser.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ public static ParserResult getStreams(final StreamInfo streamInfo)
123123
dashDoc = downloader.download(streamInfo.getDashMpdUrl());
124124
} catch (IOException ioe) {
125125
throw new DashMpdParsingException("Could not get dash mpd: " + streamInfo.getDashMpdUrl(), ioe);
126-
} catch (ReCaptchaException e) {
127-
throw new ReCaptchaException("reCaptcha Challenge needed");
128126
}
129127

130128
try {

extractor/src/test/java/org/schabi/newpipe/Downloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private static String dl(HttpsURLConnection con) throws IOException, ReCaptchaEx
129129
* request See : https://github.com/rg3/youtube-dl/issues/5138
130130
*/
131131
if (con.getResponseCode() == 429) {
132-
throw new ReCaptchaException("reCaptcha Challenge requested");
132+
throw new ReCaptchaException("reCaptcha Challenge requested", con.getURL().toString());
133133
}
134134

135135
throw new IOException(con.getResponseCode() + " " + con.getResponseMessage(), e);

0 commit comments

Comments
 (0)