Ejemplo n.º 1
0
  @SuppressWarnings("deprecation")
  public void doFree(
      DownloadLink downloadLink, boolean resumable, int maxchunks, boolean checkFastWay)
      throws Exception, PluginException {
    String passCode = null;
    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");
      if (dllink != null) {
        try {
          Browser br2 = br.cloneBrowser();
          URLConnectionAdapter con = br2.openGetConnection(dllink);
          if (con.getContentType().contains("html") || con.getLongContentLength() == -1) {
            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) {
      checkErrors(downloadLink, false, passCode);
      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();
        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);
      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);
        rc.prepareForm(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);
    }
    downloadLink.setProperty("freelink", dllink);
    if (passCode != null) downloadLink.setProperty("pass", passCode);
    dl.startDownload();
  }
Ejemplo n.º 2
0
  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();
  }
Ejemplo n.º 3
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);
   }
 }
Ejemplo n.º 4
0
  @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();
  }