Ejemplo n.º 1
0
  public void doFreeWebsite(
      final DownloadLink downloadLink, final boolean resumable, final int maxChunks)
      throws Exception, PluginException {
    checkErrorsWebsite(downloadLink, true);

    String dllink = null;
    long timeBefore = System.currentTimeMillis();
    boolean password = false;
    boolean skipWaittime = false;

    // only ReCaptcha
    Form dlForm = new Form();
    if (new Regex(brbefore, "(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)").matches()) {
      dlForm = br.getForm(0);
      if (dlForm == null) {
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, getPhrase("NO_RECAPTCHA_FORM"));
      }

      logger.info("Detected captcha method \"Re Captcha\" for this host");
      final Recaptcha rc = new Recaptcha(br, this);
      rc.setForm(dlForm);
      String id = br.getRegex("\\?k=([A-Za-z0-9%_\\+\\- ]+)\"").getMatch(0);
      rc.setId(id);
      for (int i = 0; i < 5; i++) {
        rc.load();
        File cf = rc.downloadCaptcha(getLocalCaptchaFile());
        String c = getCaptchaCode("recaptcha", 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;
        submitForm(dlForm);
        logger.info("Submitted DLForm");
        if (br.containsHTML("(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")) {
          rc.reload();
          continue;
        }
        break;
      }

    } else {
      logger.warning("Unknown ReCaptcha method for: " + downloadLink.getDownloadURL());
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, getPhrase("UNKNOWN_RECAPTCHA"));
    }

    /* Captcha END */
    // if (password) passCode = handlePassword(passCode, dlForm, downloadLink);
    if (br.containsHTML("(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")) {
      logger.info("5 reCaptcha tryouts for <" + downloadLink.getDownloadURL() + "> were incorrect");
      throw new PluginException(
          LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, getPhrase("RECAPTCHA_ERROR"), 1 * 60 * 1000l);
    }

    doSomething();
    checkErrorsWebsite(downloadLink, false);
    dllink = getDllinkWebsite();
    if (dllink == null) {
      logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!");
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, getPhrase("REGEX_ERROR"));
    }
    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, getPhrase("FINAL_LINK_ERROR"));
    }
    downloadLink.setProperty("freelink", dllink);
    dl.startDownload();
  }
Ejemplo n.º 2
0
 public void doFree(final DownloadLink downloadLink, final boolean resume, final int maxchunks)
     throws Exception, PluginException {
   boolean captcha = false;
   if (br.getURL().contains(SIMULTANDLSLIMIT) || br.getURL().contains(SIMULTANDLSLIMIT_2)) {
     throw new PluginException(
         LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
         SIMULTANDLSLIMITUSERTEXT,
         1 * 60 * 1000l);
   } else if (br.getURL().contains(SERVERERROR)) {
     throw new PluginException(
         LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, SERVERERRORUSERTEXT, 5 * 60 * 1000l);
   }
   String free_link =
       br.getRegex("\\'(https?://depofile\\.info/[^<>\"]+\\?pt=[^<>\"]*?)\\'").getMatch(0);
   if (free_link == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   final String waittime =
       br.getRegex("\\$\\(\\'\\.download\\-timer\\-seconds\\'\\)\\.html\\((\\d+)\\);").getMatch(0);
   if (waittime != null) {
     sleep(Integer.parseInt(waittime) * 1001l, downloadLink);
   }
   dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, free_link, RESUME, MAXCHUNKS);
   if (!dl.getConnection().isContentDisposition()) {
     br.followConnection();
     if (br.getURL().contains(SERVERERROR)) {
       throw new PluginException(
           LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, SERVERERRORUSERTEXT, 5 * 60 * 1000l);
     }
     final String captchaAction =
         br.getRegex(
                 "<div class=\"captchaPageTable\">[\t\n\r ]+<form method=\"POST\" action=\"(http://[^<>\"]*?)\"")
             .getMatch(0);
     final String rcID = br.getRegex("recaptcha/api/noscript\\?k=([^<>\"]*?)\"").getMatch(0);
     if (rcID == null || captchaAction == null) {
       logger.warning("reCaptcha_ID or captchaAction NULL - plugin seems to be broken!");
       throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     }
     final Recaptcha rc = new Recaptcha(br, this);
     rc.setId(rcID);
     rc.load();
     for (int i = 0; i <= 5; i++) {
       File cf = rc.downloadCaptcha(getLocalCaptchaFile());
       String c = getCaptchaCode("recaptcha", cf, downloadLink);
       dl =
           jd.plugins.BrowserAdapter.openDownload(
               br,
               downloadLink,
               captchaAction,
               "submit=continue&submitted=1&d=1&recaptcha_challenge_field="
                   + rc.getChallenge()
                   + "&recaptcha_response_field="
                   + c,
               RESUME,
               MAXCHUNKS);
       if (!dl.getConnection().isContentDisposition()) {
         br.followConnection();
         rc.reload();
         continue;
       }
       break;
     }
     captcha = true;
   }
   if (!dl.getConnection().isContentDisposition()) {
     br.followConnection();
     if (captcha && br.containsHTML("(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)")) {
       throw new PluginException(LinkStatus.ERROR_CAPTCHA);
     }
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   dl.startDownload();
 }