Quote:
Originally Posted by emilio530
I would like to know if i can invoke some function that can help me get that info in a script so i can set a stopmark when the 9kw captcha queue is too high.
|
Quote:
Originally Posted by Jiaz
You could directly query the 9kw api in your script and parse the server response for the queue size.
|
Simple example for high queue:
Code:
// Queue check for 9kw.eu
// Trigger Required: Interval
var newInterval = 10000;
if (interval == newInterval) {
check9kw_queue();
} else {
interval = newInterval;
}
function check9kw_queue() {
var settings_9kw = "org.jdownloader.captcha.v2.solver.solver9kw.Captcha9kwSettings";
var https = callAPI("config", "get", settings_9kw, null, "https");
var servercheck_page = '://www.9kw.eu/grafik/servercheck.json';
var servercheck;
for (var i = 0; i < 3; i++) {
if (https == 1) {
servercheck = getPage("https" + servercheck_page);
} else {
servercheck = getPage("http" + servercheck_page);
}
if (IsValidJSONString(servercheck)) {
var queue = JSON.parse(servercheck).queue;
if (parseInt(queue) > 100) {
//callAPI("downloadsV2", "setStopMark", linkUUID, -1);//Set stop mark on link
//callAPI("downloadsV2", "setStopMark", -1, packageUUID);//Set stop mark on package
setDownloadsPaused(true);
//alert("High queue. " + "(" + queue + ")");
} else {
//callAPI("downloadsV2", "removeStopMark");//Remove stop mark
setDownloadsPaused(false);
}
break;
}
}
}
function IsValidJSONString(str) {
if (typeof str !== "string") {
return false;
}
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
And one example for credits:
Code:
// Check for enough credits (captcha service 9kw.eu)
// Trigger Required: Interval
var newInterval = 30000;
if(interval == newInterval){
check9kw_credits();
}else{
interval = newInterval;
}
function check9kw_credits (){
var settings_9kw = "org.jdownloader.captcha.v2.solver.solver9kw.Captcha9kwSettings";
var apikey = callAPI("config", "get", settings_9kw, null, "ApiKey");
var prio = callAPI("config", "get", settings_9kw, null, "prio");
var confirm = callAPI("config", "get", settings_9kw, null, "confirm");
var https = callAPI("config", "get", settings_9kw, null, "https");
var credits_page = '://www.9kw.eu/index.cgi?action=usercaptchaguthaben&apikey=' + apikey;
var credits;
if (https == 1) {
credits = getPage("https" + credits_page);
} else {
credits = getPage("http" + credits_page);
}
if (credits.match(/^\d+$/)) {
var min_credits = 30;
if (confirm) {
min_credits += 6;
}
if (prio) {
min_credits += parseInt(prio);
}
if (parseInt(credits) < min_credits) {
setDownloadsPaused(true);
//alert("Not enough credits. " + "(" + credits + ")");
}else{
setDownloadsPaused(false);
}
}
}
Another example for 'account missing' and 'skipped - captcha input':
Code:
// Unskip 'account missing' and 'skipped - captcha input' links at user specified interval
// Trigger Required : "Interval"
// Set interval to 3600000 (60 minutes)
var newInterval = 3600000;
if (interval == newInterval) {
check_skipped();
} else {
interval = newInterval;
}
function check_skipped() {
var links = getAllDownloadLinks();
for (i = 0; i < links.length; i++) {
var link = links[i];
if (link.isSkipped()) {
if (link.getSkippedReason() == "CAPTCHA" || link.getSkippedReason() == "NO_ACCOUNT") {
link.setSkipped(false);
}
}
}
}