public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress) throws Exception { synchronized (LOCK) { ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>(); String parameter = param.toString(); br.getPage(parameter); String waittime = br.getRegex("<p>Du musst noch (\\d+) Sekunden warten bis du").getMatch(0); if (waittime != null) { int wait = Integer.parseInt(waittime); if (wait > 80) { logger.warning(wait + " Sekunden Wartezeit: Limit erreicht!"); logger.warning(br.toString()); return null; } sleep(wait * 1001l, param); } for (int i = 0; i <= 5; i++) { PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP"); jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br); rc.parse(); rc.load(); File cf = rc.downloadCaptcha(getLocalCaptchaFile()); String c = getCaptchaCode(cf, param); rc.setCode(c); if (br.containsHTML("(api.recaptcha.net|Das war leider Falsch)")) continue; if (br.containsHTML("das Falsche Captcha eingegeben")) { sleep(60 * 1001l, param); br.getHeaders().put("User-Agent", RandomUserAgent.generate()); br.getPage(parameter); continue; } break; } if (br.containsHTML( "(api.recaptcha.net|Das war leider Falsch|das Falsche Captcha eingegeben)")) throw new DecrypterException(DecrypterException.CAPTCHA); String links[] = br.getRegex("<a href=\"(http.*?)\" target=\"_blank\" onclick=").getColumn(0); if (links == null || links.length == 0) { logger.warning("First LdTTemp regex failed, trying the second one..."); links = HTMLParser.getHttpLinks(br.toString(), ""); } if (links.length == 0) return null; for (String finallink : links) { if (!finallink.contains("iload.to") && !finallink.contains("lof.cc") && !finallink.endsWith(".gif") && !finallink.endsWith(".swf")) decryptedLinks.add(createDownloadlink(finallink)); } return decryptedLinks; } }
public void doFree(DownloadLink downloadLink) throws Exception, PluginException { String passCode = null; boolean resumable = true; int maxchunks = 0; // If the filesize regex above doesn't match you can copy this part into // the available status (and delete it here) Form freeform = br.getFormBySubmitvalue("Kostenloser+Download"); if (freeform == null) { freeform = br.getFormBySubmitvalue("Free+Download"); if (freeform == null) { freeform = br.getFormbyKey("download1"); } } if (freeform != null) { freeform.remove("method_premium"); br.submitForm(freeform); doSomething(); } checkErrors(downloadLink, false, passCode); String md5hash = new Regex(brbefore, "<b>MD5.*?</b>.*?nowrap>(.*?)<").getMatch(0); if (md5hash != null) { md5hash = md5hash.trim(); logger.info("Found md5hash: " + md5hash); downloadLink.setMD5Hash(md5hash); } br.setFollowRedirects(false); Form DLForm = br.getFormbyProperty("name", "F1"); if (DLForm == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); // Ticket Time String ttt = new Regex(brbefore, "countdown\">.*?(\\d+).*?</span>").getMatch(0); if (ttt == null) ttt = new Regex(brbefore, "id=\"countdown_str\".*?<span id=\".*?\">.*?(\\d+).*?</span") .getMatch(0); if (ttt != null) { logger.info("Waittime detected, waiting " + ttt + " seconds from now on..."); int tt = Integer.parseInt(ttt); sleep(tt * 1001, downloadLink); } boolean password = false; boolean recaptcha = false; if (brbefore.contains(PASSWORDTEXT0) || brbefore.contains(PASSWORDTEXT1)) { password = true; logger.info("The downloadlink seems to be password protected."); } /* Captcha START */ if (brbefore.contains(";background:#ccc;text-align")) { logger.info("Detected captcha method \"plaintext captchas\" for this host"); // Captcha method by ManiacMansion String[][] letters = new Regex( Encoding.htmlDecode(br.toString()), "<span style='position:absolute;padding-left:(\\d+)px;padding-top:\\d+px;'>(\\d)</span>") .getMatches(); if (letters == null || letters.length == 0) { logger.warning("plaintext captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } SortedMap<Integer, String> capMap = new TreeMap<Integer, String>(); for (String[] letter : letters) { capMap.put(Integer.parseInt(letter[0]), letter[1]); } StringBuilder code = new StringBuilder(); for (String value : capMap.values()) { code.append(value); } DLForm.put("code", code.toString()); logger.info( "Put captchacode " + code.toString() + " obtained by captcha metod \"plaintext captchas\" in the form."); } else if (brbefore.contains("/captchas/")) { logger.info("Detected captcha method \"Standard captcha\" for this host"); String[] sitelinks = HTMLParser.getHttpLinks(br.toString(), null); String captchaurl = null; if (sitelinks == null || sitelinks.length == 0) { logger.warning("Standard captcha captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } for (String link : sitelinks) { if (link.contains("/captchas/")) { captchaurl = link; break; } } if (captchaurl == null) { logger.warning("Standard captcha captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } String code = getCaptchaCode(captchaurl, downloadLink); DLForm.put("code", code); logger.info( "Put captchacode " + code + " obtained by captcha metod \"Standard captcha\" in the form."); } else if (brbefore.contains("api.recaptcha.net")) { // Some hosters also got commentfields with captchas, therefore is // the !br.contains...check Exampleplugin: // FileGigaCom logger.info("Detected captcha method \"Re Captcha\" for this host"); PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP"); jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br); rc.parse(); rc.load(); File cf = rc.downloadCaptcha(getLocalCaptchaFile()); String c = getCaptchaCode(cf, downloadLink); if (password) { passCode = handlePassword(passCode, rc.getForm(), downloadLink); } recaptcha = true; rc.setCode(c); logger.info( "Put captchacode " + c + " obtained by captcha metod \"Re Captcha\" in the form and submitted it."); } /* Captcha END */ // If the hoster uses Re Captcha the form has already been sent before // here so here it's checked. Most hosters don't use Re Captcha so // usually recaptcha is false if (!recaptcha) { if (password) { passCode = handlePassword(passCode, DLForm, downloadLink); } dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, DLForm, resumable, maxchunks); logger.info("Submitted DLForm"); } if (dl.getConnection().getContentType().contains("html")) { br.followConnection(); logger.info("followed connection..."); doSomething(); checkErrors(downloadLink, true, passCode); String dllink = getDllink(); if (dllink == null) { logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } logger.info("Final downloadlink = " + dllink + " starting the download..."); dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, resumable, maxchunks); if (dl.getConnection().getContentType().contains("html")) { logger.warning("The final dllink seems not to be a file!"); br.followConnection(); checkServerErrors(); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } } if (passCode != null) { downloadLink.setProperty("pass", passCode); } dl.startDownload(); }
@Override public void handleFree(DownloadLink downloadLink) throws Exception, PluginException { boolean resumable = false; int maxchunks = 1; requestFileInformation(downloadLink); // If the filesize regex above doesn't match you can copy this part into // the available status (and delete it here) Form freeform = br.getFormBySubmitvalue("Kostenloser+Download"); if (freeform == null) { freeform = br.getFormBySubmitvalue("Free+Download"); if (freeform == null) { freeform = br.getFormbyKey("download1"); } } if (freeform != null) br.submitForm(freeform); /* Errorhandling START */ // Handling for only-premium links if (br.containsHTML( "(You can download files up to.*?only|Upgrade your account to download bigger files)")) { String filesizelimit = br.getRegex("You can download files up to(.*?)only").getMatch(0); if (filesizelimit != null) { filesizelimit = filesizelimit.trim(); logger.warning("As free user you can download files up to " + filesizelimit + " only"); throw new PluginException( LinkStatus.ERROR_FATAL, "Free users can only download files up to " + filesizelimit); } else { logger.warning("Only downloadable via premium"); throw new PluginException(LinkStatus.ERROR_FATAL, "Only downloadable via premium"); } } if (br.containsHTML("This file reached max downloads")) { throw new PluginException(LinkStatus.ERROR_FATAL, "This file reached max downloads"); } if (br.containsHTML("You have to wait")) { int minutes = 0, seconds = 0, hours = 0; String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0); if (tmphrs != null) hours = Integer.parseInt(tmphrs); String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0); if (tmpmin != null) minutes = Integer.parseInt(tmpmin); String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0); if (tmpsec != null) seconds = Integer.parseInt(tmpsec); int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000; logger.info("Detected waittime #1, waiting " + waittime + "milliseconds"); throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime); } if (br.containsHTML("You have reached the download-limit")) { String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0); String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0); String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0); if (tmphrs == null && tmpmin == null && tmpsec == null) { throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 60 * 60 * 1000l); } else { int minutes = 0, seconds = 0, hours = 0; if (tmphrs != null) hours = Integer.parseInt(tmphrs); if (tmpmin != null) minutes = Integer.parseInt(tmpmin); if (tmpsec != null) seconds = Integer.parseInt(tmpsec); int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000; logger.info("Detected waittime #2, waiting " + waittime + "milliseconds"); throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime); } } /* Errorhandling END */ String md5hash = br.getRegex("<b>MD5.*?</b>.*?nowrap>(.*?)<").getMatch(0); if (md5hash != null) { md5hash = md5hash.trim(); logger.info("Found md5hash: " + md5hash); downloadLink.setMD5Hash(md5hash); } br.setFollowRedirects(false); Form DLForm = br.getFormbyProperty("name", "F1"); if (DLForm == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); // Ticket Time String ttt = br.getRegex("countdown\">.*?(\\d+).*?</span>").getMatch(0); if (ttt != null) { logger.info("Waittime detected, waiting " + ttt.trim() + " seconds from now on..."); int tt = Integer.parseInt(ttt); sleep(tt * 1001, downloadLink); } String passCode = null; boolean password = false; boolean recaptcha = false; if (br.containsHTML("(<b>Passwort:</b>|<b>Password:</b>)")) { password = true; logger.info("The downloadlink seems to be password protected."); } /* Captcha START */ if (br.containsHTML("background:#ccc;text-align")) { logger.info("Detected captcha method \"plaintext captchas\" for this host"); // Captcha method by ManiacMansion String[][] letters = new Regex( Encoding.htmlDecode(br.toString()), "<span style='position:absolute;padding-left:(\\d+)px;padding-top:\\d+px;'>(\\d)</span>") .getMatches(); if (letters == null || letters.length == 0) { logger.warning("plaintext captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } SortedMap<Integer, String> capMap = new TreeMap<Integer, String>(); for (String[] letter : letters) { capMap.put(Integer.parseInt(letter[0]), letter[1]); } StringBuilder code = new StringBuilder(); for (String value : capMap.values()) { code.append(value); } DLForm.put("code", code.toString()); logger.info( "Put captchacode " + code.toString() + " obtained by captcha metod \"plaintext captchas\" in the form."); } else if (br.containsHTML("/captchas/")) { logger.info("Detected captcha method \"Standard captcha\" for this host"); String[] sitelinks = HTMLParser.getHttpLinks(br.toString(), null); String captchaurl = null; if (sitelinks == null || sitelinks.length == 0) { logger.warning("Standard captcha captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } for (String link : sitelinks) { if (link.contains("/captchas/")) { captchaurl = link; break; } } if (captchaurl == null) { logger.warning("Standard captcha captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } String code = getCaptchaCode(captchaurl, downloadLink); DLForm.put("code", code); logger.info( "Put captchacode " + code + " obtained by captcha metod \"Standard captcha\" in the form."); } else if (br.containsHTML("api.recaptcha.net") && !br.containsHTML( "api\\.recaptcha\\.net.*?<Textarea.*?<input type=\"submit\" value.*?</Form>")) { // Some hosters also got commentfields with captchas, therefore is // the !br.contains...check Exampleplugin: // FileGigaCom logger.info("Detected captcha method \"Re Captcha\" for this host"); PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP"); jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br); rc.parse(); rc.load(); File cf = rc.downloadCaptcha(getLocalCaptchaFile()); String c = getCaptchaCode(cf, downloadLink); if (password == true) { if (downloadLink.getStringProperty("pass", null) == null) { passCode = getUserInput(null, downloadLink); } else { /* gespeicherten PassCode holen */ passCode = downloadLink.getStringProperty("pass", null); } rc.getForm().put("password", passCode); logger.info("Put password \"" + passCode + "\" entered by user in the DLForm."); password = false; } recaptcha = true; rc.setCode(c); logger.info( "Put captchacode " + c + " obtained by captcha metod \"Re Captcha\" in the form and submitted it."); } /* Captcha END */ // If the hoster uses Re Captcha the form has already been sent before // here so here it's checked. Most hosters don't use Re Captcha so // usually recaptcha is false if (recaptcha == false) { if (password == true) { if (downloadLink.getStringProperty("pass", null) == null) { passCode = getUserInput(null, downloadLink); } else { /* gespeicherten PassCode holen */ passCode = downloadLink.getStringProperty("pass", null); } DLForm.put("password", passCode); logger.info("Put password \"" + passCode + "\" entered by user in the DLForm."); } jd.plugins.BrowserAdapter.openDownload(br, downloadLink, DLForm, resumable, maxchunks); logger.info("Submitted DLForm"); } boolean error = false; try { if (dl.getConnection().getContentType().contains("html")) { error = true; } } catch (Exception e) { error = true; } if (br.getRedirectLocation() != null || error == true) { br.followConnection(); logger.info("followed connection..."); String dllink = br.getRedirectLocation(); if (dllink == null) { if (br.containsHTML("You have to wait")) { int minutes = 0, seconds = 0, hours = 0; String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0); if (tmphrs != null) hours = Integer.parseInt(tmphrs); String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0); if (tmpmin != null) minutes = Integer.parseInt(tmpmin); String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0); if (tmpsec != null) seconds = Integer.parseInt(tmpsec); int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000; logger.info("Detected waittime #1, waiting " + waittime + "milliseconds"); throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime); } if (br.containsHTML("You have reached the download-limit")) { String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0); String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0); String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0); if (tmphrs == null && tmpmin == null && tmpsec == null) { throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 60 * 60 * 1000l); } else { int minutes = 0, seconds = 0, hours = 0; if (tmphrs != null) hours = Integer.parseInt(tmphrs); if (tmpmin != null) minutes = Integer.parseInt(tmpmin); if (tmpsec != null) seconds = Integer.parseInt(tmpsec); int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000; logger.info("Detected waittime #2, waiting " + waittime + "milliseconds"); throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime); } } if (br.containsHTML("You're using all download slots for IP")) throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 10 * 60 * 1001l); if (br.containsHTML("(<b>Passwort:</b>|<b>Password:</b>|Wrong password)")) { logger.warning( "Wrong password, the entered password \"" + passCode + "\" is wrong, retrying..."); downloadLink.setProperty("pass", null); throw new PluginException(LinkStatus.ERROR_RETRY); } if (br.containsHTML("Wrong captcha")) { logger.warning("Wrong captcha or wrong password!"); throw new PluginException(LinkStatus.ERROR_CAPTCHA); } if (dllink == null) { dllink = br.getRegex("dotted #bbb;padding.*?<a href=\"(.*?)\"").getMatch(0); if (dllink == null) { dllink = br.getRegex("This direct link will be available for your IP.*?href=\"(http.*?)\"") .getMatch(0); if (dllink == null) { // This was for fileop.com, maybe also works for // others! dllink = br.getRegex("Download: <a href=\"(.*?)\"").getMatch(0); } } } } if (dllink == null) { logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } logger.info("Final downloadlink = " + dllink + " starting the download..."); jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, resumable, maxchunks); } if (passCode != null) { downloadLink.setProperty("pass", passCode); } boolean error2 = false; try { if (dl.getConnection().getContentType().contains("html")) { error2 = true; } } catch (Exception e) { error2 = true; } if (error2 == true) { logger.warning("The final dllink seems not to be a file!"); br.followConnection(); if (br.containsHTML("File Not Found")) { logger.warning("Server says link offline, please recheck that!"); throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } dl.startDownload(); }
@SuppressWarnings("unchecked") private void login(Account account, boolean showCaptcha, boolean doCheck) throws Exception { synchronized (LOCK) { try { /** Load cookies */ br.setCookiesExclusive(true); br.setCookie(COOKIE_HOST, "lang", "english"); final Object ret = account.getProperty("cookies", null); boolean refreshCookies = true; boolean acmatch = Encoding.urlEncode(account.getUser()) .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser()))); if (acmatch) acmatch = Encoding.urlEncode(account.getPass()) .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass()))); if (acmatch && ret != null && ret instanceof HashMap<?, ?>) { final HashMap<String, String> cookies = (HashMap<String, String>) ret; if (account.isValid()) { for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) { final String key = cookieEntry.getKey(); final String value = cookieEntry.getValue(); this.br.setCookie(COOKIE_HOST, key, value); } if (doCheck) { br.getPage(COOKIE_HOST + "/?op=my_account"); doSomething(); if ((br.getCookie(COOKIE_HOST, "login")) == null || br.getCookie(COOKIE_HOST, "xfss") == null) { /* cookies are no longer valid, refresh them */ refreshCookies = true; } else { /* cookies are still okay, no need to refresh */ refreshCookies = false; } } else { /* no doCheck */ return; } } } if (refreshCookies) { /* fresh login = new cookies */ br.getPage(COOKIE_HOST + "/login.html"); Form loginform = br.getForm(0); if (loginform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); loginform.put("login", Encoding.urlEncode(account.getUser())); loginform.put("password", Encoding.urlEncode(account.getPass())); if (br.containsHTML("RecaptchaOptions")) { /* too many logins result in recaptcha login */ if (showCaptcha == false) { AccountInfo ai = account.getAccountInfo(); if (ai != null) { ai.setStatus("Logout/Login in Browser please!"); } throw new PluginException( LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE); } else { /* recaptcha needed */ PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP"); jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br); rc.setForm(loginform); String id = this.br.getRegex("\\?k=([A-Za-z0-9%_\\+\\- ]+)\"").getMatch(0); rc.setId(id); rc.load(); File cf = rc.downloadCaptcha(getLocalCaptchaFile()); DownloadLink dummyLink = new DownloadLink(null, "Account", "easybytez.com", "http://easybytez.com", true); String c = getCaptchaCode(cf, dummyLink); rc.setCode(c); } } else { /* no recaptcha needed */ br.submitForm(loginform); } } if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null) throw new PluginException( LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE); if (refreshCookies) { /* we have to fetch my_account page again */ br.getPage(COOKIE_HOST + "/?op=my_account"); doSomething(); } if (!new Regex( BRBEFORE, "(Premium\\-Account expire|/\\?op=payments\">Get Premium<|>Renew premium<)") .matches()) throw new PluginException( LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE); if (!new Regex(BRBEFORE, "(Premium\\-Account expire|>Renew premium<)").matches()) { account.setProperty("nopremium", true); } else { account.setProperty("nopremium", false); } /** Save cookies */ final HashMap<String, String> cookies = new HashMap<String, String>(); final Cookies add = this.br.getCookies(COOKIE_HOST); for (final Cookie c : add.getCookies()) { cookies.put(c.getKey(), c.getValue()); } account.setProperty("name", Encoding.urlEncode(account.getUser())); account.setProperty("pass", Encoding.urlEncode(account.getPass())); account.setProperty("cookies", cookies); } catch (PluginException e) { account.setProperty("cookies", null); throw e; } } }