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.
This commit is contained in:
Stypox 2019-08-17 09:09:07 +02:00
parent 5f65788a2f
commit 06689a2f27
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
4 changed files with 9 additions and 6 deletions

View File

@ -21,7 +21,14 @@ package org.schabi.newpipe.extractor.exceptions;
*/
public class ReCaptchaException extends ExtractionException {
public ReCaptchaException(String message) {
private String url;
public ReCaptchaException(String message, String url) {
super(message);
this.url = url;
}
public String getUrl() {
return url;
}
}

View File

@ -714,8 +714,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
} catch (IOException e) {
throw new ParsingException(
"Could load decryption code form restricted video for the Youtube service.", e);
} catch (ReCaptchaException e) {
throw new ReCaptchaException("reCaptcha Challenge requested");
}
}

View File

@ -123,8 +123,6 @@ public class DashMpdParser {
dashDoc = downloader.download(streamInfo.getDashMpdUrl());
} catch (IOException ioe) {
throw new DashMpdParsingException("Could not get dash mpd: " + streamInfo.getDashMpdUrl(), ioe);
} catch (ReCaptchaException e) {
throw new ReCaptchaException("reCaptcha Challenge needed");
}
try {

View File

@ -129,7 +129,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
* request See : https://github.com/rg3/youtube-dl/issues/5138
*/
if (con.getResponseCode() == 429) {
throw new ReCaptchaException("reCaptcha Challenge requested");
throw new ReCaptchaException("reCaptcha Challenge requested", con.getURL().toString());
}
throw new IOException(con.getResponseCode() + " " + con.getResponseMessage(), e);