Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/nya/miku/wishmaster/chans/makaba/MakabaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,23 +456,26 @@ public PostModel[] search(String boardName, String searchRequest, ProgressListen
@Override
public CaptchaModel getNewCaptcha(String boardName, String threadNumber, ProgressListener listener, CancellableTask task) throws Exception {
String response;
String url = domainUrl + "makaba/captcha.fcgi?type=2chaptcha" + (threadNumber != null ? "&action=thread" : "") + ("&board=" + boardName);
JSONObject json;
String url = domainUrl + "api/captcha/2chaptcha/id?" + ("board=" + boardName) + (threadNumber != null ? "&thread" : "") ;
try {
response = HttpStreamer.getInstance().getStringFromUrl(url, HttpRequestModel.DEFAULT_GET, httpClient, null, task, true);
if (task != null && task.isCancelled()) throw new Exception("interrupted");
if (response.startsWith("DISABLED") || response.startsWith("VIP")) {
json = new JSONObject(response);
if (json.getInt("result")==3 || json.getInt("result")==2) {
captchaId = null;
return null;
} else if (!response.startsWith("CHECK")) {
} else if (json.getInt("result")!=1) {
throw new Exception("Invalid captcha response");
}
} catch (HttpWrongStatusCodeException e) {
checkCloudflareError(e, url);
throw e;
}

String id = response.substring(response.indexOf('\n') + 1);
url = domainUrl + "makaba/captcha.fcgi?type=2chaptcha&action=image&id=" + id;
String id = json.getString("id");
url = domainUrl + "api/captcha/2chaptcha/image/" + id;

CaptchaModel captchaModel = downloadCaptcha(url, listener, task);
captchaModel.type = CaptchaModel.TYPE_NORMAL_DIGITS;
captchaId = id;
Expand Down