*Plugins: Fixes/Changes/Maintenance*

- FileCryptCc: removed duplicated code
- TeraboxComFolder: updated pattern: some links containing file/subfolder-path crawled all URLs while the plugin should've only crawled a specific file or subfolder

git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@49840 ebf7c1c2-ba36-0410-9fe8-c592906822b4

Former-commit-id: f537970f69bb68ed3b6ded135caaa7fcd1f9aea6
This commit is contained in:
psp 2024-09-23 13:09:37 +00:00
parent 9414221f52
commit c490750feb
2 changed files with 28 additions and 34 deletions

View File

@ -562,7 +562,7 @@ public class FileCryptCc extends PluginForDecrypt {
throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, "Failed to find captchaForm");
}
final String captchaURL = captchaForm.getRegex("((https?://[^<>\"']*?)?/captcha/[^<>\"']*?)\"").getMatch(0);
if (captchaURL != null && captchaURL.contains("circle.php")) {
if (captchaURL != null && this.containsCircleCaptcha(captchaURL)) {
/* Click-captcha */
final File file = this.getLocalCaptchaFile();
getCaptchaBrowser(br).getDownload(file, captchaURL);
@ -786,8 +786,8 @@ public class FileCryptCc extends PluginForDecrypt {
}
}
private final boolean containsCircleCaptcha(final String html) {
if (html.contains("circle.php")) {
private final boolean containsCircleCaptcha(final String str) {
if (StringUtils.containsIgnoreCase(str, "circle.php")) {
return true;
} else {
return false;

View File

@ -22,6 +22,12 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
import org.appwork.storage.TypeRef;
import org.appwork.utils.StringUtils;
import org.appwork.utils.Time;
import org.appwork.utils.parser.UrlQuery;
import org.jdownloader.scripting.JavaScriptEngineFactory;
import jd.PluginWrapper;
import jd.controlling.AccountController;
import jd.controlling.ProgressController;
@ -41,12 +47,6 @@ import jd.plugins.PluginForDecrypt;
import jd.plugins.PluginForHost;
import jd.plugins.hoster.TeraboxCom;
import org.appwork.storage.TypeRef;
import org.appwork.utils.StringUtils;
import org.appwork.utils.Time;
import org.appwork.utils.parser.UrlQuery;
import org.jdownloader.scripting.JavaScriptEngineFactory;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 3, names = {}, urls = {})
public class TeraboxComFolder extends PluginForDecrypt {
public TeraboxComFolder(PluginWrapper wrapper) {
@ -83,7 +83,7 @@ public class TeraboxComFolder extends PluginForDecrypt {
public static String[] buildAnnotationUrls(final List<String[]> pluginDomains) {
final List<String> ret = new ArrayList<String>();
for (final String[] domains : pluginDomains) {
ret.add("https?://(?:www\\.)?" + buildHostsPatternPart(domains) + "/(web/share/(?:init|link|filelist)\\?surl=[A-Za-z0-9\\-_]+(\\&path=[^/]+)?|web/share/videoPlay\\?surl=[A-Za-z0-9\\-_]+\\&dir=[^\\&]+|s/[A-Za-z0-9\\-_]+|(?:[a-z0-9]+/)?sharing/link\\?surl=[A-Za-z0-9\\-_]+)");
ret.add("https?://(?:www\\.)?" + buildHostsPatternPart(domains) + "/(web/share/(?:init|link|filelist)\\?surl=[A-Za-z0-9\\-_]+.*|web/share/videoPlay\\?surl=[A-Za-z0-9\\-_]+\\&dir=[^\\&]+|s/[A-Za-z0-9\\-_]+|(?:[a-z0-9]+/)?sharing/link\\?surl=[A-Za-z0-9\\-_]+.*)");
}
return ret.toArray(new String[0]);
}
@ -110,10 +110,10 @@ public class TeraboxComFolder extends PluginForDecrypt {
br.setCookie(host, "BOXCLND", passwordCookie);
}
private static final String TYPE_SHORT = "(?i)https?://[^/]+/s/(.+)";
private static final String TYPE_SHORT_NEW = "(?i)https?://[^/]+/(?:[a-z0-9]+/)?sharing/link\\?surl=([A-Za-z0-9\\-_]+)";
private static final Pattern TYPE_SHORT = Pattern.compile("https?://[^/]+/s/(.+)", Pattern.CASE_INSENSITIVE);
private static final Pattern TYPE_SHORT_NEW = Pattern.compile("https?://[^/]+/(?:[a-z0-9]+/)?sharing/link\\?surl=([A-Za-z0-9\\-_]+).*", Pattern.CASE_INSENSITIVE);
/* For such URLs leading to single files we'll crawl all items of the folder that file is in -> Makes it easier */
private static final String TYPE_SINGLE_VIDEO = "(?i)https?://[^/]+/web/share/videoPlay\\?surl=([A-Za-z0-9\\-_]+)\\&dir=([^\\&]+)";
private static final Pattern TYPE_SINGLE_VIDEO = Pattern.compile("https?://[^/]+/web/share/videoPlay\\?surl=([A-Za-z0-9\\-_]+)\\&dir=([^\\&]+)", Pattern.CASE_INSENSITIVE);
private static final AtomicLong anonymousJstokenTimestamp = new AtomicLong(-1);
private static AtomicReference<String> anonymousJstoken = new AtomicReference<String>(null);
@ -131,22 +131,17 @@ public class TeraboxComFolder extends PluginForDecrypt {
contenturl = contenturl.replaceFirst(Pattern.quote(domainOfAddedURL) + "/", getHost() + "/");
}
final UrlQuery paramsOfAddedURL = UrlQuery.parse(contenturl);
String surl;
String surl = null;
String preGivenPath = null;
if (contenturl.matches(TYPE_SHORT)) {
if (new Regex(contenturl, TYPE_SHORT).patternFind()) {
surl = new Regex(contenturl, TYPE_SHORT).getMatch(0);
} else if (contenturl.matches(TYPE_SHORT_NEW)) {
surl = new Regex(param.getCryptedUrl(), TYPE_SHORT_NEW).getMatch(0);
} else if (contenturl.matches(TYPE_SINGLE_VIDEO)) {
surl = paramsOfAddedURL.get("surl");
preGivenPath = paramsOfAddedURL.get("dir");
} else {
surl = paramsOfAddedURL.get("surl");
}
preGivenPath = paramsOfAddedURL.get("dir");
if (preGivenPath == null) {
preGivenPath = paramsOfAddedURL.get("path");
}
}
if (surl == null) {
/* Developer mistake */
throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
@ -336,17 +331,16 @@ public class TeraboxComFolder extends PluginForDecrypt {
logger.info("Assume that this folder is offline");
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
}
final List<Object> ressourcelist = (List<Object>) entries.get("list");
final List<Map<String, Object>> ressourcelist = (List<Map<String, Object>>) entries.get("list");
if (ressourcelist.isEmpty()) {
logger.info("Stopping because: Current page doesn't contain any items");
break;
}
for (final Object ressourceO : ressourcelist) {
entries = (Map<String, Object>) ressourceO;
final String path = (String) entries.get("path");
for (final Map<String, Object> ressource : ressourcelist) {
final String path = (String) ressource.get("path");
/* 2021-04-14: 'category' is represented as a String. */
final long category = JavaScriptEngineFactory.toLong(entries.get("category"), -1);
if (JavaScriptEngineFactory.toLong(entries.get("isdir"), -1) == 1) {
final long category = JavaScriptEngineFactory.toLong(ressource.get("category"), -1);
if (JavaScriptEngineFactory.toLong(ressource.get("isdir"), -1) == 1) {
/* Folder */
final String url = "https://www." + this.getHost() + "/web/share/link?surl=" + surl + "&path=" + Encoding.urlEncode(path);
final DownloadLink folder = this.createDownloadlink(url);
@ -360,12 +354,12 @@ public class TeraboxComFolder extends PluginForDecrypt {
ret.add(folder);
} else {
/* File */
final String serverfilename = (String) entries.get("server_filename");
final String serverfilename = (String) ressource.get("server_filename");
// final long fsid = JavaScriptEngineFactory.toLong(entries.get("fs_id"), -1);
final String fsidStr = Long.toString(JavaScriptEngineFactory.toLong(entries.get("fs_id"), -1));
final String fsidStr = Long.toString(JavaScriptEngineFactory.toLong(ressource.get("fs_id"), -1));
final String realpath;
if (path.endsWith("/" + serverfilename)) {
realpath = path.replaceFirst("/" + org.appwork.utils.Regex.escape(serverfilename) + "$", "");
realpath = path.replaceFirst("/" + Pattern.quote(serverfilename) + "$", "");
} else {
realpath = path;
}
@ -385,7 +379,7 @@ public class TeraboxComFolder extends PluginForDecrypt {
}
final DownloadLink dl = new DownloadLink(plg, "dubox", this.getHost(), url, true);
dl.setContentUrl(contentURL);
TeraboxCom.parseFileInformation(dl, entries);
TeraboxCom.parseFileInformation(dl, ressource);
if (passCode != null) {
dl.setDownloadPassword(passCode);
}