예제 #1
0
  public void doFree(final DownloadLink downloadLink, final Account account) throws Exception {
    logger.info("Free mode");
    checkShowFreeDialog();
    String currentIP = getIP();
    try {
      workAroundTimeOut(br);
      String id = getID(downloadLink);
      br.setFollowRedirects(false);
      br.setCookie("http://cloudzer.net/", "lang", "de");
      br.getPage("http://cloudzer.net/language/de");
      if (br.containsHTML("<title>[^<].*?\\- Wartungsarbeiten</title>"))
        throw new PluginException(
            LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE, "ServerMaintenance", 10 * 60 * 1000);

      /**
       * Reconnect handling to prevent having to enter a captcha just to see that a limit has been
       * reached
       */
      logger.info("New Download: currentIP = " + currentIP);
      if (hasDled.get() && ipChanged(currentIP, downloadLink) == false) {
        long result = System.currentTimeMillis() - timeBefore.get();
        if (result < RECONNECTWAIT && result > 0)
          throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, RECONNECTWAIT - result);
      }

      br.getPage("http://cloudzer.net/file/" + id);
      if (br.getRedirectLocation() != null && br.getRedirectLocation().contains("/404")) {
        throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
      }
      if (br.getRedirectLocation() != null) br.getPage(br.getRedirectLocation());
      if (br.containsHTML(
          ">Sie haben die max\\. Anzahl an Free\\-Downloads f\\&#252;r diese Stunde erreicht"))
        throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 60 * 60 * 1001l);
      String passCode = null;
      if (br.containsHTML("<h2>Authentifizierung</h2>")) {
        passCode = getPassword(downloadLink);
        Form form = br.getForm(0);
        form.put("pw", Encoding.urlEncode(passCode));
        br.submitForm(form);
        if (br.containsHTML("<h2>Authentifizierung</h2>")) {
          downloadLink.setProperty("pass", null);
          throw new PluginException(LinkStatus.ERROR_RETRY, "Password wrong!");
        }
        downloadLink.setProperty("pass", passCode);
      }
      final Browser brc = br.cloneBrowser();
      brc.getPage("http://cloudzer.net/js/download.js");
      final String rcID = brc.getRegex("Recaptcha\\.create\\(\"([^<>\"]*?)\"").getMatch(0);
      String wait =
          br.getRegex("Aktuelle Wartezeit: <span>(\\d+)</span> Sekunden</span>").getMatch(0);
      if (rcID == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      if (wait == null) {
        wait = "30";
      }
      br.getHeaders().put("X-Requested-With", "XMLHttpRequest");
      br.postPage("http://cloudzer.net/io/ticket/slot/" + getID(downloadLink), "");
      if (!br.containsHTML("\"succ\":true"))
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      final long timebefore = System.currentTimeMillis();
      final PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
      jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
      rc.setId(rcID);
      rc.load();
      for (int i = 0; i <= 5; i++) {
        File cf = rc.downloadCaptcha(getLocalCaptchaFile());
        String c = getCaptchaCode(cf, downloadLink);
        int passedTime = (int) ((System.currentTimeMillis() - timebefore) / 1000) - 1;
        if (i == 0 && passedTime < Integer.parseInt(wait)) {
          sleep((Integer.parseInt(wait) - passedTime) * 1001l, downloadLink);
        }
        br.postPage(
            "http://cloudzer.net/io/ticket/captcha/" + getID(downloadLink),
            "recaptcha_challenge_field=" + rc.getChallenge() + "&recaptcha_response_field=" + c);
        if (br.containsHTML("\"err\":\"captcha\"")) {
          try {
            invalidateLastChallengeResponse();
          } catch (final Throwable e) {
          }
          rc.reload();
          continue;
        } else {
          try {
            validateLastChallengeResponse();
          } catch (final Throwable e) {
          }
        }
        break;
      }
      generalFreeErrorhandling(account);
      if (br.containsHTML("err\":\"Ticket kann nicht"))
        throw new PluginException(
            LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError", 30 * 60 * 1000l);
      if (br.containsHTML("err\":\"Leider sind derzeit all unsere"))
        throw new PluginException(
            LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
            "No free Downloadslots available",
            15 * 60 * 1000l);
      if (br.containsHTML("limit\\-parallel"))
        throw new PluginException(
            LinkStatus.ERROR_IP_BLOCKED, "You're already downloading", RECONNECTWAIT);
      if (br.containsHTML("welche von Free\\-Usern gedownloadet werden kann"))
        throw new PluginException(
            LinkStatus.ERROR_FATAL,
            "Only Premium users are allowed to download files lager than 1,00 GB.");
      if (br.containsHTML("\"err\":\"Das Verteilen dieser Datei ist vermutlich nicht erlaubt"))
        throw new PluginException(LinkStatus.ERROR_FATAL, "Link abused, download not possible!");
      String url = br.getRegex("\"url\":\\s*?\"(.*?dl\\\\/.*?)\"").getMatch(0);
      if (url == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      url = url.replaceAll("\\\\/", "/");
      dl = BrowserAdapter.openDownload(br, downloadLink, url, false, 1);
      try {
        /* remove next major update */
        /* workaround for broken timeout in 0.9xx public */
        ((RAFDownload) dl).getRequest().setConnectTimeout(30000);
        ((RAFDownload) dl).getRequest().setReadTimeout(60000);
      } catch (final Throwable ee) {
      }
      if (!dl.getConnection().isContentDisposition()) {
        try {
          br.followConnection();
        } catch (final Throwable e) {
          logger.severe(e.getMessage());
        }
        logger.info(br.toString());
        if (dl.getConnection().getResponseCode() == 404) {
          throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
        }
        generalFreeErrorhandling(account);
        if (br.containsHTML("please try again in an hour or purchase one of our"))
          throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, RECONNECTWAIT);
        if (dl.getConnection().getResponseCode() == 508)
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError(508)", 30 * 60 * 1000l);
        if (br.containsHTML("try again later"))
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError", 30 * 60 * 1000l);
        if (br.containsHTML("All of our free\\-download capacities are"))
          throw new PluginException(
              LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
              "All of our free-download capacities are exhausted currently",
              10 * 60 * 1000l);
        if (br.containsHTML("File not found!"))
          throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
        if (br.getURL().contains("view=error"))
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError", 10 * 60 * 1000l);
        if (br.containsHTML("Aus technischen Gr")
            && br.containsHTML("ist ein Download momentan nicht m"))
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError", 30 * 60 * 1000l);
        if ("No htmlCode read".equalsIgnoreCase(br.toString()))
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError", 30 * 60 * 1000l);
        if (br.containsHTML("Datei herunterladen")) {
          /*
           * we get fresh entry page after clicking download, means we have to start from beginning
           */
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Serverproblem", 5 * 60 * 1000l);
        }
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      }
      if (dl.getConnection().getResponseCode() == 404) {
        br.followConnection();
        throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
      }
      if (account != null) account.setProperty("LASTDOWNLOAD", System.currentTimeMillis());
      dl.startDownload();
      hasDled.set(true);
    } catch (Exception e) {
      hasDled.set(false);
      throw e;
    } finally {
      timeBefore.set(System.currentTimeMillis());
      setIP(currentIP, downloadLink, account);
    }
  }
예제 #2
0
 public void doFree(
     DownloadLink downloadLink, boolean resumable, int maxchunks, String directlinkproperty)
     throws Exception, PluginException {
   String passCode = null;
   // First, bring up saved final links
   String dllink = checkDirectLink(downloadLink, directlinkproperty);
   // Second, check for streaming links on the first page
   if (dllink == null) dllink = getDllink();
   // Third, continue like normal.
   if (dllink == null) {
     checkErrors(downloadLink, false, passCode);
     if (correctedBR.contains("\"download1\"")) {
       postPage(
           br.getURL(),
           "op=download1&usr_login=&id="
               + new Regex(downloadLink.getDownloadURL(), "/([A-Za-z0-9]{12})$").getMatch(0)
               + "&fname="
               + Encoding.urlEncode(downloadLink.getStringProperty("plainfilename"))
               + "&referer=&method_free=Free+Download");
       checkErrors(downloadLink, false, passCode);
     }
     dllink = getDllink();
   }
   if (dllink == null) {
     Form dlForm = br.getFormbyProperty("name", "F1");
     if (dlForm == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     // how many forms deep do you want to try.
     int repeat = 4;
     for (int i = 1; i <= repeat; i++) {
       dlForm.remove(null);
       final long timeBefore = System.currentTimeMillis();
       boolean password = false;
       boolean skipWaittime = false;
       if (new Regex(correctedBR, PASSWORDTEXT).matches()) {
         password = true;
         logger.info("The downloadlink seems to be password protected.");
       }
       // md5 can be on the subquent pages
       if (downloadLink.getMD5Hash() == null) {
         String md5hash = new Regex(correctedBR, "<b>MD5.*?</b>.*?nowrap>(.*?)<").getMatch(0);
         if (md5hash != null) downloadLink.setMD5Hash(md5hash.trim());
       }
       /* Captcha START */
       if (new Regex(correctedBR, "(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")
           .matches()) {
         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.setForm(dlForm);
         String id = new Regex(correctedBR, "\\?k=([A-Za-z0-9%_\\+\\- ]+)\"").getMatch(0);
         rc.setId(id);
         rc.load();
         File cf = rc.downloadCaptcha(getLocalCaptchaFile());
         String c = getCaptchaCode(cf, downloadLink);
         Form rcform = rc.getForm();
         rcform.put("recaptcha_challenge_field", rc.getChallenge());
         rcform.put("recaptcha_response_field", Encoding.urlEncode(c));
         logger.info(
             "Put captchacode "
                 + c
                 + " obtained by captcha metod \"Re Captcha\" in the form and submitted it.");
         dlForm = rc.getForm();
         /** wait time is often skippable for reCaptcha handling */
         skipWaittime = true;
       } else if (correctedBR.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 (correctedBR.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("xfilesharingprobasic", captchaurl, downloadLink);
         dlForm.put("code", code);
         logger.info(
             "Put captchacode "
                 + code
                 + " obtained by captcha metod \"Standard captcha\" in the form.");
       }
       /* Captcha END */
       if (password) passCode = handlePassword(passCode, dlForm, downloadLink);
       if (!skipWaittime) waitTime(timeBefore, downloadLink);
       sendForm(dlForm);
       logger.info("Submitted DLForm");
       checkErrors(downloadLink, true, passCode);
       dllink = getDllink();
       if (dllink == null
           && (!br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"") || i == repeat)) {
         logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!");
         throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       } else if (dllink == null
           && br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"")) {
         dlForm = br.getFormbyProperty("name", "F1");
         continue;
       } else break;
     }
   }
   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();
     correctBR();
     checkServerErrors();
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   downloadLink.setProperty(directlinkproperty, dllink);
   if (passCode != null) downloadLink.setProperty("pass", passCode);
   try {
     // add a download slot
     controlFree(+1);
     // start the dl
     dl.startDownload();
   } finally {
     // remove download slot
     controlFree(-1);
   }
 }
예제 #3
0
 @SuppressWarnings("unused")
 public void doFree(
     final DownloadLink downloadLink,
     final boolean resumable,
     final int maxchunks,
     final String directlinkproperty)
     throws Exception, PluginException {
   br.setFollowRedirects(false);
   passCode = downloadLink.getStringProperty("pass");
   /* First, bring up saved final links */
   String dllink = checkDirectLink(downloadLink, directlinkproperty);
   /* Second, check for streaming/direct links on the first page */
   if (dllink == null) {
     dllink = getDllink();
   }
   /* Third, do they provide video hosting? */
   if (dllink == null && VIDEOHOSTER) {
     try {
       logger.info("Trying to get link via vidembed");
       final Browser brv = br.cloneBrowser();
       brv.getPage("/vidembed-" + fuid);
       dllink = brv.getRedirectLocation();
       if (dllink == null) {
         logger.info("Failed to get link via vidembed");
       } else {
         logger.info("Successfully found link via vidembed");
       }
     } catch (final Throwable e) {
       logger.info("Failed to get link via vidembed");
     }
   }
   if (dllink == null && VIDEOHOSTER_2) {
     try {
       logger.info("Trying to get link via embed");
       final String embed_access =
           "http://" + COOKIE_HOST.replace("http://", "") + "/embed-" + fuid + ".html";
       this.postPage(
           embed_access,
           "op=video_embed3&usr_login=&id2="
               + fuid
               + "&fname="
               + Encoding.urlEncode(downloadLink.getName())
               + "&referer=&file_code="
               + fuid
               + "&method_free=Click+here+to+watch+the+Video");
       // brv.getPage("http://grifthost.com/embed-" + fuid + ".html");
       dllink = getDllink();
       if (dllink == null) {
         logger.info("Failed to get link via embed");
       } else {
         logger.info("Successfully found link via embed");
       }
     } catch (final Throwable e) {
       logger.info("Failed to get link via embed");
     }
     if (dllink == null) {
       getPage(downloadLink.getDownloadURL());
     }
   }
   /* Fourth, continue like normal */
   if (dllink == null) {
     checkErrors(downloadLink, false);
     final Form download1 = getFormByKey("op", "download1");
     if (download1 != null) {
       download1.remove("method_premium");
       /* stable is lame, issue finding input data fields correctly. eg. closes at ' quotation mark - remove when jd2 goes stable! */
       if (downloadLink.getName().contains("'")) {
         String fname =
             new Regex(br, "<input type=\"hidden\" name=\"fname\" value=\"([^\"]+)\">")
                 .getMatch(0);
         if (fname != null) {
           download1.put("fname", Encoding.urlEncode(fname));
         } else {
           logger.warning("Could not find 'fname'");
           throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
         }
       }
       /* end of backward compatibility */
       sendForm(download1);
       checkErrors(downloadLink, false);
       dllink = getDllink();
     }
   }
   if (dllink == null) {
     Form dlForm = br.getFormbyProperty("name", "F1");
     if (dlForm == null) {
       handlePluginBroken(downloadLink, "dlform_f1_null", 3);
     }
     /* how many forms deep do you want to try? */
     int repeat = 2;
     for (int i = 0; i <= repeat; i++) {
       dlForm.remove(null);
       final long timeBefore = System.currentTimeMillis();
       boolean password = false;
       boolean skipWaittime = false;
       if (new Regex(correctedBR, PASSWORDTEXT).matches()) {
         password = true;
         logger.info("The downloadlink seems to be password protected.");
       }
       /* md5 can be on the subsequent pages - it is to be found very rare in current XFS versions */
       if (downloadLink.getMD5Hash() == null) {
         String md5hash = new Regex(correctedBR, "<b>MD5.*?</b>.*?nowrap>(.*?)<").getMatch(0);
         if (md5hash != null) {
           downloadLink.setMD5Hash(md5hash.trim());
         }
       }
       /* Captcha START */
       if (correctedBR.contains(";background:#ccc;text-align")) {
         logger.info("Detected captcha method \"plaintext captchas\" for this host");
         /* Captcha method by ManiacMansion */
         final String[][] letters =
             new Regex(
                     br,
                     "<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);
         }
         final SortedMap<Integer, String> capMap = new TreeMap<Integer, String>();
         for (String[] letter : letters) {
           capMap.put(Integer.parseInt(letter[0]), Encoding.htmlDecode(letter[1]));
         }
         final 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 (correctedBR.contains("/captchas/")) {
         logger.info("Detected captcha method \"Standard captcha\" for this host");
         final 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("xfilesharingprobasic", captchaurl, downloadLink);
         dlForm.put("code", code);
         logger.info(
             "Put captchacode "
                 + code
                 + " obtained by captcha metod \"Standard captcha\" in the form.");
       } else if (new Regex(correctedBR, "(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")
           .matches()) {
         logger.info("Detected captcha method \"Re Captcha\" for this host");
         final PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
         final jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
         rc.findID();
         rc.load();
         final File cf = rc.downloadCaptcha(getLocalCaptchaFile());
         final String c = getCaptchaCode(cf, downloadLink);
         dlForm.put("recaptcha_challenge_field", rc.getChallenge());
         dlForm.put("recaptcha_response_field", Encoding.urlEncode(c));
         logger.info(
             "Put captchacode "
                 + c
                 + " obtained by captcha metod \"Re Captcha\" in the form and submitted it.");
         /* wait time is usually skippable for reCaptcha handling */
         skipWaittime = true;
       } else if (br.containsHTML("solvemedia\\.com/papi/")) {
         logger.info("Detected captcha method \"solvemedia\" for this host");
         final PluginForDecrypt solveplug = JDUtilities.getPluginForDecrypt("linkcrypt.ws");
         final jd.plugins.decrypter.LnkCrptWs.SolveMedia sm =
             ((jd.plugins.decrypter.LnkCrptWs) solveplug).getSolveMedia(br);
         File cf = null;
         try {
           cf = sm.downloadCaptcha(getLocalCaptchaFile());
         } catch (final Exception e) {
           if (jd.plugins.decrypter.LnkCrptWs.SolveMedia.FAIL_CAUSE_CKEY_MISSING.equals(
               e.getMessage())) {
             throw new PluginException(
                 LinkStatus.ERROR_FATAL,
                 "Host side solvemedia.com captcha error - please contact the "
                     + this.getHost()
                     + " support");
           }
           throw e;
         }
         final String code = getCaptchaCode(cf, downloadLink);
         final String chid = sm.getChallenge(code);
         dlForm.put("adcopy_challenge", chid);
         dlForm.put("adcopy_response", "manual_challenge");
       } else if (br.containsHTML("id=\"capcode\" name= \"capcode\"")) {
         logger.info("Detected captcha method \"keycaptca\"");
         String result = null;
         final PluginForDecrypt keycplug = JDUtilities.getPluginForDecrypt("linkcrypt.ws");
         try {
           final jd.plugins.decrypter.LnkCrptWs.KeyCaptcha kc =
               ((jd.plugins.decrypter.LnkCrptWs) keycplug).getKeyCaptcha(br);
           result = kc.showDialog(downloadLink.getDownloadURL());
         } catch (final Throwable e) {
           result = null;
         }
         if (result == null) {
           throw new PluginException(LinkStatus.ERROR_CAPTCHA);
         }
         if ("CANCEL".equals(result)) {
           throw new PluginException(LinkStatus.ERROR_FATAL);
         }
         dlForm.put("capcode", result);
         skipWaittime = false;
       }
       /* Captcha END */
       if (password) {
         passCode = handlePassword(dlForm, downloadLink);
       }
       if (!skipWaittime) {
         waitTime(timeBefore, downloadLink);
       }
       sendForm(dlForm);
       logger.info("Submitted DLForm");
       checkErrors(downloadLink, true);
       dllink = getDllink();
       if (dllink == null
           && (!br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"") || i == repeat)) {
         logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!");
         throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       } else if (dllink == null
           && br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"")) {
         dlForm = br.getFormbyProperty("name", "F1");
         continue;
       } else {
         break;
       }
     }
   }
   logger.info("Final downloadlink = " + dllink + " starting the download...");
   dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, resumable, maxchunks);
   if (dl.getConnection().getContentType().contains("html")) {
     if (dl.getConnection().getResponseCode() == 503) {
       throw new PluginException(
           LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
           "Connection limit reached, please contact our support!",
           5 * 60 * 1000l);
     }
     logger.warning("The final dllink seems not to be a file!");
     br.followConnection();
     correctBR();
     checkServerErrors();
     handlePluginBroken(downloadLink, "dllinknofile", 3);
   }
   downloadLink.setProperty(directlinkproperty, dllink);
   fixFilename(downloadLink);
   try {
     /* add a download slot */
     controlFree(+1);
     /* start the dl */
     dl.startDownload();
   } finally {
     /* remove download slot */
     controlFree(-1);
   }
 }
예제 #4
0
 @SuppressWarnings("unused")
 public void doFree(
     final DownloadLink downloadLink,
     boolean resumable,
     int maxchunks,
     final String directlinkproperty)
     throws Exception, PluginException {
   br.setFollowRedirects(false);
   passCode = downloadLink.getStringProperty("pass");
   // First, bring up saved final links
   String dllink = checkDirectLink(downloadLink, directlinkproperty);
   // Second, check for streaming links on the first page
   if (dllink == null) {
     dllink = getDllink();
   }
   // Third, do they provide video hosting?
   if (dllink == null && VIDEOHOSTER) {
     try {
       logger.info("Trying to get link via vidembed");
       final Browser brv = br.cloneBrowser();
       brv.getPage("/vidembed-" + fuid);
       dllink = brv.getRedirectLocation();
       if (dllink == null) {
         logger.info("Failed to get link via vidembed");
       }
     } catch (final Throwable e) {
       logger.info("Failed to get link via vidembed");
     }
   }
   // Possibility to skip captcha & (reconnect) waittimes
   dllink = null;
   boolean special_success = false;
   boolean special2_success = false;
   if (dllink == null
       && TRY_SPECIAL_WAY
       && !downloadLink.getBooleanProperty("special2_failed", false)) {
     try {
       final String temp_id =
           this.getPluginConfig().getStringProperty("spaceforfiles_tempid", null);
       if (temp_id != null) {
         final String checklink =
             "http://www.filespace.com/cgi-bin/dl.cgi/"
                 + temp_id
                 + "/"
                 + Encoding.urlEncode(downloadLink.getName());
         final boolean isvalid = checkDirectLink(checklink);
         if (isvalid) {
           dllink = checklink;
           special_success = true;
         }
       }
     } catch (final Throwable e) {
     }
   }
   if (dllink == null
       && TRY_SPECIAL_WAY_2
       && !downloadLink.getBooleanProperty("special2_failed", false)) {
     try {
       /* Pattern of finallinks generated here: http://www.spaceforfiles.com/dlcdn/xxxxxxxxxxxx/filename.ext */
       final Browser brad = br.cloneBrowser();
       final String fid = new Regex(downloadLink.getDownloadURL(), "([a-z0-9]{12})$").getMatch(0);
       final String postDataF1 =
           "op=download1&usr_login=&id="
               + fid
               + "&fname="
               + Encoding.urlEncode(downloadLink.getName())
               + "&referer=&lck=1&method_free=Free+Download";
       brad.postPage(br.getURL(), postDataF1);
       final String md5 = brad.getRegex("MD5 Checksum: ([a-f0-9]{32})").getMatch(0);
       if (md5 != null) {
         downloadLink.setMD5Hash(md5);
       }
       final String start_referer = brad.getURL();
       final String rand = brad.getRegex("name=\"rand\" value=\"([a-z0-9]+)\"").getMatch(0);
       if (rand == null) {
         throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       }
       // br.postPage("http://filespace.com/xxxxxxxxxxxx", "op=download2&id=" + fid + "&rand=" +
       // rand +
       // "&referer=&method_free=Free+Download&method_premium=&adcopy_response=&adcopy_challenge=&down_script=1");
       brad.cloneBrowser().getPage("http://www.filespace.com/locker/locker.js?1");
       brad.getPage("http://www.filespace.com/locker/lockurl.php?uniqueid=" + fid);
       if (!brad.containsHTML("\"lockid\":\\-1")) {
         final String lockid = brad.getRegex("\"lockid\":(\")?(\\d+)").getMatch(1);
         final String hash = brad.getRegex("\"hash\":\"([a-z0-9]+)\"").getMatch(0);
         if (lockid == null || hash == null) {
           throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
         }
         brad.getPage(
             "http://www.spaceforfiles.com/locker/offers.php?hash=" + hash + "&sid=" + fid);
         brad.cloneBrowser()
             .getPage("http://www.filespace.com/locker/checkoffer.php?lockid=" + lockid);
       }
       brad.getHeaders().put("Referer", start_referer);
       final String postData =
           "op=download2&id="
               + fid
               + "&rand="
               + rand
               + "&referer="
               + Encoding.urlEncode(br.getURL())
               + "&method_free=Free+Download&method_premium=&method_highspeed=1&lck=1&down_script=1";
       brad.postPage(start_referer, postData);
       dllink = brad.getRedirectLocation();
       if (dllink != null) {
         // resumable = true;
         // maxchunks = 0;
         special2_success = true;
       }
     } catch (final Throwable e) {
     }
   }
   // Fourth, continue like normal.
   if (dllink == null) {
     checkErrors(downloadLink, false);
     final Form download1 = getFormByKey("op", "download1");
     if (download1 != null) {
       download1.remove("method_premium");
       // stable is lame, issue finding input data fields correctly. eg. closes at ' quotation mark
       // - remove when jd2 goes stable!
       if (downloadLink.getName().contains("'")) {
         String fname =
             new Regex(br, "<input type=\"hidden\" name=\"fname\" value=\"([^\"]+)\">")
                 .getMatch(0);
         if (fname != null) {
           download1.put("fname", Encoding.urlEncode(fname));
         } else {
           logger.warning("Could not find 'fname'");
           throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
         }
       }
       // end of backward compatibility
       sendForm(download1);
       checkErrors(downloadLink, false);
       dllink = getDllink();
     }
   }
   if (dllink == null) {
     Form dlForm = br.getFormbyProperty("name", "F1");
     if (dlForm == null) {
       throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     }
     // how many forms deep do you want to try.
     int repeat = 2;
     for (int i = 0; i <= repeat; i++) {
       dlForm.remove(null);
       final long timeBefore = System.currentTimeMillis();
       boolean password = false;
       boolean skipWaittime = false;
       if (new Regex(correctedBR, PASSWORDTEXT).matches()) {
         password = true;
         logger.info("The downloadlink seems to be password protected.");
       }
       // md5 can be on the subsequent pages
       if (downloadLink.getMD5Hash() == null) {
         String md5hash = new Regex(correctedBR, "<b>MD5.*?</b>.*?nowrap>(.*?)<").getMatch(0);
         if (md5hash != null) {
           downloadLink.setMD5Hash(md5hash.trim());
         }
       }
       /* Captcha START */
       if (correctedBR.contains(";background:#ccc;text-align")) {
         logger.info("Detected captcha method \"plaintext captchas\" for this host");
         /** Captcha method by ManiacMansion */
         final String[][] letters =
             new Regex(
                     br,
                     "<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);
         }
         final SortedMap<Integer, String> capMap = new TreeMap<Integer, String>();
         for (String[] letter : letters) {
           capMap.put(Integer.parseInt(letter[0]), Encoding.htmlDecode(letter[1]));
         }
         final 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 (correctedBR.contains("/captchas/")) {
         logger.info("Detected captcha method \"Standard captcha\" for this host");
         final 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("xfilesharingprobasic", captchaurl, downloadLink);
         dlForm.put("code", code);
         logger.info(
             "Put captchacode "
                 + code
                 + " obtained by captcha metod \"Standard captcha\" in the form.");
       } else if (new Regex(correctedBR, "(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")
           .matches()) {
         logger.info("Detected captcha method \"Re Captcha\" for this host");
         final PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
         final jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
         rc.findID();
         rc.load();
         final File cf = rc.downloadCaptcha(getLocalCaptchaFile());
         final String c = getCaptchaCode(cf, downloadLink);
         dlForm.put("recaptcha_challenge_field", rc.getChallenge());
         dlForm.put("recaptcha_response_field", Encoding.urlEncode(c));
         logger.info(
             "Put captchacode "
                 + c
                 + " obtained by captcha metod \"Re Captcha\" in the form and submitted it.");
         /** wait time is often skippable for reCaptcha handling */
         skipWaittime = true;
       } else if (br.containsHTML("solvemedia\\.com/papi/")) {
         logger.info("Detected captcha method \"solvemedia\" for this host");
         final PluginForDecrypt solveplug = JDUtilities.getPluginForDecrypt("linkcrypt.ws");
         final jd.plugins.decrypter.LnkCrptWs.SolveMedia sm =
             ((jd.plugins.decrypter.LnkCrptWs) solveplug).getSolveMedia(br);
         File cf = null;
         try {
           cf = sm.downloadCaptcha(getLocalCaptchaFile());
         } catch (final Exception e) {
           if (jd.plugins.decrypter.LnkCrptWs.SolveMedia.FAIL_CAUSE_CKEY_MISSING.equals(
               e.getMessage())) {
             throw new PluginException(
                 LinkStatus.ERROR_FATAL,
                 "Host side solvemedia.com captcha error - please contact the "
                     + this.getHost()
                     + " support");
           }
           throw e;
         }
         final String code = getCaptchaCode(cf, downloadLink);
         final String chid = sm.getChallenge(code);
         dlForm.put("adcopy_challenge", chid);
         dlForm.put("adcopy_response", "manual_challenge");
       } else if (br.containsHTML("id=\"capcode\" name= \"capcode\"")) {
         logger.info("Detected captcha method \"keycaptca\"");
         String result = null;
         final PluginForDecrypt keycplug = JDUtilities.getPluginForDecrypt("linkcrypt.ws");
         try {
           final jd.plugins.decrypter.LnkCrptWs.KeyCaptcha kc =
               ((jd.plugins.decrypter.LnkCrptWs) keycplug).getKeyCaptcha(br);
           result = kc.showDialog(downloadLink.getDownloadURL());
         } catch (final Throwable e) {
           result = null;
         }
         if (result == null) {
           throw new PluginException(LinkStatus.ERROR_CAPTCHA);
         }
         if ("CANCEL".equals(result)) {
           throw new PluginException(LinkStatus.ERROR_FATAL);
         }
         dlForm.put("capcode", result);
         /** wait time is often skippable for reCaptcha handling */
         skipWaittime = false;
       }
       /* Captcha END */
       if (password) {
         passCode = handlePassword(dlForm, downloadLink);
       }
       if (!skipWaittime) {
         waitTime(timeBefore, downloadLink);
       }
       sendForm(dlForm);
       logger.info("Submitted DLForm");
       checkErrors(downloadLink, true);
       dllink = getDllink();
       if (dllink == null
           && (!br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"") || i == repeat)) {
         logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!");
         throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       } else if (dllink == null
           && br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"")) {
         dlForm = br.getFormbyProperty("name", "F1");
         try {
           invalidateLastChallengeResponse();
         } catch (final Throwable e) {
         }
         continue;
       } else {
         try {
           validateLastChallengeResponse();
         } catch (final Throwable e) {
         }
         break;
       }
     }
   }
   logger.info("Final downloadlink = " + dllink + " starting the download...");
   dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, resumable, maxchunks);
   if (dl.getConnection().getContentType().contains("html")) {
     if (dl.getConnection().getResponseCode() == 503) {
       throw new PluginException(
           LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
           "Connection limit reached, please contact our support!",
           5 * 60 * 1000l);
     }
     logger.warning("The final dllink seems not to be a file!");
     br.followConnection();
     correctBR();
     checkServerErrors();
     if (special_success) {
       downloadLink.setProperty("special_failed", true);
     } else if (special2_success) {
       downloadLink.setProperty("special2_failed", true);
     }
     int timesFailed =
         downloadLink.getIntegerProperty(NICE_HOSTproperty + "failedtimes_dllinknofile", 0);
     downloadLink.getLinkStatus().setRetryCount(0);
     if (timesFailed <= 2) {
       logger.info(NICE_HOST + ": Final link is no file -> Retrying");
       timesFailed++;
       downloadLink.setProperty(NICE_HOSTproperty + "failedtimes_dllinknofile", timesFailed);
       throw new PluginException(LinkStatus.ERROR_RETRY, "Final download link not found");
     } else {
       downloadLink.setProperty(NICE_HOSTproperty + "failedtimes_dllinknofile", Property.NULL);
       logger.info(NICE_HOST + ": Final link is no file -> Plugin is broken");
       throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     }
   }
   final String tempid = new Regex(dllink, "cgi\\-bin/dl\\.cgi/([a-z0-9]+)/").getMatch(0);
   if (tempid != null) {
     this.getPluginConfig().setProperty("spaceforfiles_tempid", tempid);
   }
   downloadLink.setProperty(directlinkproperty, dllink);
   fixFilename(downloadLink);
   try {
     // add a download slot
     controlFree(+1);
     // start the dl
     dl.startDownload();
   } finally {
     // remove download slot
     controlFree(-1);
   }
 }
예제 #5
0
  @SuppressWarnings("unused")
  public void doFree(
      final DownloadLink downloadLink,
      final boolean resumable,
      final int maxchunks,
      final String directlinkproperty)
      throws Exception, PluginException {
    br.setFollowRedirects(false);
    passCode = downloadLink.getStringProperty("pass");
    // First, bring up saved final links
    String dllink = checkDirectLink(downloadLink, directlinkproperty);
    // Second, check for streaming links on the first page
    if (dllink == null) {
      dllink = getDllink();
    }
    // Third, do they provide video hosting?
    if (dllink == null && VIDEOHOSTER) {
      final Browser brv = br.cloneBrowser();
      brv.getPage(
          "/vidembed-" + new Regex(downloadLink.getDownloadURL(), "([a-z0-9]+)$").getMatch(0));
      dllink = brv.getRedirectLocation();
    }
    // Fourth, continue like normal.
    if (dllink == null) {
      checkErrors(downloadLink, false);
      final Form download1 = getFormByKey("op", "download1");
      if (download1 != null) {
        download1.remove("method_premium");
        // stable is lame, issue finding input data fields correctly. eg. closes at ' quotation mark
        // - remove when jd2 goes stable!
        if (downloadLink.getName().contains("'")) {
          String fname =
              new Regex(br, "<input type=\"hidden\" name=\"fname\" value=\"([^\"]+)\">")
                  .getMatch(0);
          if (fname != null) {
            download1.put("fname", Encoding.urlEncode(fname));
          } else {
            logger.warning("Could not find 'fname'");
            throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
          }
        }
        // end of backward compatibility
        sendForm(download1);
        checkErrors(downloadLink, false);
        dllink = getDllink();
      }
    }
    if (dllink == null) {
      Form dlForm = br.getFormbyProperty("name", "F1");
      if (dlForm == null) {
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      }
      // how many forms deep do you want to try.
      int repeat = 2;
      for (int i = 0; i <= repeat; i++) {
        dlForm.remove(null);
        final long timeBefore = System.currentTimeMillis();
        boolean password = false;
        boolean skipWaittime = false;
        if (new Regex(correctedBR, PASSWORDTEXT).matches()) {
          password = true;
          logger.info("The downloadlink seems to be password protected.");
        }
        // md5 can be on the subsequent pages
        if (downloadLink.getMD5Hash() == null) {
          String md5hash = new Regex(correctedBR, "<b>MD5.*?</b>.*?nowrap>(.*?)<").getMatch(0);
          if (md5hash != null) {
            downloadLink.setMD5Hash(md5hash.trim());
          }
        }
        /* Captcha START */
        if (correctedBR.contains(";background:#ccc;text-align")) {
          logger.info("Detected captcha method \"plaintext captchas\" for this host");
          /** Captcha method by ManiacMansion */
          final String[][] letters =
              new Regex(
                      br,
                      "<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);
          }
          final SortedMap<Integer, String> capMap = new TreeMap<Integer, String>();
          for (String[] letter : letters) {
            capMap.put(Integer.parseInt(letter[0]), Encoding.htmlDecode(letter[1]));
          }
          final 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 (correctedBR.contains("/captchas/")) {
          logger.info("Detected captcha method \"Standard captcha\" for this host");
          final 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("xfilesharingprobasic", captchaurl, downloadLink);
          dlForm.put("code", code);
          logger.info(
              "Put captchacode "
                  + code
                  + " obtained by captcha metod \"Standard captcha\" in the form.");
        } else if (new Regex(correctedBR, "(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")
            .matches()) {
          logger.info("Detected captcha method \"Re Captcha\" for this host");
          final PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
          final jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
          rc.findID();
          rc.load();
          final File cf = rc.downloadCaptcha(getLocalCaptchaFile());
          final String c = getCaptchaCode("recaptcha", cf, downloadLink);
          dlForm.put("recaptcha_challenge_field", rc.getChallenge());
          dlForm.put("recaptcha_response_field", Encoding.urlEncode(c));
          logger.info(
              "Put captchacode "
                  + c
                  + " obtained by captcha metod \"Re Captcha\" in the form and submitted it.");
          /** wait time is often skippable for reCaptcha handling */
          skipWaittime = true;
        } else if (br.containsHTML("solvemedia\\.com/papi/")) {
          logger.info("Detected captcha method \"solvemedia\" for this host");

          final org.jdownloader.captcha.v2.challenge.solvemedia.SolveMedia sm =
              new org.jdownloader.captcha.v2.challenge.solvemedia.SolveMedia(br);
          final File cf = sm.downloadCaptcha(getLocalCaptchaFile());
          final String code = getCaptchaCode(cf, downloadLink);
          final String chid = sm.getChallenge(code);
          dlForm.put("adcopy_challenge", chid);
          dlForm.put("adcopy_response", "manual_challenge");
        } else if (br.containsHTML("id=\"capcode\" name= \"capcode\"")) {
          logger.info("Detected captcha method \"keycaptca\"");
          String result =
              handleCaptchaChallenge(
                  getDownloadLink(),
                  new KeyCaptcha(this, br, getDownloadLink()).createChallenge(this));
          if (result == null) {
            throw new PluginException(LinkStatus.ERROR_CAPTCHA);
          }
          if ("CANCEL".equals(result)) {
            throw new PluginException(LinkStatus.ERROR_FATAL);
          }
          dlForm.put("capcode", result);
          /** wait time is often skippable for reCaptcha handling */
          skipWaittime = false;
        }
        /* Captcha END */
        if (password) {
          passCode = handlePassword(dlForm, downloadLink);
        }
        if (!skipWaittime) {
          waitTime(timeBefore, downloadLink);
        }
        sendForm(dlForm);
        logger.info("Submitted DLForm");
        checkErrors(downloadLink, true);
        dllink = getDllink();
        if (dllink == null
            && (!br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"") || i == repeat)) {
          logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!");
          throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
        } else if (dllink == null
            && br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"")) {
          dlForm = br.getFormbyProperty("name", "F1");
          try {
            invalidateLastChallengeResponse();
          } catch (final Throwable e) {
          }
          continue;
        } else {
          try {
            validateLastChallengeResponse();
          } catch (final Throwable e) {
          }
          break;
        }
      }
    }
    logger.info("Final downloadlink = " + dllink + " starting the download...");
    dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, resumable, maxchunks);
    if (dl.getConnection().getContentType().contains("html")) {
      if (dl.getConnection().getResponseCode() == 503) {
        throw new PluginException(
            LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
            "Connection limit reached, please contact our support!",
            5 * 60 * 1000l);
      }
      logger.warning("The final dllink seems not to be a file!");
      br.followConnection();
      correctBR();
      checkServerErrors();
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    downloadLink.setProperty(directlinkproperty, dllink);
    fixFilename(downloadLink);
    try {
      // add a download slot
      controlFree(+1);
      // start the dl
      dl.startDownload();
    } finally {
      // remove download slot
      controlFree(-1);
    }
  }
예제 #6
0
  @Override
  public void handleFree(DownloadLink downloadLink) throws Exception {
    this.setBrowserExclusive();
    requestFileInformation(downloadLink);
    if (br.containsHTML("value=\"Free Users\""))
      br.postPage(downloadLink.getDownloadURL(), "Free=Free+Users");
    else if (br.getFormbyProperty("name", "entryform1") != null)
      br.submitForm(br.getFormbyProperty("name", "entryform1"));
    final Browser ajaxBR = br.cloneBrowser();
    ajaxBR.getHeaders().put("X-Requested-With", "XMLHttpRequest");

    final String rcID = br.getRegex("challenge\\?k=([^<>\"]*?)\"").getMatch(0);
    if (rcID != null) {
      PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
      jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
      rc.setId(rcID);
      rc.load();
      File cf = rc.downloadCaptcha(getLocalCaptchaFile());
      String c = getCaptchaCode(cf, downloadLink);
      ajaxBR.postPage(
          downloadLink.getDownloadURL(),
          "downloadverify=1&d=1&recaptcha_response_field="
              + c
              + "&recaptcha_challenge_field="
              + rc.getChallenge());
      if (ajaxBR.containsHTML("incorrect\\-captcha\\-sol"))
        throw new PluginException(LinkStatus.ERROR_CAPTCHA);
    } else if (br.containsHTML(this.getHost() + "/captcha\\.php\"")) {
      final String code =
          getCaptchaCode(
              "mhfstandard",
              COOKIE_HOST + "/captcha.php?rand=" + System.currentTimeMillis(),
              downloadLink);
      ajaxBR.postPage(downloadLink.getDownloadURL(), "downloadverify=1&d=1&captchacode=" + code);
      if (ajaxBR.containsHTML("Captcha number error or expired"))
        throw new PluginException(LinkStatus.ERROR_CAPTCHA);
    } else {
      ajaxBR.postPage(downloadLink.getDownloadURL(), "downloadverify=1&d=1");
    }
    final String reconnectWaittime =
        ajaxBR.getRegex("You must wait (\\d+) mins\\. for next download.").getMatch(0);
    if (reconnectWaittime != null)
      throw new PluginException(
          LinkStatus.ERROR_IP_BLOCKED, Integer.parseInt(reconnectWaittime) * 60 * 1001l);
    if (ajaxBR.containsHTML(">You have got max allowed download sessions from the same")
        || ajaxBR.containsHTML("The allowed download sessions assigned to your IP is used up"))
      throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 60 * 60 * 1000l);
    final String finalLink = findLink(ajaxBR);
    if (finalLink == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    int wait = DEFAULTWAITTIME;
    String waittime = ajaxBR.getRegex("countdown\\((\\d+)\\);").getMatch(0);
    // For older versions it's usually skippable
    // if (waittime == null) waittime =
    // br.getRegex("var timeout=\\'(\\d+)\\';").getMatch(0);
    if (waittime != null) wait = Integer.parseInt(waittime);
    sleep(wait * 1001l, downloadLink);
    dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, finalLink, false, 1);
    if (dl.getConnection().getContentType().contains("html")) {
      br.followConnection();

      if (br.containsHTML(">AccessKey is expired, please request"))
        throw new PluginException(LinkStatus.ERROR_FATAL, "FATAL server error, waittime skipped?");
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    dl.startDownload();
  }
예제 #7
0
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();
    br.setFollowRedirects(false);
    br.getPage(parameter);
    if (br.containsHTML("(\"This link does not exist\\.\"|ERROR - this link does not exist)"))
      throw new DecrypterException(
          JDL.L(
              "plugins.decrypt.errormsg.unavailable",
              "Perhaps wrong URL or the download is not available anymore."));
    if (br.containsHTML(">Not yet checked</span>")) throw new DecrypterException("Not yet checked");
    if (br.containsHTML("To use reCAPTCHA you must get an API key from"))
      throw new DecrypterException("Server error, please contact the safelinking.net support!");
    if (!parameter.contains("/d/")) {
      Form capForm = new Form();
      capForm.put("post-protect", "1");
      capForm.setMethod(MethodType.POST);
      capForm.setAction(parameter);
      for (int i = 0; i <= 5; i++) {
        if (br.containsHTML(PASSWORDPROTECTEDTEXT)) {
          capForm.put("link-password", getUserInput(null, param));
        }
        if (br.containsHTML(RECAPTCHATEXT)) {
          PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
          jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
          rc.parse();
          rc.load();
          File cf = rc.downloadCaptcha(getLocalCaptchaFile());
          capForm.put("recaptcha_challenge_field", rc.getChallenge());
          capForm.put("recaptcha_response_field", getCaptchaCode(cf, param));
        } else if (br.getRegex(CAPTCHAREGEX1).getMatch(0) != null) {
          capForm.put(
              "securimage_response_field",
              getCaptchaCode(br.getRegex(CAPTCHAREGEX1).getMatch(0), param));
        } else if (br.getRegex(CAPTCHAREGEX2).getMatch(0) != null) {
          capForm.put(
              "3dcaptcha_response_field",
              getCaptchaCode(br.getRegex(CAPTCHAREGEX2).getMatch(0), param));
        } else if (br.containsHTML(CAPTCHATEXT3)) {
          Browser xmlbrowser = br.cloneBrowser();
          xmlbrowser.getPage("http://safelinking.net/includes/captcha_factory/fancycaptcha.php");
          capForm.put("fancy-captcha", xmlbrowser.toString().trim());
        }
        br.submitForm(capForm);
        if (br.containsHTML(RECAPTCHATEXT)
            || br.getRegex(CAPTCHAREGEX1).getMatch(0) != null
            || br.getRegex(CAPTCHAREGEX2).getMatch(0) != null
            || br.containsHTML(PASSWORDPROTECTEDTEXT)) continue;
        if (br.containsHTML(CAPTCHATEXT3)) {
          logger.warning("Captcha3 captchahandling failed for link: " + parameter);
          return null;
        }
        break;
      }
      if (br.containsHTML(RECAPTCHATEXT)
          || br.getRegex(CAPTCHAREGEX1).getMatch(0) != null
          || br.getRegex(CAPTCHAREGEX2).getMatch(0) != null)
        throw new DecrypterException(DecrypterException.CAPTCHA);
      if (br.containsHTML(PASSWORDPROTECTEDTEXT))
        throw new DecrypterException(DecrypterException.PASSWORD);
      if (br.containsHTML(">All links are dead\\.<"))
        throw new DecrypterException(
            JDL.L(
                "plugins.decrypt.errormsg.unavailable",
                "Perhaps wrong URL or the download is not available anymore."));
      // container handling (if no containers found, use webprotection
      if (br.containsHTML("\\.dlc")) {
        decryptedLinks = loadcontainer(".dlc", param);
        if (decryptedLinks != null && decryptedLinks.size() > 0) return decryptedLinks;
      }

      if (br.containsHTML("\\.rsdf")) {
        decryptedLinks = loadcontainer(".rsdf", param);
        if (decryptedLinks != null && decryptedLinks.size() > 0) return decryptedLinks;
      }

      if (br.containsHTML("\\.ccf")) {
        decryptedLinks = loadcontainer(".ccf", param);
        if (decryptedLinks != null && decryptedLinks.size() > 0) return decryptedLinks;
      }
      decryptedLinks = new ArrayList<DownloadLink>();
      // Webprotection decryption
      String[] links =
          br.getRegex("class=\"linked\">(http://safelinking\\.net/d/.*?)</a>").getColumn(0);
      if (links == null || links.length == 0) {
        String allLinks =
            br.getRegex("class=\"link-box\" id=\"direct-links\".*?>(.*?<a href=\".*?)</div>")
                .getMatch(0);
        if (allLinks != null) links = new Regex(allLinks, "<a href=\"(.*?)\"").getColumn(0);
        if (links == null || links.length == 0) {
          links = br.getRegex("\"(http://safelinking\\.net/d/[a-z0-9]+)\"").getColumn(0);
          if (links == null || links.length == 0) {
            links = br.getRegex("class=\"linked\">(http://.*?)</a>").getColumn(0);
          }
        }
      }
      if (links == null || links.length == 0) return null;
      progress.setRange(links.length);
      for (String link : links) {
        if (!link.contains("safelinking.net/")) {
          decryptedLinks.add(createDownloadlink(link));
        } else {
          br.getPage(link);
          String finallink = br.getRedirectLocation();
          if (finallink == null) {
            logger.warning("Decrypter broken, decryption stopped at link: " + link);
            return null;
          }
          if (!parameter.equals(finallink)) decryptedLinks.add(createDownloadlink(finallink));
        }
        progress.increase(1);
      }
    } else {
      if (br.getRedirectLocation() == null) {
        logger.warning("Error in single-link handling for link: " + parameter);
        return null;
      }
      decryptedLinks.add(createDownloadlink(br.getRedirectLocation()));
    }
    return decryptedLinks;
  }
예제 #8
0
  public void doFree(
      DownloadLink downloadLink, boolean resumable, int maxchunks, boolean checkFastWay)
      throws Exception, PluginException {
    if (BRBEFORE.contains(">404 Not Found<"))
      throw new PluginException(
          LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error: 404", 10 * 60 * 1000l);
    String passCode = null;
    if (BRBEFORE.contains("\"download1\"")) {
      br.postPage(
          downloadLink.getDownloadURL(),
          "op=download1&usr_login=&id="
              + new Regex(
                      downloadLink.getDownloadURL(),
                      COOKIE_HOST.replace("http://", "") + "/" + "([a-z0-9]{12})")
                  .getMatch(0)
              + "&fname="
              + Encoding.urlEncode(downloadLink.getName())
              + "&referer=&method_free=Free+Download");
      doSomething();
      if (BRBEFORE.contains(">No such file with this filename<"))
        throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
    }
    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);
    }
    String dllink = null;
    if (checkFastWay) {
      dllink = downloadLink.getStringProperty("freelink");
      try {
        if (dllink != null) {
          Browser br2 = br.cloneBrowser();
          URLConnectionAdapter con = br2.openGetConnection(dllink);
          if (con.getContentType().contains("html")) {
            downloadLink.setProperty("freelink", Property.NULL);
            dllink = null;
          }
          con.disconnect();
        }
      } catch (Exception e) {
        dllink = null;
      }
    }
    // Videolinks can already be found here, if a link is found here we can skip waittimes and
    // captchas
    if (dllink == null) dllink = getDllink();
    if (dllink == null) {
      Form dlForm = br.getFormbyProperty("name", "F1");
      if (dlForm == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      long timeBefore = System.currentTimeMillis();
      boolean password = false;
      boolean skipWaittime = false;
      if (new Regex(BRBEFORE, PASSWORDTEXT).matches()) {
        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("xfilesharingprobasic", captchaurl, downloadLink);
        dlForm.put("code", code);
        logger.info(
            "Put captchacode "
                + code
                + " obtained by captcha metod \"Standard captcha\" in the form.");
      } else if (new Regex(BRBEFORE, "(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")
          .matches()) {
        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.setForm(dlForm);
        String id = this.br.getRegex("\\?k=([A-Za-z0-9%_\\+\\- ]+)\"").getMatch(0);
        rc.setId(id);
        rc.load();
        File cf = rc.downloadCaptcha(getLocalCaptchaFile());
        String c = getCaptchaCode(cf, downloadLink);
        Form rcform = rc.getForm();
        rcform.put("recaptcha_challenge_field", rc.getChallenge());
        rcform.put("recaptcha_response_field", Encoding.urlEncode(c));
        logger.info(
            "Put captchacode "
                + c
                + " obtained by captcha metod \"Re Captcha\" in the form and submitted it.");
        dlForm = rc.getForm();
        // waittime is often skippable for reCaptcha handling
        // skipWaittime = true;
      }
      /* Captcha END */
      if (password) passCode = handlePassword(passCode, dlForm, downloadLink);
      if (!skipWaittime) waitTime(timeBefore, downloadLink);
      br.submitForm(dlForm);
      logger.info("Submitted DLForm");
      doSomething();
      checkErrors(downloadLink, true, passCode);
      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();
      doSomething();
      checkServerErrors();
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    if (passCode != null) downloadLink.setProperty("pass", passCode);
    downloadLink.setProperty("freelink", dllink);
    dl.startDownload();
  }
 @Override
 public void handleFree(DownloadLink downloadLink) throws Exception {
   checkShowFreeDialog();
   requestFileInformation(downloadLink);
   br.setFollowRedirects(true);
   if (server != -1) {
     synchronized (noFreeSlot) {
       Long ret = noFreeSlot.get(server);
       if (ret != null) {
         if (System.currentTimeMillis() - ret < waitNoFreeSlot) {
           if (downloadLink.getLinkStatus().getRetryCount() >= 5) {
             /*
              * reset counter this error does not cause plugin to stop
              */
             downloadLink.getLinkStatus().setRetryCount(0);
           }
           throw new PluginException(
               LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE,
               JDL.L(
                   "plugins.hoster.shareonlinebiz.errors.servernotavailable3",
                   "No free Free-User Slots! Get PremiumAccount or wait!"),
               waitNoFreeSlot);
         } else {
           noFreeSlot.remove(server);
         }
       }
     }
     synchronized (overloadedServer) {
       Long ret = overloadedServer.get(server);
       if (ret != null) {
         if (System.currentTimeMillis() - ret < waitOverloadedServer) {
           if (downloadLink.getLinkStatus().getRetryCount() >= 5) {
             /*
              * reset counter this error does not cause plugin to stop
              */
             downloadLink.getLinkStatus().setRetryCount(0);
           }
           throw new PluginException(
               LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server overloaded", waitNoFreeSlot);
         } else {
           overloadedServer.remove(server);
         }
       }
     }
   }
   this.setBrowserExclusive();
   br.getHeaders().put("User-Agent", UA.toString());
   br.getHeaders()
       .put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
   br.getHeaders().put("Accept-Language", "en-us,de;q=0.7,en;q=0.3");
   br.getHeaders().put("Pragma", null);
   br.getHeaders().put("Cache-Control", null);
   br.setCookie("http://www.share-online.biz", "page_language", "english");
   // redirects!
   try {
     br.getPage(downloadLink.getDownloadURL().replace("https://", "http://"));
   } catch (final BrowserException e) {
     if (br.getRequest().getHttpConnection().getResponseCode() == 502) {
       throw new PluginException(
           LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
           JDL.L("plugins.hoster.shareonlinebiz.errors.maintenance", "Server maintenance"),
           30 * 60 * 1000l);
     }
     throw new PluginException(
         LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE,
         JDL.L("plugins.hoster.shareonlinebiz.errors.unknownservererror", "Unknown server error"),
         1 * 60 * 60 * 1000l);
   }
   if (br.getURL().contains("/failure/proxy/1")) {
     throw new PluginException(LinkStatus.ERROR_FATAL, "Proxy error");
   }
   final Browser brc = br.cloneBrowser();
   try {
     brc.openGetConnection("/template/images/corp/uploadking.php?show=last");
   } finally {
     try {
       brc.getHttpConnection().disconnect();
     } catch (final Throwable e) {
     }
   }
   errorHandling(br, downloadLink, null, null);
   if (!br.containsHTML(">>> continue for free <<<")) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   String ID = getID(downloadLink);
   br.postPage("/dl/" + ID + "/free/", "dl_free=1");
   errorHandling(br, downloadLink, null, null);
   String wait = br.getRegex("var wait=(\\d+)").getMatch(0);
   boolean captcha = br.containsHTML("RECAPTCHA active");
   long startWait = 0;
   if (captcha == true) {
     startWait = System.currentTimeMillis();
   } else {
     if (wait != null) {
       this.sleep(Integer.parseInt(wait) * 1000l, downloadLink);
     }
   }
   String dlINFO = br.getRegex("var dl=\"(.*?)\"").getMatch(0);
   String url = Encoding.Base64Decode(dlINFO);
   if (captcha) {
     /* recaptcha handling */
     PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
     jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
     rc.setId("6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX");
     rc.load();
     File cf = rc.downloadCaptcha(getLocalCaptchaFile());
     String c = getCaptchaCode("recaptcha", cf, downloadLink);
     if (wait != null) {
       long gotWait = Integer.parseInt(wait) * 500l;
       long waited = System.currentTimeMillis() - startWait;
       gotWait -= waited;
       if (gotWait > 0) {
         this.sleep(gotWait, downloadLink);
       }
     }
     br.postPage(
         "/dl/" + ID + "/free/captcha/" + System.currentTimeMillis(),
         "dl_free=1&recaptcha_response_field="
             + Encoding.urlEncode(c)
             + "&recaptcha_challenge_field="
             + rc.getChallenge());
     url = br.getRegex("([a-zA-Z0-9/=]+)").getMatch(0);
     if ("0".equals(url)) {
       throw new PluginException(LinkStatus.ERROR_CAPTCHA);
     }
     url = Encoding.Base64Decode(url);
     if (url == null || !url.startsWith("http")) {
       url = null;
     }
     if (wait != null) {
       this.sleep(Integer.parseInt(wait) * 1000l, downloadLink);
     }
   }
   br.setFollowRedirects(true);
   /* Datei herunterladen */
   if (url != null && url.trim().length() == 0) {
     throw new PluginException(
         LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError", 5 * 60 * 1000l);
   }
   if (br.containsHTML(">Proxy\\-Download not supported for free access")) {
     throw new PluginException(
         LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE,
         "Proxy download not supported for free access",
         5 * 60 * 1000l);
   }
   if (url == null || !url.startsWith("http")) {
     logger.info("share-online.biz: Unknown error");
     int timesFailed = downloadLink.getIntegerProperty("timesfailedshareonlinebiz_unknown", 0);
     if (timesFailed <= 2) {
       timesFailed++;
       downloadLink.setProperty("timesfailedshareonlinebiz_unknown", timesFailed);
       throw new PluginException(LinkStatus.ERROR_RETRY, "Unknown error");
     } else {
       downloadLink.setProperty("timesfailedshareonlinebiz_unknown", Property.NULL);
       logger.info("share-online.biz: Unknown error - Plugin broken!");
       throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     }
   }
   dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, url);
   if (dl.getConnection().isContentDisposition()
       || (dl.getConnection().getContentType() != null
           && dl.getConnection().getContentType().contains("octet-stream"))) {
     try {
       validateLastChallengeResponse();
     } catch (final Throwable e) {
     }
     dl.startDownload();
   } else {
     try {
       invalidateLastChallengeResponse();
     } catch (final Throwable e) {
     }
     br.followConnection();
     errorHandling(br, downloadLink, null, null);
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
 }
예제 #10
0
  public void doFree(
      final DownloadLink downloadLink,
      final boolean resumable,
      final int maxchunks,
      final String directlinkproperty)
      throws Exception, PluginException {
    br.setFollowRedirects(false);
    String passCode = null;
    // First, bring up saved final links
    String dllink = checkDirectLink(downloadLink, directlinkproperty);
    // Second, check for streaming links on the first page
    if (dllink == null) dllink = getDllink();
    // Third, do they provide video hosting?
    if (dllink == null && VIDEOHOSTER) {
      // jwplayer - http://vdoreel.com/test/ExorcomPlayer.swf
      final Browser brv = br.cloneBrowser();
      brv.getPage(
          COOKIE_HOST
              + "/xml2/"
              + new Regex(downloadLink.getDownloadURL(), "([a-z0-9]+)$").getMatch(0)
              + ".xml");
      String a = brv.getRegex("CDATA\\[([^\\]]+={0,2})").getMatch(0);
      if (a == null || a.length() < 10) {
        logger.warning("Can't find 'a'");
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      }
      try {
        Cipher c = Cipher.getInstance("DES/ECB/PKCS5Padding");
        /* CHECK: we should always use getBytes("UTF-8") or with wanted charset, never system charset! */
        SecretKeySpec keySpec = new SecretKeySpec("N%66=]H6".getBytes(), "DES");
        c.init(Cipher.DECRYPT_MODE, keySpec);
        /* CHECK: we should always use new String (bytes,charset) to avoid issues with system charset and utf-8 */
        dllink = new String(c.doFinal(Base64.decode(a.substring(0, a.length() - 6))));
      } catch (Throwable e) {
      }
    }
    // Fourth, continue like normal.
    if (dllink == null) {
      checkErrors(downloadLink, false, passCode);
      final Form download1 = getFormByKey("op", "download1");
      if (download1 != null) {
        download1.remove("method_premium");
        // stable is lame, issue finding input data fields correctly. eg. closes at ' quotation mark
        // - remove when jd2 goes stable!
        if (downloadLink.getName().contains("'")) {
          String fname =
              new Regex(br, "<input type=\"hidden\" name=\"fname\" value=\"([^\"]+)\">")
                  .getMatch(0);
          if (fname != null) {
            download1.put("fname", Encoding.urlEncode(fname));
          } else {
            logger.warning("Could not find 'fname'");
            throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
          }
        }
        // end of backward compatibility
        sendForm(download1);
        checkErrors(downloadLink, false, passCode);
        dllink = getDllink();
      }
    }
    if (dllink == null) {
      Form dlForm = br.getFormbyProperty("name", "F1");
      if (dlForm == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      // how many forms deep do you want to try.
      int repeat = 2;
      for (int i = 0; i <= repeat; i++) {
        dlForm.remove(null);
        final long timeBefore = System.currentTimeMillis();
        boolean password = false;
        boolean skipWaittime = false;
        if (new Regex(correctedBR, PASSWORDTEXT).matches()) {
          password = true;
          logger.info("The downloadlink seems to be password protected.");
        }
        // md5 can be on the subsequent pages
        if (downloadLink.getMD5Hash() == null) {
          String md5hash = new Regex(correctedBR, "<b>MD5.*?</b>.*?nowrap>(.*?)<").getMatch(0);
          if (md5hash != null) downloadLink.setMD5Hash(md5hash.trim());
        }
        /* Captcha START */
        if (correctedBR.contains(";background:#ccc;text-align")) {
          logger.info("Detected captcha method \"plaintext captchas\" for this host");
          /** Captcha method by ManiacMansion */
          final String[][] letters =
              new Regex(
                      br,
                      "<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);
          }
          final SortedMap<Integer, String> capMap = new TreeMap<Integer, String>();
          for (String[] letter : letters) {
            capMap.put(Integer.parseInt(letter[0]), Encoding.htmlDecode(letter[1]));
          }
          final 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 (correctedBR.contains("/captchas/")) {
          logger.info("Detected captcha method \"Standard captcha\" for this host");
          final 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("xfilesharingprobasic", captchaurl, downloadLink);
          dlForm.put("code", code);
          logger.info(
              "Put captchacode "
                  + code
                  + " obtained by captcha metod \"Standard captcha\" in the form.");
        } else if (new Regex(correctedBR, "(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")
            .matches()) {
          logger.info("Detected captcha method \"Re Captcha\" for this host");
          final PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
          final jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
          final String id = new Regex(correctedBR, "\\?k=([A-Za-z0-9%_\\+\\- ]+)\"").getMatch(0);
          if (id == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
          rc.setId(id);
          rc.load();
          final File cf = rc.downloadCaptcha(getLocalCaptchaFile());
          final String c = getCaptchaCode(cf, downloadLink);
          dlForm.put("recaptcha_challenge_field", rc.getChallenge());
          dlForm.put("recaptcha_response_field", Encoding.urlEncode(c));
          logger.info(
              "Put captchacode "
                  + c
                  + " obtained by captcha metod \"Re Captcha\" in the form and submitted it.");
          /** wait time is often skippable for reCaptcha handling */
          skipWaittime = true;
        } else if (br.containsHTML("solvemedia\\.com/papi/")) {
          logger.info("Detected captcha method \"solvemedia\" for this host");
          final PluginForDecrypt solveplug = JDUtilities.getPluginForDecrypt("linkcrypt.ws");
          final jd.plugins.decrypter.LnkCrptWs.SolveMedia sm =
              ((jd.plugins.decrypter.LnkCrptWs) solveplug).getSolveMedia(br);
          final File cf = sm.downloadCaptcha(getLocalCaptchaFile());
          final String code = getCaptchaCode(cf, downloadLink);
          final String chid = sm.getChallenge(code);
          dlForm.put("adcopy_challenge", chid);
          dlForm.put("adcopy_response", "manual_challenge");
        }
        /* Captcha END */

        if (password) passCode = handlePassword(passCode, dlForm, downloadLink);

        if (!skipWaittime) waitTime(timeBefore, downloadLink);

        sendForm(dlForm);
        logger.info("Submitted DLForm");

        dllink = getDllink();
        if (dllink == null
            && (!br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"") || i == repeat)) {
          checkErrors(downloadLink, true, passCode);
          logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!");
          break;
        } else if (dllink == null
            && br.containsHTML("<Form name=\"F1\" method=\"POST\" action=\"\"")) {
          dlForm = br.getFormbyProperty("name", "F1");
          continue;
        } else {
          break;
        }
      }
    }
    checkErrors(downloadLink, true, passCode);
    if (dllink == null) 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")) {
      if (dl.getConnection().getResponseCode() == 503)
        throw new PluginException(
            LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
            "Connection limit reached, please contact our support!",
            5 * 60 * 1000l);
      logger.warning("The final dllink seems not to be a file!");
      br.followConnection();
      correctBR();
      checkServerErrors();
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    downloadLink.setProperty(directlinkproperty, dllink);
    if (passCode != null) downloadLink.setProperty("pass", passCode);
    fixFilename(downloadLink);
    try {
      // add a download slot
      controlFree(+1);
      // start the dl
      dl.startDownload();
    } finally {
      // remove download slot
      controlFree(-1);
    }
  }