コード例 #1
0
  // @Override
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();

    br.getPage(parameter);

    Form form = br.getForm(1);
    for (int i = 0; i <= 5; i++) {
      String code = getCaptchaCode("http://alpha-link.eu/captcha/captcha.php", param);
      form.put("captcha", code);
      form.setAction(parameter);
      br.submitForm(form);
      if (!br.containsHTML("(Code ist falsch)|(kein Code eingegeben)")) break;
    }
    form = br.getForm(1);
    String[] ids = br.getRegex("class='btn' name='id' value='(\\d+)'").getColumn(0);
    if (ids.length == 0) return null;
    progress.setRange(ids.length);
    for (String id : ids) {
      form.put("id", id);
      br.submitForm(form);

      String codedLink = br.getRegex("src=.\"(.*?).\"").getMatch(0);
      if (codedLink == null) return null;
      String link = Encoding.htmlDecode(codedLink);

      decryptedLinks.add(createDownloadlink(link));
      progress.increase(1);
    }
    return decryptedLinks;
  }
コード例 #2
0
 // @Override
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   String parameter = param.toString();
   br.getPage(parameter);
   for (int retry = 0; retry < 5; retry++) {
     String loc = br.getRedirectLocation();
     if (loc != null) {
       decryptedLinks.add(createDownloadlink(br.getRedirectLocation()));
       return decryptedLinks;
     } else {
       String whatis = br.getRegex("alt=\"What is (.*?) = \"").getMatch(0);
       if (whatis == null) return null;
       String calc[] = whatis.split(" ");
       if (calc.length != 3) return null;
       Form form = br.getForm(0);
       if (calc[1].equalsIgnoreCase("*")) {
         form.put("__ec_s", "" + (Integer.parseInt(calc[0]) * Integer.parseInt(calc[2])));
       } else if (calc[1].equalsIgnoreCase("+")) {
         form.put("__ec_s", "" + (Integer.parseInt(calc[0]) + Integer.parseInt(calc[2])));
       } else if (calc[1].equalsIgnoreCase("-")) {
         form.put("__ec_s", "" + (Integer.parseInt(calc[0]) - Integer.parseInt(calc[2])));
       } else if (calc[1].equalsIgnoreCase("/")) {
         form.put("__ec_s", "" + (Double.parseDouble(calc[0]) / Double.parseDouble(calc[2])));
       }
       br.submitForm(form);
     }
   }
   return null;
 }
コード例 #3
0
 @SuppressWarnings("unchecked")
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /** Load cookies */
       br.setCookiesExclusive(true);
       prepBrowser(br);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch)
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(COOKIE_HOST, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       getPage(COOKIE_HOST + "/login.html");
       final Form loginform = br.getFormbyProperty("name", "FL");
       if (loginform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       loginform.put("login", Encoding.urlEncode(account.getUser()));
       loginform.put("password", Encoding.urlEncode(account.getPass()));
       sendForm(loginform);
       if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null)
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       if (!br.getURL().contains("/?op=my_account")) {
         getPage("/?op=my_account");
       }
       if (!new Regex(correctedBR, "(Premium(\\-| )Account expire|>Renew premium<)").matches()) {
         account.setProperty("nopremium", true);
       } else {
         account.setProperty("nopremium", false);
       }
       /** Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(COOKIE_HOST);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
コード例 #4
0
  private boolean handlePassword() throws DecrypterException, IOException {
    final boolean passwordRequired;
    if ((this.br.getRedirectLocation() != null
            && this.br.getRedirectLocation().contains(urlpart_passwordneeded))
        || this.br.getURL().contains(urlpart_passwordneeded)) {
      logger.info("Blog password needed");
      passwordRequired = true;

      // final String password_required_url;
      // if (this.br.getRedirectLocation() != null) {
      // password_required_url = this.br.getRedirectLocation();
      // } else {
      // password_required_url = this.br.getURL();
      // }
      // final String blog_user = new Regex(password_required_url, "/blog_auth/(.+)").getMatch(0);
      // if (blog_user != null) {
      // this.br = prepBR(new Browser());
      // this.br.setFollowRedirects(true);
      // this.br.getPage("https://www.tumblr.com/blog_auth/" + blog_user);
      // } else {
      // this.br.setFollowRedirects(true);
      // }

      boolean success = false;
      for (int i = 0; i <= 2; i++) {
        if (this.passCode == null) {
          this.passCode = getUserInput("Password?", this.param);
        }
        Form form = br.getFormbyKey("auth");
        if (form == null) {
          form = br.getFormbyKey("password");
        }
        form.put("password", Encoding.urlEncode(this.passCode));
        br.submitForm(form);
        form = br.getFormbyKey("auth");
        if (form != null) {
          form.put("password", Encoding.urlEncode(passCode));
          br.submitForm(form);
        }
        if (this.br.getURL().contains(urlpart_passwordneeded)) {
          passCode = null;
          continue;
        }
        success = true;
        break;
      }
      if (!success) {
        throw new DecrypterException(DecrypterException.PASSWORD);
      }
      this.br.setFollowRedirects(false);
    } else {
      passwordRequired = false;
    }
    return passwordRequired;
  }
コード例 #5
0
 @SuppressWarnings("unchecked")
 private void login(Account account, boolean force) throws Exception {
   synchronized (LOCK) {
     /** Load cookies */
     br.setCookiesExclusive(false);
     br.setFollowRedirects(true);
     final Object ret = account.getProperty("cookies", null);
     boolean acmatch =
         Encoding.urlEncode(account.getUser())
             .matches(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
     if (acmatch)
       acmatch =
           Encoding.urlEncode(account.getPass())
               .matches(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
     if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
       final HashMap<String, String> cookies = (HashMap<String, String>) ret;
       if (account.isValid()) {
         for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
           final String key = cookieEntry.getKey();
           final String value = cookieEntry.getValue();
           this.br.setCookie(COOKIE_HOST, key, value);
         }
         return;
       }
     }
     br.setCookie(COOKIE_HOST, "lang", "english");
     br.getPage(COOKIE_HOST + "/login.html");
     Form loginform = br.getForm(0);
     if (loginform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     loginform.put("login", Encoding.urlEncode(account.getUser()));
     loginform.put("password", Encoding.urlEncode(account.getPass()));
     br.submitForm(loginform);
     if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null)
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     br.getPage(COOKIE_HOST + "/?op=my_account");
     doSomething();
     if (!new Regex(BRBEFORE, "(Premium\\-Account expire|Upgrade to premium|>Renew premium<)")
         .matches())
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     if (!new Regex(BRBEFORE, "(Premium\\-Account expire|>Renew premium<)").matches())
       account.setProperty("nopremium", "true");
     /** Save cookies */
     final HashMap<String, String> cookies = new HashMap<String, String>();
     final Cookies add = this.br.getCookies(COOKIE_HOST);
     for (final Cookie c : add.getCookies()) {
       cookies.put(c.getKey(), c.getValue());
     }
     account.setProperty("name", Encoding.urlEncode(account.getUser()));
     account.setProperty("pass", Encoding.urlEncode(account.getPass()));
     account.setProperty("cookies", cookies);
   }
 }
コード例 #6
0
ファイル: LnkPrtctrCm.java プロジェクト: sn0w/jdownloader
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   String parameter = param.toString();
   br.getPage(parameter);
   if (br.containsHTML("red>Bad Referrer!")) {
     String ref =
         br.getRegex("You could get this File only from t.*?<br><a.*?><b>(.*?)</b>").getMatch(0);
     if (ref == null) return null;
     br.getPage(ref);
     br.getPage(parameter);
   }
   boolean do_continue = false;
   for (int retrycounter = 1; retrycounter <= 5; retrycounter++) {
     if (br.containsHTML("<h1>PASSWORD PROTECTED LINK</h1>")
         || br.containsHTML("Incorrect Password")) {
       String passCode = getUserInput(null, param);
       Form pwForm = br.getForm(0);
       pwForm.put("u_password", passCode);
       br.submitForm(pwForm);
       System.out.print(br.toString());
     } else {
       do_continue = true;
       break;
     }
   }
   String link = null;
   if (do_continue == true) {
     link = br.getRegex("onClick=\"window.location='(.*?)'\" style=").getMatch(0);
     if (link == null) {
       link = br.getRegex("<form action=\"(.*?)\"").getMatch(0);
       if (link == null) link = br.getRegex("window\\.location = \"(.*?)\"").getMatch(0);
     }
     if (link == null)
       link = br.getRegex("METHOD=\"LINK\" ACTION=\"(http[^<>\"]*?)\"").getMatch(0);
     if (link == null || link.length() < 10) {
       Form form = br.getForm(0);
       if (form != null) {
         form.setMethod(MethodType.GET);
         br.setFollowRedirects(false);
         br.submitForm(form);
       }
       link = br.getRegex("frame name=\"protected\" src=\"(.*?)\"").getMatch(0);
     }
   }
   if (link != null && link.length() > 10) {
     decryptedLinks.add(createDownloadlink(link));
   } else {
     return null;
   }
   return decryptedLinks;
 }
コード例 #7
0
ファイル: UploaDriveCom.java プロジェクト: Syn4ck/jdownloader
 /**
  * Returns the first form that has a 'key' that equals 'value'.
  *
  * @param key
  * @param value
  * @return
  */
 private Form getFormByKey(final String key, final String value) {
   Form[] workaround = br.getForms();
   if (workaround != null) {
     for (Form f : workaround) {
       for (InputField field : f.getInputFields()) {
         if (key != null && key.equals(field.getKey())) {
           if (value == null && field.getValue() == null) return f;
           if (value != null && value.equals(field.getValue())) return f;
         }
       }
     }
   }
   return null;
 }
コード例 #8
0
  public void handlePremium(DownloadLink parameter, Account account) throws Exception {
    requestFileInformation(parameter);
    login(account, false);
    br.setFollowRedirects(false);
    br.setCookie(COOKIE_HOST, "mfh_mylang", "en");
    br.getPage(parameter.getDownloadURL());
    String finalLink = null;
    if (br.getRedirectLocation() != null
        && (br.getRedirectLocation().contains("access_key=")
            || br.getRedirectLocation().contains("getfile.php"))) {
      finalLink = br.getRedirectLocation();
    } else {
      if (br.containsHTML("You have got max allowed download sessions from the same IP"))
        throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 10 * 60 * 1001l);
      String passCode = null;
      if (br.containsHTML("downloadpw")) {
        logger.info("The file you're trying to download seems to be password protected...");
        Form pwform = br.getFormbyProperty("name", "myform");
        if (pwform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
        if (parameter.getStringProperty("pass", null) == null) {
          passCode = Plugin.getUserInput("Password?", parameter);
        } else {
          /* gespeicherten PassCode holen */
          passCode = parameter.getStringProperty("pass", null);
        }
        pwform.put("downloadpw", passCode);
        br.submitForm(pwform);
      }
      if (br.containsHTML("You have got max allowed download sessions from the same IP"))
        throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 10 * 60 * 1001l);
      if (br.containsHTML("Password Error")) {
        logger.warning("Wrong password!");
        parameter.setProperty("pass", null);
        throw new PluginException(LinkStatus.ERROR_RETRY);
      }

      if (passCode != null) {
        parameter.setProperty("pass", passCode);
      }
      finalLink = findLink(br);
    }
    if (finalLink == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    dl = jd.plugins.BrowserAdapter.openDownload(br, parameter, finalLink, true, 0);
    if (dl.getConnection().getContentType().contains("html")) {
      br.followConnection();
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    dl.startDownload();
  }
コード例 #9
0
ファイル: RemixShareCom.java プロジェクト: amicom/my-project
 public void handleFree(DownloadLink downloadLink) throws Exception {
   requestFileInformation(downloadLink);
   br.setFollowRedirects(false);
   if (br.containsHTML(BLOCKED)) {
     throw new PluginException(LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE, 10 * 1000l);
   }
   if (br.containsHTML("Download password")) {
     Form pw = br.getFormbyProperty("name", "pass");
     String pass = downloadLink.getStringProperty("pass", null);
     if (pass == null) {
       pass = Plugin.getUserInput("Password?", downloadLink);
     }
     pw.put("passwd", pass);
     br.submitForm(pw);
     br.getPage(br.getRedirectLocation());
     if (br.containsHTML("Incorrect password entered")) {
       downloadLink.setProperty("pass", null);
       throw new PluginException(
           LinkStatus.ERROR_FATAL, JDL.L("plugins.errors.wrongpassword", "Password wrong"));
     } else {
       downloadLink.setProperty("pass", pass);
     }
   }
   String lnk = execJS();
   if (lnk == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   if (!lnk.matches("https?://.+") && !lnk.matches("^/.+$")) {
     lnk = new Regex(lnk, "<a href=\"(http://.*?)\"").getMatch(0);
   }
   br.getPage(lnk);
   String dllink = br.getRedirectLocation();
   if (dllink == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   br.setFollowRedirects(true);
   dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, false, 1);
   if (dl.getConnection().getLongContentLength() == 0) {
     throw new PluginException(
         LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error", 2 * 60 * 60 * 1000l);
   }
   if (!(dl.getConnection().isContentDisposition())) {
     br.followConnection();
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   dl.startDownload();
 }
コード例 #10
0
ファイル: OvFileCom.java プロジェクト: xiongtec/jdownloader
 public String handlePassword(String passCode, Form pwform, DownloadLink thelink)
     throws IOException, PluginException {
   passCode = thelink.getStringProperty("pass", null);
   if (passCode == null) passCode = Plugin.getUserInput("Password?", thelink);
   pwform.put("password", passCode);
   logger.info("Put password \"" + passCode + "\" entered by user in the DLForm.");
   return Encoding.urlEncode(passCode);
 }
コード例 #11
0
ファイル: ShareRepoCom.java プロジェクト: pkim/jdownloader
 @Override
 public AvailableStatus requestFileInformation(DownloadLink link) throws Exception {
   br.setFollowRedirects(true);
   prepBrowser();
   getPage(link.getDownloadURL());
   br.setFollowRedirects(false);
   if (new Regex(
           correctedBR,
           "(No such file|>File Not Found<|>The file was removed by|Reason for deletion:\n)")
       .matches()) throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   if (correctedBR.contains(MAINTENANCE)) {
     link.getLinkStatus().setStatusText(MAINTENANCEUSERTEXT);
     return AvailableStatus.TRUE;
   }
   if (br.getURL().contains("/?op=login&redirect=")) {
     link.getLinkStatus().setStatusText(PREMIUMONLY2);
     return AvailableStatus.UNCHECKABLE;
   }
   String[] fileInfo = new String[3];
   // scan the first page
   scanInfo(fileInfo);
   // scan the second page. filesize[1] and md5hash[2] are not mission
   // critical
   if (fileInfo[0] == null) {
     Form download1 = getFormByKey("op", "download1");
     if (download1 != null) {
       download1.remove("method_premium");
       sendForm(download1);
       scanInfo(fileInfo);
     }
   }
   if (fileInfo[0] == null || fileInfo[0].equals("")) {
     if (correctedBR.contains("You have reached the download(\\-| )limit")) {
       logger.warning("Waittime detected, please reconnect to make the linkchecker work!");
       return AvailableStatus.UNCHECKABLE;
     }
     logger.warning("filename equals null, throwing \"plugin defect\"");
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   if (fileInfo[2] != null && !fileInfo[2].equals("")) link.setMD5Hash(fileInfo[2].trim());
   fileInfo[0] = fileInfo[0].replaceAll("(</b>|<b>|\\.html)", "");
   link.setFinalFileName(fileInfo[0].trim());
   if (fileInfo[1] != null && !fileInfo[1].equals(""))
     link.setDownloadSize(SizeFormatter.getSize(fileInfo[1]));
   return AvailableStatus.TRUE;
 }
コード例 #12
0
 private void login(final Account account) throws Exception {
   setBrowserExclusive();
   br.setFollowRedirects(true);
   br.getHeaders().put("User-Agent", UA.get());
   br.setCookie(COOKIE_HOST, "lang", "english");
   br.getPage(COOKIE_HOST + "/login.html");
   Form loginform = br.getForm(0);
   if (loginform == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   loginform.put("login", Encoding.urlEncode(account.getUser()));
   loginform.put("password", Encoding.urlEncode(account.getPass()));
   loginform.put("x", String.valueOf((int) (Math.random() * 57)));
   loginform.put("y", String.valueOf((int) (Math.random() * 21)));
   br.submitForm(loginform);
   br.getPage(COOKIE_HOST + "/?op=my_account");
   if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null) {
     throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
   }
 }
コード例 #13
0
ファイル: Q4ShareCom.java プロジェクト: xiongtec/jdownloader
 public String handlePassword(String passCode, Form pwform, DownloadLink thelink)
     throws IOException, PluginException {
   if (thelink.getStringProperty("pass", null) == null) {
     passCode = Plugin.getUserInput("Password?", thelink);
   } else {
     /* gespeicherten PassCode holen */
     passCode = thelink.getStringProperty("pass", null);
   }
   pwform.put("password", passCode);
   logger.info("Put password \"" + passCode + "\" entered by user in the DLForm.");
   return passCode;
 }
コード例 #14
0
  @Override
  public void handleFree(DownloadLink downloadLink) throws Exception {
    requestFileInformation(downloadLink);
    if (br.containsHTML("downloadpw")) {
      Form pwform = br.getFormbyProperty("name", "myform");
      if (pwform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      String passCode = null;
      {
        if (downloadLink.getStringProperty("pass", null) == null) {
          passCode = Plugin.getUserInput("Password?", downloadLink);

        } else {
          /* gespeicherten PassCode holen */
          passCode = downloadLink.getStringProperty("pass", null);
        }
        pwform.put("downloadpw", passCode);
        br.submitForm(pwform);
        if (br.containsHTML("Password Error")) {
          logger.warning("Wrong password!");
          downloadLink.setProperty("pass", null);
          throw new PluginException(LinkStatus.ERROR_RETRY);
        }
      }
      if (passCode != null) {
        downloadLink.setProperty("pass", passCode);
      }
    }
    // Limit errorhandling, currently this host does not have any limit but
    // if they add the limit, this should work as it is the standard phrase
    // of the script which they use!
    if (br.containsHTML("You have reached the maximum")) {
      throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 10 * 60 * 1001l);
    }
    String dllink =
        br.getRegex(
                "wnloadfile style=\"display:none\">.*?<a href=\"(.*?)\" onmouseout='window.status=\"\";return true;' onmou")
            .getMatch(0);
    dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, true, 1);
    dl.startDownload();
  }
コード例 #15
0
ファイル: CatShareNet.java プロジェクト: mirror/jdownloader
 private void loginWebsite(Account account, boolean force) throws Exception {
   synchronized (lock) {
     try {
       br.setCookiesExclusive(true);
       final Cookies cookies = account.loadCookies("");
       if (cookies != null && !force) {
         br.setCookies(this.getHost(), cookies);
         return;
       }
       getPage("http://" + this.getHost() + "/login");
       Form login = br.getForm(0);
       if (login == null) {
         logger.warning("Couldn't find login form");
         throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, getPhrase("NO_LOGIN_FORM"));
       }
       login.put("user_email", Encoding.urlEncode(account.getUser()));
       login.put("user_password", Encoding.urlEncode(account.getPass()));
       submitForm(login);
       getPage("/");
       if (br.containsHTML("(Konto:[\r\t\n ]+)*Darmowe")) {
         account.setType(AccountType.FREE);
       } else if ((br.containsHTML("(Konto:[\r\t\n ]+)*Premium \\(<b>\\d+ dni</b>\\)"))
           || (br.containsHTML(
               "(Konto:[\r\t\n ]+)+Premium \\(<b><span style=\"color: red\">\\d+ godzin</span></b>\\)"))) {
         account.setType(AccountType.PREMIUM);
       } else {
         /* Unknown account type */
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM,
             getPhrase("LOGIN_ERROR"),
             PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       account.saveCookies(br.getCookies(this.getHost()), "");
     } catch (final PluginException e) {
       account.clearCookies("");
       throw e;
     }
   }
 }
コード例 #16
0
ファイル: OshoWorldCom.java プロジェクト: Irbidan/jdownloader
  @Override
  public void handleFree(final DownloadLink downloadLink) throws Exception, PluginException {
    requestFileInformation(downloadLink);
    String dllink = this.checkDirectLink(downloadLink, "cache");
    if (dllink == null) {
      final Form f = br.getForm(0);
      InputField i = null;
      for (final InputField inputfield : f.getInputFields()) {
        if ("trackvalue".equals(inputfield.getKey())
            && inputfield.getValue().equals(downloadLink.getStringProperty("iFilename", null))) {
          i = inputfield;
          break;
        }
      }
      // lets remove all other files execpt the one we want, they are all prechecked.
      while (f.getInputField("trackvalue") != null) {
        f.remove("trackvalue");
      }
      // add the one we want
      f.addInputField(i);
      if (f != null && f.hasInputFieldByName("securityCode")) {
        // has captcha
        final String captcha =
            new Regex(br.getURL(), "https?://(?:www\\.)?oshoworld\\.com/[^/]+/").getMatch(-1)
                + "CAPTCHA/CAPTCHA_image.asp";
        final String code = this.getCaptchaCode(captcha, downloadLink);
        f.put("securityCode", Encoding.urlEncode(code));
      }
      br.setFollowRedirects(false);
      br.submitForm(f);
      // redirect show show correct.
      // they come in the form of
      // http://www.oshoarchive.com/ow-english/download.php?id=T1NITy1UaGVfQXJ0X29mX0R5aW5nXzEwLm1wMw
      // the id = base64 iFilename, if we knew the /ow-english/ (for english section) was static we
      // could theoretically bypass
      // captcha..

      dllink = br.getRedirectLocation();
      if (dllink == null) {
        throw new PluginException(LinkStatus.ERROR_CAPTCHA);
      }
    }
    dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, false, 1);
    if (dl.getConnection().getContentType().contains("html")) {
      if (dl.getConnection().getResponseCode() == 404) {
        throw new PluginException(
            LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error 404", 30 * 60 * 1000l);
      }
      br.followConnection();
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    downloadLink.setProperty("cache", dllink);
    dl.startDownload();
  }
コード例 #17
0
ファイル: FilerCx.java プロジェクト: pkim/jdownloader
 @Override
 public void handleFree(DownloadLink link) throws Exception {
   requestFileInformation(link);
   this.setBrowserExclusive();
   br.getPage(link.getDownloadURL());
   Form form = br.getForm(0);
   String captchaUrl = "http://www.filer.cx/captcha.php";
   String captchaCode = getCaptchaCode(captchaUrl, link);
   form.put("captchacode", captchaCode);
   br.submitForm(form);
   if (br.containsHTML("Captcha number error or expired")) {
     throw new PluginException(LinkStatus.ERROR_CAPTCHA);
   }
   String dllink = null;
   dllink =
       br.getRegex(
               "onclick=\"highlight\\('downloadurl'\\);\" ondblclick=\"ClipBoard\\('downloadurl'\\);\">(.*?)</textarea>")
           .getMatch(0);
   if (dllink == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   dl = jd.plugins.BrowserAdapter.openDownload(br, link, dllink, false, 1);
   dl.startDownload();
 }
コード例 #18
0
ファイル: Rlnks.java プロジェクト: Irbidan/jdownloader
 private void decryptLinks(final ArrayList<DownloadLink> decryptedLinks, final CryptedLink param)
     throws Exception {
   br.setFollowRedirects(false);
   final String[] matches = br.getRegex("getFile\\('(cid=\\w*?&lid=\\d*?)'\\)").getColumn(0);
   try {
     Browser brc = null;
     for (final String match : matches) {
       Thread.sleep(2333);
       handleCaptchaAndPassword("http://www.relink.us/frame.php?" + match, param);
       if (ALLFORM != null && ALLFORM.getRegex("captcha").matches()) {
         logger.warning("Falsche Captcheingabe, Link wird übersprungen!");
         continue;
       }
       brc = br.cloneBrowser();
       if (brc != null
           && brc.getRedirectLocation() != null
           && brc.getRedirectLocation().contains("relink.us/getfile")) {
         brc.getPage(brc.getRedirectLocation());
       }
       if (brc.getRedirectLocation() != null) {
         final DownloadLink dl =
             createDownloadlink(Encoding.htmlDecode(brc.getRedirectLocation()));
         try {
           distribute(dl);
         } catch (final Throwable e) {
           /* does not exist in 09581 */
         }
         decryptedLinks.add(dl);
         break;
       } else {
         final String url = brc.getRegex("iframe.*?src=\"(.*?)\"").getMatch(0);
         final DownloadLink dl = createDownloadlink(Encoding.htmlDecode(url));
         if (url != null) {
           try {
             distribute(dl);
           } catch (final Throwable e) {
             /* does not exist in 09581 */
           }
           decryptedLinks.add(dl);
         } else {
           /* as bot detected */
           return;
         }
       }
       PROGRESS.increase(1);
     }
   } finally {
     br.setFollowRedirects(true);
   }
 }
コード例 #19
0
ファイル: UploaDriveCom.java プロジェクト: Syn4ck/jdownloader
 private String handlePassword(final Form pwform, final DownloadLink thelink)
     throws PluginException {
   if (passCode == null) passCode = Plugin.getUserInput("Password?", thelink);
   if (passCode == null || passCode.equals("")) {
     logger.info("User has entered blank password, exiting handlePassword");
     passCode = null;
     thelink.setProperty("pass", Property.NULL);
     return null;
   }
   if (pwform == null) {
     // so we know handlePassword triggered without any form
     logger.info("Password Form == null");
   } else {
     logger.info("Put password \"" + passCode + "\" entered by user in the DLForm.");
     pwform.put("password", Encoding.urlEncode(passCode));
   }
   thelink.setProperty("pass", passCode);
   return passCode;
 }
コード例 #20
0
ファイル: DownloadAniMe.java プロジェクト: pkim/jdownloader
 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);
   }
 }
コード例 #21
0
  @Override
  public void handleFree(DownloadLink downloadLink) throws Exception {
    requestFileInformation(downloadLink);
    br.setFollowRedirects(false);

    if (br.containsHTML("You have reached")) {
      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;
      throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime);
    } else {
      Form form = br.getFormbyProperty("name", "F1");
      if (form == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      /* "Captcha Method" */
      String[][] letters =
          br.getRegex(
                  "<span style='position:absolute;padding-left:(\\d+)px;padding-top:\\d+px;'>(\\d)</span>")
              .getMatches();
      if (letters.length == 0) 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);
      }

      form.put("code", code.toString());
      form.setAction(downloadLink.getDownloadURL());
      // Ticket Time
      int tt = Integer.parseInt(br.getRegex("countdown\">(\\d+)</span>").getMatch(0));
      sleep(tt * 1001, downloadLink);
      br.submitForm(form);
      URLConnectionAdapter con2 = br.getHttpConnection();
      String dllink = br.getRedirectLocation();
      if (con2.getContentType().contains("html")) {
        String error = br.getRegex("class=\"err\">(.*?)</font>").getMatch(0);
        if (error != null) {
          logger.warning(error);
          con2.disconnect();
          if (error.equalsIgnoreCase("Wrong captcha")
              || error.equalsIgnoreCase("Expired session")) {
            throw new PluginException(LinkStatus.ERROR_CAPTCHA);
          } else {
            throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, error, 10000);
          }
        }
        if (br.containsHTML("Download Link Generated"))
          dllink = br.getRegex("padding:7px;\">\\s+<a\\s+href=\"(.*?)\">").getMatch(0);
      }
      if (dllink == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, true, 0);
      dl.startDownload();
    }
  }
コード例 #22
0
ファイル: RedBunkerNet.java プロジェクト: amicom/my-project
 @SuppressWarnings("unchecked")
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /** Load cookies */
       br.setCookiesExclusive(true);
       prepBrowser(br);
       final Object ret = account.getProperty("cookies", null);
       boolean acmatch =
           Encoding.urlEncode(account.getUser())
               .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
       if (acmatch) {
         acmatch =
             Encoding.urlEncode(account.getPass())
                 .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
       }
       if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
         final HashMap<String, String> cookies = (HashMap<String, String>) ret;
         if (account.isValid()) {
           for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
             final String key = cookieEntry.getKey();
             final String value = cookieEntry.getValue();
             this.br.setCookie(COOKIE_HOST, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       getPage(COOKIE_HOST + "/login.html");
       final String lang = System.getProperty("user.language");
       final Form loginform = br.getFormbyProperty("name", "FL");
       if (loginform == null) {
         if ("de".equalsIgnoreCase(lang)) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin defekt, bitte den JDownloader Support kontaktieren!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin broken, please contact the JDownloader Support!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       loginform.put("login", Encoding.urlEncode(account.getUser()));
       loginform.put("password", Encoding.urlEncode(account.getPass()));
       sendForm(loginform);
       if (br.getCookie(COOKIE_HOST, "login") == null
           || br.getCookie(COOKIE_HOST, "xfss") == null) {
         if ("de".equalsIgnoreCase(lang)) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nSchnellhilfe: \r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen?\r\nFalls dein Passwort Sonderzeichen enthält, ändere es und versuche es erneut!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nInvalid username/password!\r\nQuick help:\r\nYou're sure that the username and password you entered are correct?\r\nIf your password contains special characters, change it (remove them) and try again!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       if (!br.getURL().contains("/?op=my_account")) {
         getPage("/?op=my_account");
       }
       if (!new Regex(correctedBR, "(Premium(\\-| )Account expire|>Renew premium<)").matches()) {
         account.setProperty("nopremium", true);
       } else {
         account.setProperty("nopremium", false);
       }
       /** Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(COOKIE_HOST);
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("name", Encoding.urlEncode(account.getUser()));
       account.setProperty("pass", Encoding.urlEncode(account.getPass()));
       account.setProperty("cookies", cookies);
     } catch (final PluginException e) {
       account.setProperty("cookies", Property.NULL);
       throw e;
     }
   }
 }
コード例 #23
0
ファイル: RedBunkerNet.java プロジェクト: amicom/my-project
  @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);
    }
  }
コード例 #24
0
ファイル: HotFileCom.java プロジェクト: Horstman/JDownloader
 @SuppressWarnings("unchecked")
 public void loginWebsite(final Account account) throws IOException, PluginException {
   setBrowserExclusive();
   synchronized (HotFileCom.LOCK) {
     br.setDebug(true);
     br.getHeaders().put("User-Agent", ua);
     br.setCookie("http://hotfile.com", "lang", "en");
     final Object ret = account.getProperty("cookies", null);
     if (ret != null
         && ret instanceof HashMap<?, ?>
         && getPluginConfig().getBooleanProperty(HotFileCom.TRY_IWL_BYPASS, false)) {
       logger.info("Use cookie login");
       /* use saved cookies */
       final HashMap<String, String> cookies = (HashMap<String, String>) ret;
       for (final String key : cookies.keySet()) {
         br.setCookie("http://hotfile.com/", key, cookies.get(key));
       }
       br.setFollowRedirects(true);
       br.getPage("http://hotfile.com/");
       br.setFollowRedirects(false);
       String isPremium =
           br.getRegex("Account:.*?label.*?centerSide[^/]*?>(Premium)<").getMatch(0);
       if (isPremium == null)
         isPremium = br.getRegex("centerSide\"><p><span>(Premium)</span>").getMatch(0);
       if (isPremium == null) {
         account.setProperty("cookies", null);
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
     } else {
       /* normal login */
       br.setFollowRedirects(true);
       br.getPage("http://hotfile.com/");
       br.postPage(
           "http://hotfile.com/login.php",
           "returnto=%2F&user="******"&pass="******"<td>Username:"******"cookies", null);
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       if (br.getCookie("http://hotfile.com/", "auth") == null) {
         account.setProperty("cookies", null);
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       String isPremium =
           br.getRegex("Account:.*?label.*?centerSide[^/]*?>(Premium)<").getMatch(0);
       if (isPremium == null)
         isPremium = br.getRegex("centerSide\"><p><span>(Premium)</span>").getMatch(0);
       if (isPremium == null) {
         account.setProperty("cookies", null);
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = br.getCookies("http://hotfile.com/");
       for (final Cookie c : add.getCookies()) {
         cookies.put(c.getKey(), c.getValue());
       }
       account.setProperty("cookies", cookies);
       br.setFollowRedirects(false);
     }
   }
 }
コード例 #25
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);
   }
 }
コード例 #26
0
ファイル: SubyShareCom.java プロジェクト: munix/jdget
 @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);
   }
 }
コード例 #27
0
ファイル: OvFileCom.java プロジェクト: xiongtec/jdownloader
  @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();
  }
コード例 #28
0
  @Override
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();
    FilePackage fp = FilePackage.getInstance();
    br.setFollowRedirects(false);
    br.getPage(parameter);
    boolean decrypterBroken = false;
    if (decrypterBroken) return null;

    /* Error handling */
    if (br.containsHTML("This data has been removed by the owner")) {
      logger.warning("Wrong link");
      logger.warning(
          JDL.L(
              "plugins.decrypt.errormsg.unavailable",
              "Perhaps wrong URL or the download is not available anymore."));
      return new ArrayList<DownloadLink>();
    }

    /* File package handling */
    for (int i = 0; i <= 5; i++) {
      Form captchaForm = br.getForm(1);
      if (captchaForm == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      String passCode = null;
      String captchalink0 = br.getRegex("src=\"(mUSystem.*?)\"").getMatch(0);
      String captchalink = "http://protect-my-links.com/" + captchalink0;
      if (captchalink0.contains("null")) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      String code = getCaptchaCode(captchalink, param);
      captchaForm.put("captcha", code);

      if (br.containsHTML("Password :"******"passwd", passCode);
      }
      br.submitForm(captchaForm);
      if (br.containsHTML("Captcha is not valid") || br.containsHTML("Password is not valid"))
        continue;
      break;
    }
    if (br.containsHTML("Captcha is not valid"))
      throw new PluginException(LinkStatus.ERROR_CAPTCHA);
    String fpName = br.getRegex("h1 class=\"pmclass\">(.*?)</h1></td>").getMatch(0).trim();
    fp.setName(fpName);
    String[] links = br.getRegex("><a href='(/\\?p=.*?)'").getColumn(0);
    if (links == null || links.length == 0) return null;
    progress.setRange(links.length);
    for (String psp : links) {
      // Fixed, thx to [email protected]
      br.getPage("http://protect-my-links.com" + psp);
      String c = br.getRegex("javascript>c=\"(.*?)\";").getMatch(0);
      String x = br.getRegex("x\\(\"(.*?)\"\\)").getMatch(0);
      if (c == null || x == null) return null;
      String step1Str = step1(c);
      if (step1Str == null) return null;
      ArrayList<Integer> step2Lst = step2(step1Str);
      if (step2Lst == null || step2Lst.size() == 0) return null;
      String step3Str = step3(step2Lst, x);
      if (step3Str == null) return null;
      String finallink = step4(step3Str);
      if (finallink == null) return null;
      decryptedLinks.add(createDownloadlink(finallink));
      progress.increase(1);
    }
    fp.addLinks(decryptedLinks);
    return decryptedLinks;
  }
コード例 #29
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);
    }
  }
コード例 #30
0
ファイル: Q4ShareCom.java プロジェクト: xiongtec/jdownloader
  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();
  }