示例#1
0
 /**
  * Holt den Dateinamen aus einem Content-Disposition header. wird dieser nicht gefunden, wird der
  * dateiname aus der url ermittelt
  *
  * @param urlConnection
  * @return Filename aus dem header (content disposition) extrahiert
  */
 public static String getFileNameFromHeader(final URLConnectionAdapter urlConnection) {
   if (urlConnection.getHeaderField("Content-Disposition") == null
       || urlConnection.getHeaderField("Content-Disposition").indexOf("filename") < 0) {
     return Plugin.getFileNameFromURL(urlConnection.getURL());
   }
   return Plugin.getFileNameFromDispositionHeader(
       urlConnection.getHeaderField("Content-Disposition"));
 }
 protected LogInterface getLogger() {
   LogInterface logger = null;
   final Plugin plg = captchaChallenge.getPlugin();
   if (plg != null) {
     if (plg instanceof PluginForHost) {
       logger = plg.getLogger();
     } else if (plg instanceof PluginForDecrypt) {
       logger = plg.getLogger();
     }
   }
   if (logger == null) {
     logger = org.appwork.utils.logging2.extmanager.LoggerFactory.getDefaultLogger();
   }
   return logger;
 }
示例#3
0
 private void handlePassword(final DownloadLink dl) throws PluginException, IOException {
   if (br.getURL().contains("/file_password.html")) {
     logger.info("Current link is password protected");
     String passCode = dl.getStringProperty("pass", null);
     if (passCode == null) {
       passCode = Plugin.getUserInput("Password?", dl);
       if (passCode == null || passCode.equals("")) {
         logger.info("User has entered blank password, exiting handlePassword");
         dl.setProperty("pass", Property.NULL);
         throw new PluginException(LinkStatus.ERROR_RETRY, "Wrong password entered");
       }
       dl.setProperty("pass", passCode);
     }
     br.postPage(
         br.getURL(),
         "submit=access+file&submitme=1&file="
             + this.getFID(dl)
             + "&filePassword="******"/file_password.html")) {
       logger.info("User entered incorrect password --> Retrying");
       dl.setProperty("pass", Property.NULL);
       throw new PluginException(LinkStatus.ERROR_RETRY, "Wrong password entered");
     }
     logger.info("User entered correct password --> Continuing");
   }
 }
示例#4
0
 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);
 }
示例#5
0
 public static String doFilenameEncoding(final Plugin plugin, String filename) {
   filename = Encoding.htmlDecode(filename).trim();
   filename = plugin.encodeUnicode(filename);
   filename = HTMLEntities.unhtmlentities(filename);
   filename = HTMLEntities.unhtmlAmpersand(filename);
   filename = HTMLEntities.unhtmlAngleBrackets(filename);
   filename = HTMLEntities.unhtmlSingleQuotes(filename);
   filename = HTMLEntities.unhtmlDoubleQuotes(filename);
   filename = filename.replaceAll("&apos;", "'");
   return filename;
 }
示例#6
0
 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;
 }
示例#7
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();
  }
示例#8
0
 public AvailableStatus requestFileInformation(DownloadLink downloadLink)
     throws IOException, InterruptedException, PluginException {
   this.setBrowserExclusive();
   br.setCustomCharset("UTF-8");
   br.setFollowRedirects(true);
   URLConnectionAdapter con = br.openGetConnection(downloadLink.getDownloadURL());
   if (con.isContentDisposition()) {
     downloadLink.setFinalFileName(Plugin.getFileNameFromHeader(con));
     downloadLink.setDownloadSize(con.getLongContentLength());
     con.disconnect();
     return AvailableStatus.TRUE;
   } else {
     return AvailableStatus.FALSE;
   }
 }
示例#9
0
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();
    String uid = new Regex(parameter, "([a-z0-9]{7})$").getMatch(0);

    br.getPage(parameter);
    if (br.containsHTML("<div id=\"error\">пакет не найден<")) {
      logger.info("Wrong URL or the package no longer exists.");
      return decryptedLinks;
    }
    String title = br.getRegex("<title>(.*?)</title>").getMatch(0);
    if (title == null) title = "";

    /* Password protected package */
    if (br.containsHTML(">пакет защищен паролем<")) {
      for (int i = 0; i <= 3; i++) {
        final String passCode = Plugin.getUserInput("Enter password for: " + title, param);
        br.postPage(parameter, "put_pwd=" + Encoding.urlEncode(passCode));
        if (br.containsHTML(">пакет защищен паролем<")) continue;
        break;
      }
      if (br.containsHTML(">пакет защищен паролем<"))
        throw new DecrypterException(DecrypterException.PASSWORD);
      if (br.getRedirectLocation() != null) br.getPage(br.getRedirectLocation());
    }

    String domain = new Regex(br.getURL(), "(https?://[^/]+)").getMatch(0);

    String[] links = br.getRegex("href=\"(/download/" + uid + "/[^\"]+)").getColumn(0);
    if (links == null || links.length == 0) {
      logger.warning("Decrypter broken for link: " + parameter);
      return null;
    }

    for (String link : links) {
      decryptedLinks.add(createDownloadlink("directhttp://" + domain + link));
    }

    if (title != null || !title.equals("")) {
      FilePackage fp = FilePackage.getInstance();
      fp.setName(Encoding.htmlDecode(title.trim()));
      fp.addLinks(decryptedLinks);
    }

    return decryptedLinks;
  }
示例#10
0
 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();
 }
示例#11
0
 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;
 }
示例#12
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();
  }
示例#13
0
  // @Override
  public void handleFree(DownloadLink downloadLink) throws Exception {
    requestFileInformation(downloadLink);
    /* Link holen */
    HashMap<String, String> submitvalues = HTMLParser.getInputHiddenFields(br.toString());
    postdata = "act=" + Encoding.urlEncode(submitvalues.get("act"));
    postdata = postdata + "&id=" + Encoding.urlEncode(submitvalues.get("id"));
    postdata = postdata + "&fname=" + Encoding.urlEncode(submitvalues.get("fname"));
    if (br.containsHTML("type=\"password\" name=\"password\"")) {
      String password =
          Plugin.getUserInput(
              JDL.L("plugins.hoster.speedysharecom.password", "Enter Password:"******"")) {
        postdata = postdata + "&password=" + Encoding.urlEncode(password);
      }
    }

    /* Zwangswarten, 30seks */
    sleep(30000, downloadLink);

    /* Datei herunterladen */
    jd.plugins.BrowserAdapter.openDownload(
            br, downloadLink, downloadLink.getDownloadURL(), postdata)
        .startDownload();
  }
示例#14
0
 public static String getFileNameFromURL(final URL url) {
   return Plugin.extractFileNameFromURL(url.toExternalForm());
 }
示例#15
0
  @Override
  public void handleFree(DownloadLink link) throws Exception {
    this.setBrowserExclusive();
    requestFileInformation(link);
    if (br.containsHTML("value=\"Free Users\""))
      br.postPage(link.getDownloadURL(), "Free=Free+Users");
    String passCode = null;
    Form captchaform = br.getFormbyProperty("name", "myform");
    if (captchaform == null) {
      captchaform = br.getFormbyProperty("name", "validateform");
      if (captchaform == null) {
        captchaform = br.getFormbyProperty("name", "valideform");
      }
    }
    if (br.containsHTML("(captcha.php|class=textinput name=downloadpw)")) {
      if (captchaform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      for (int i = 0; i <= 3; i++) {
        if (br.containsHTML("captcha.php")) {
          String captchaurl = COOKIE_HOST + "/captcha.php";
          String code = getCaptchaCode(captchaurl, link);
          captchaform.put("captchacode", code);
        }
        if (br.containsHTML("class=textinput name=downloadpw")) {
          if (link.getStringProperty("pass", null) == null) {
            passCode = Plugin.getUserInput("Password?", link);

          } else {
            /* gespeicherten PassCode holen */
            passCode = link.getStringProperty("pass", null);
          }
          captchaform.put("downloadpw", passCode);
        }
        br.submitForm(captchaform);
        if (br.containsHTML("Password Error")) {
          logger.warning("Wrong password!");
          link.setProperty("pass", null);
          continue;
        }
        if (br.containsHTML("Captcha number error")
            || br.containsHTML("captcha.php")
                && !br.containsHTML("You have got max allowed bandwidth size per hour")) {
          logger.warning("Wrong captcha or wrong password!");
          link.setProperty("pass", null);
          continue;
        }
        break;
      }
    }
    if (br.containsHTML("Password Error")) {
      logger.warning("Wrong password!");
      link.setProperty("pass", null);
      throw new PluginException(LinkStatus.ERROR_RETRY);
    }
    if (br.containsHTML("Captcha number error")
        || br.containsHTML("captcha.php")
            && !br.containsHTML("You have got max allowed bandwidth size per hour")) {
      logger.warning("Wrong captcha or wrong password!");
      link.setProperty("pass", null);
      throw new PluginException(LinkStatus.ERROR_CAPTCHA);
    }
    if (passCode != null) {
      link.setProperty("pass", passCode);
    }
    if (br.containsHTML("You have got max allowed bandwidth size per hour"))
      throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 10 * 60 * 1001l);
    String finalLink = findLink();
    if (finalLink == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    dl = jd.plugins.BrowserAdapter.openDownload(br, link, finalLink, true, 1);
    if (dl.getConnection().getContentType().contains("html")) {
      br.followConnection();
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    dl.startDownload();
  }
示例#16
0
 @Override
 public void handlePremium(final DownloadLink downloadLink, final Account account)
     throws Exception {
   String passCode = null;
   requestFileInformation(downloadLink);
   login(account);
   br.setFollowRedirects(false);
   br.getPage(downloadLink.getDownloadURL());
   String dllink = br.getRedirectLocation();
   if (dllink == null) {
     Form DLForm = br.getFormbyProperty("name", "F1");
     if (DLForm == null) {
       throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     }
     if (br.containsHTML("(<b>Passwort:</b>|<b>Password:</b>)")) {
       logger.info("The downloadlink seems to be password protected.");
       if (downloadLink.getStringProperty("pass", null) == null) {
         passCode = Plugin.getUserInput("Password?", downloadLink);
       } else {
         /* gespeicherten PassCode holen */
         passCode = downloadLink.getStringProperty("pass", null);
       }
       DLForm.put("password", passCode);
       logger.info(
           "Put password \"" + passCode + "\" entered by user in the DLForm and submitted it.");
     }
     br.submitForm(DLForm);
     if (br.containsHTML("(Wrong password|<b>Passwort:</b>|<b>Password:</b>)")) {
       logger.warning(
           "Wrong password, the entered password \"" + passCode + "\" is wrong, retrying...");
       downloadLink.setProperty("pass", null);
       throw new PluginException(LinkStatus.ERROR_RETRY);
     }
     dllink = br.getRedirectLocation();
     if (dllink == null) {
       dllink = getDllink();
     }
   }
   if (dllink == null) {
     handleErrors();
     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...");
   int chunks = -5;
   boolean resume = true;
   if (downloadLink.getBooleanProperty(JumboFilesCom.NOCHUNKS, false) || resume == false) {
     chunks = 1;
   }
   dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, resume, chunks);
   if (passCode != null) {
     downloadLink.setProperty("pass", passCode);
   }
   if (dl.getConnection().getContentType() != null
       && dl.getConnection().getContentType().contains("html")) {
     logger.warning("The final dllink seems not to be a file!");
     br.followConnection();
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   if (!this.dl.startDownload()) {
     try {
       if (dl.externalDownloadStop()) {
         return;
       }
     } catch (final Throwable e) {
     }
     if (downloadLink.getLinkStatus().getErrorMessage() != null
         && downloadLink
             .getLinkStatus()
             .getErrorMessage()
             .startsWith(
                 JDL.L(
                     "download.error.message.rangeheaders",
                     "Server does not support chunkload"))) {
       if (downloadLink.getBooleanProperty(JumboFilesCom.NORESUME, false) == false) {
         downloadLink.setChunksProgress(null);
         downloadLink.setProperty(JumboFilesCom.NORESUME, Boolean.valueOf(true));
         throw new PluginException(LinkStatus.ERROR_RETRY);
       }
     } else {
       /* unknown error, we disable multiple chunks */
       if (downloadLink.getBooleanProperty(JumboFilesCom.NOCHUNKS, false) == false) {
         downloadLink.setProperty(JumboFilesCom.NOCHUNKS, Boolean.valueOf(true));
         throw new PluginException(LinkStatus.ERROR_RETRY);
       }
     }
   }
 }
 @Override
 public boolean isSelectorBannedByPlugin(final Plugin plugin, final boolean ignoreConnectBans) {
   final String host = plugin.getHost();
   return !ignoreConnectBans && StringUtils.containsIgnoreCase(getHost(), host);
 }
示例#18
0
 public void handlePremiumWebsite(final DownloadLink downloadLink, final Account account)
     throws Exception {
   loginWebsite(account);
   String finalUrl = null;
   br.getPage(downloadLink.getDownloadURL());
   if (br.getRedirectLocation() != null) {
     finalUrl = br.getRedirectLocation();
   } else {
     if (br.containsHTML("span>Free</span")) {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "ISP blocked by Hotfile, Premium not possible",
           PluginException.VALUE_ID_PREMIUM_TEMP_DISABLE);
     }
     finalUrl =
         br.getRegex(
                 "<h3 style='margin-top: 20px'><a href=\"(.*?hotfile.*?)\">Click here to download</a></h3>")
             .getMatch(0);
     if (finalUrl == null) {
       finalUrl =
           br.getRegex("table id=\"download_file\".*?<a href=\"(.*?)\"").getMatch(0); /* polish */
     }
   }
   br.setFollowRedirects(true);
   if ("http://hotfile.com/".equals(br.getURL()))
     throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   if (finalUrl == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   // Set the meximum connections per file
   dl =
       jd.plugins.BrowserAdapter.openDownload(
           br,
           downloadLink,
           finalUrl,
           true,
           getPluginConfig().getBooleanProperty(HotFileCom.UNLIMITEDMAXCON, false) == true
               ? 0
               : -5);
   if (!dl.getConnection().isContentDisposition()) {
     br.followConnection();
     finalUrl =
         br.getRegex(
                 "<h3 style='margin-top: 20px'><a href=\"(.*?hotfile.*?)\">Click here to download</a></h3>")
             .getMatch(0);
     if (finalUrl == null) {
       finalUrl =
           br.getRegex("table id=\"download_file\".*?<a href=\"(.*?)\"").getMatch(0); /* polish */
     }
     if (finalUrl == null) {
       throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     }
     dl =
         jd.plugins.BrowserAdapter.openDownload(
             br,
             downloadLink,
             finalUrl,
             true,
             getPluginConfig().getBooleanProperty(HotFileCom.UNLIMITEDMAXCON, false) == true
                 ? 0
                 : -5);
   }
   if (!dl.getConnection().isContentDisposition()) {
     br.followConnection();
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   /* filename workaround */
   String urlFileName = Plugin.getFileNameFromURL(new URL(br.getURL()));
   urlFileName = Encoding.htmlDecode(urlFileName);
   downloadLink.setFinalFileName(urlFileName);
   dl.startDownload();
 }
示例#19
0
 @Override
 public void handlePremium(final DownloadLink downloadLink, final Account account)
     throws Exception {
   checkLinks(new DownloadLink[] {downloadLink});
   if (downloadLink.isAvailabilityStatusChecked() && !downloadLink.isAvailable()) {
     throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   }
   if (getPluginConfig().getBooleanProperty(HotFileCom.TRY_IWL_BYPASS, false)) {
     logger.severe("trying iwl-bypass");
     handlePremiumWebsite(downloadLink, account);
     return;
   }
   final HashMap<String, String> params = new HashMap<String, String>();
   params.put("link", Encoding.urlEncode(downloadLink.getDownloadURL() + "\n\r"));
   params.put("alllinks", "1");
   final HashMap<String, String> info = callAPI(null, "getdirectdownloadlink", account, params);
   logger.severe("HotFileDebug(Download): " + info.get("httpresponse"));
   if (info.get("httpresponse").contains("file was deleted")) {
     throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   }
   if (info.get("httpresponse").contains("file not found")) {
     throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   }
   if (info.get("httpresponse").contains("premium required")) {
     throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
   }
   final String finalUrls = info.get("httpresponse").trim();
   if (finalUrls == null || finalUrls.startsWith(".")) {
     if (finalUrls != null) {
       if (finalUrls.startsWith(".too many failed")) {
         logger.severe(
             "api reports: too many failed logins(check logins)! using website fallback!");
         handlePremiumWebsite(downloadLink, account);
         return;
       }
       if (finalUrls.startsWith(".ip blocked")) {
         logger.severe("api reports: ip blocked! using website fallback!");
         handlePremiumWebsite(downloadLink, account);
         return;
       }
       if (finalUrls.startsWith(".server that hosts the file is temporarily")) {
         throw new PluginException(
             LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE,
             "Server temporarily unavailable",
             30 * 60 * 1000l);
       }
     }
     logger.severe(finalUrls);
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   final String dlUrls[] = Regex.getLines(finalUrls);
   final StringBuilder errorSb = new StringBuilder("");
   if (dlUrls == null || dlUrls.length == 0) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   boolean contentHeader = false;
   for (final String url : dlUrls) {
     if (!url.startsWith("http")) {
       errorSb.append(url + "\n\r");
       continue;
     }
     dl =
         jd.plugins.BrowserAdapter.openDownload(
             br,
             downloadLink,
             url,
             true,
             getPluginConfig().getBooleanProperty(HotFileCom.UNLIMITEDMAXCON, false) == true
                 ? 0
                 : -5);
     if (!dl.getConnection().isContentDisposition()) {
       br.followConnection();
       errorSb.append(br.toString() + "\n\r");
     } else {
       contentHeader = true;
       break;
     }
   }
   if (contentHeader) {
     /* filename workaround , MAYBE no longer needed because of api */
     String urlFileName = Plugin.getFileNameFromURL(new URL(br.getURL()));
     urlFileName = Encoding.htmlDecode(urlFileName);
     downloadLink.setFinalFileName(urlFileName);
     dl.startDownload();
   } else {
     logger.info("APIDebug:" + errorSb.toString());
     /* try website workaround */
     handlePremiumWebsite(downloadLink, account);
   }
 }
示例#20
0
  @Override
  public void handleFree(final DownloadLink link) throws Exception {
    directDownload = false;
    /*
     * for free users we dont use api filecheck, cause we have to call
     * website anyway
     */
    requestFileInformation(link);
    if ("http://hotfile.com/".equals(br.getURL()))
      throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
    if (directDownload) {
      logger.info("use directdownload");
      /* use directDownloadLink */
      br.setFollowRedirects(true);
      try {
        /* first retry with resume allowed */
        dl =
            jd.plugins.BrowserAdapter.openDownload(
                br,
                link,
                link.getDownloadURL(),
                true,
                getPluginConfig().getBooleanProperty(HotFileCom.UNLIMITEDMAXCON, false) == true
                    ? 0
                    : -5);
      } catch (final Throwable e) {
        try {
          dl.getConnection().disconnect();
        } catch (final Throwable e2) {
        }
        /* then try with resume disallowed */
        /* reset chunks */
        link.setChunksProgress(null);
        dl = jd.plugins.BrowserAdapter.openDownload(br, link, link.getDownloadURL(), false, 1);
      }
    } else {
      /* fetch link from website */
      if (br.containsHTML("You are currently downloading")) {
        throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 5 * 60 * 1000l);
      }
      if (br.containsHTML("starthtimer\\(\\)")) {
        final String waittime =
            br.getRegex("starthtimer\\(\\).*?timerend=.*?\\+(\\d+);").getMatch(0);
        if (Long.parseLong(waittime.trim()) > 0) {
          throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, Long.parseLong(waittime.trim()));
        }
      }
      int tries = getPluginConfig().getIntegerProperty(HotFileCom.CAPTCHARETRIES, 20);
      while (true) {
        final Form[] forms = br.getForms();
        if (br.containsHTML("Could not open socket"))
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError", 15 * 60 * 1000l);
        final Form form = forms[1];
        long sleeptime = 0;
        try {
          sleeptime =
              Long.parseLong(br.getRegex("timerend=d\\.getTime\\(\\)\\+(\\d+);").getMatch(0)) + 1;
          // for debugging purposes
          logger.info("Regexed waittime is " + sleeptime + " seconds");
        } catch (final Exception e) {
          logger.info("WaittimeRegex broken");
          logger.info(br.toString());
          sleeptime = 60 * 1000l;
        }
        // Reconnect if the waittime is too big!
        if (sleeptime > 100 * 1000l) {
          throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, sleeptime);
        }
        /* 2secs more as extra buffer */
        this.sleep(sleeptime + 2000, link);
        submit(br, form);
        // captcha
        if (!br.containsHTML("Click here to download")) {
          final PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
          final jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
          rc.handleAuto(this, link);

          if (!br.containsHTML("Click here to download")) {
            if (tries-- > 0) {
              continue;
            } else {
              throw new PluginException(LinkStatus.ERROR_CAPTCHA);
            }
          }
        }

        break;
      }
      String dl_url =
          br.getRegex("<h3 style='margin-top: 20px'><a href=\"(.*?)\">Click here to download</a>")
              .getMatch(0);
      if (dl_url == null) {
        dl_url =
            br.getRegex("table id=\"download_file\".*?<a href=\"(.*?)\"").getMatch(0); /* polish */
      }
      if (dl_url == null) {
        if (!br.containsHTML("(Click here to download)")) {
          throw new PluginException(LinkStatus.ERROR_CAPTCHA);
        }
        if (br.containsHTML("name=waithash"))
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError,Waittime again", 30 * 1000l);
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      }
      br.setFollowRedirects(true);
      br.setDebug(true);
      dl = jd.plugins.BrowserAdapter.openDownload(br, link, dl_url, false, 1);
      if (!dl.getConnection().isContentDisposition()) {
        br.followConnection();
        if (br.containsHTML("Invalid link")) {
          final String newLink = br.getRegex("href=\"(http://.*?)\"").getMatch(0);
          if (newLink != null) {
            /* set new downloadlink */
            logger.warning("invalid link -> use new link");
            link.setUrlDownload(newLink.trim());
            throw new PluginException(LinkStatus.ERROR_RETRY);
          }
        }
        if (br.containsHTML(">Your download expired, try again<"))
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE,
              "Download-Session expired",
              10 * 60 * 1000l);
        if (br.containsHTML("You are currently downloading")) {
          throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 5 * 60 * 1000l);
        }
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      }
      /* filename workaround */
      String urlFileName = Plugin.getFileNameFromURL(new URL(br.getURL()));
      urlFileName = Encoding.htmlDecode(urlFileName);
      link.setFinalFileName(urlFileName);
    }
    dl.startDownload();
  }
 /**
  * Startet den Download. Nach dem Aufruf dieser Funktion koennen keine Downlaodparameter mehr gesetzt werden bzw bleiben wirkungslos.
  * 
  * @return
  * @throws Exception
  */
 public boolean startDownload() throws Exception {
     try {
         startTimeStamp = System.currentTimeMillis();
         sizeBefore = downloadLink.getDownloadCurrent();
         linkStatus.addStatus(LinkStatus.DOWNLOADINTERFACE_IN_PROGRESS);
         try {
             downloadLink.getDownloadLinkController().getConnectionHandler().addConnectionHandler(this.getManagedConnetionHandler());
         } catch (final Throwable e) {
         }
         /*if (this.dlAlreadyFinished == false) {
             try {
                 boolean watchAsYouDownloadTypeLink = (Boolean) downloadLink.getFilePackage().getProperty(org.jdownloader.extensions.neembuu.NeembuuExtension.WATCH_AS_YOU_DOWNLOAD_KEY, false);
                 boolean initiatedByWatchAsYouDownloadAction = (Boolean) downloadLink.getFilePackage().getProperty(org.jdownloader.extensions.neembuu.NeembuuExtension.INITIATED_BY_WATCH_ACTION, false);
                 if (watchAsYouDownloadTypeLink && initiatedByWatchAsYouDownloadAction) {
                     org.jdownloader.extensions.neembuu.DownloadSession downloadSession = new org.jdownloader.extensions.neembuu.DownloadSession(downloadLink, this, this.plugin, this.getConnection(), this.browser.cloneBrowser());
                     if (org.jdownloader.extensions.neembuu.NeembuuExtension.tryHandle(downloadSession)) {
                         org.jdownloader.extensions.neembuu.WatchAsYouDownloadSession watchAsYouDownloadSession = downloadSession.getWatchAsYouDownloadSession();
                         try {
                             watchAsYouDownloadSession.waitForDownloadToFinish();
                         } catch (Exception a) {
                             logger.log(Level.SEVERE, "Exception in waiting for neembuu watch as you download", a);
                             // if we do not return, normal download would start.
                             return false;
                         }
                         return true;
                     }
                     int o = 0;
                     try {
                         o = Dialog.I().showConfirmDialog(Dialog.LOGIC_COUNTDOWN, org.jdownloader.extensions.neembuu.translate._NT._.neembuu_could_not_handle_title(), org.jdownloader.extensions.neembuu.translate._NT._.neembuu_could_not_handle_message());
                     } catch (Exception a) {
                         o = Dialog.RETURN_CANCEL;
                     }
                     if (o == Dialog.RETURN_CANCEL) return false;
                     logger.severe("Neembuu could not handle this link/filehost. Using default download system.");
                 } else if (watchAsYouDownloadTypeLink && !initiatedByWatchAsYouDownloadAction) {
                     // Neembuu downloads should start if and only if user clicks
                     // watch as you download
                     // action in the context menu. We don't want neembuu to
                     // start when user pressed
                     // forced download, or simple download button.
                     // We shall skip this link and disable all in this
                     // filepackage
                     for (DownloadLink dl : downloadLink.getFilePackage().getChildren()) {
                         dl.setEnabled(false);
                     }
                     // TODO: change me 
                     throw new PluginException(LinkStatus.ERROR_FATAL);
                 }
             } catch (final Throwable e) {
                 logger.severe("Exception in neembuu watch as you download");
                 LogSource.exception(logger, e);
             }
         }*/
         logger.finer("Start Download");
         if (this.dlAlreadyFinished == true) {
             downloadLink.setAvailable(true);
             logger.finer("DownloadAlreadyFinished workaround");
             linkStatus.setStatus(LinkStatus.FINISHED);
             return true;
         }
         if (!connected) connect();
         if (connection != null && connection.getHeaderField("Content-Encoding") != null && connection.getHeaderField("Content-Encoding").equalsIgnoreCase("gzip")) {
             /* GZIP Encoding kann weder chunk noch resume */
             setResume(false);
             setChunkNum(1);
         }
         // Erst hier Dateinamen holen, somit umgeht man das Problem das bei
         // mehrfachAufruf von connect entstehen kann
         if (this.downloadLink.getFinalFileName() == null && ((connection != null && connection.isContentDisposition()) || this.allowFilenameFromURL)) {
             String name = Plugin.getFileNameFromHeader(connection);
             if (this.fixWrongContentDispositionHeader) {
                 this.downloadLink.setFinalFileName(Encoding.htmlDecode(name));
             } else {
                 this.downloadLink.setFinalFileName(name);
             }
         }
         downloadLink.getLinkStatus().setStatusText(null);
         if (connection == null || !connection.isOK()) {
             if (connection != null) logger.finest(connection.toString());
             try {
                 connection.disconnect();
             } catch (final Throwable e) {
             }
             throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, 10 * 60 * 1000l);
         }
         if (connection.getHeaderField("Location") != null) {
             error(LinkStatus.ERROR_PLUGIN_DEFECT, "Sent a redirect to Downloadinterface");
             return false;
         }
         if (downloadLink.getVerifiedFileSize() < 0) {
             /* we don't have a verified filesize yet, let's check if we have it now! */
             if (connection.getRange() != null) {
                 if (connection.getRange()[2] > 0) {
                     downloadLink.setVerifiedFileSize(connection.getRange()[2]);
                 }
             } else if (connection.getRequestProperty("Range") == null && connection.getLongContentLength() > 0 && connection.isOK()) {
                 downloadLink.setVerifiedFileSize(connection.getLongContentLength());
             }
         }
         //if (DownloadWatchDog.preDownloadCheckFailed(downloadLink)) return false;
         setupChunks();
         /* download in progress so file should be online ;) */
         downloadLink.setAvailable(true);
         waitForChunks();
         onChunksReady();
         return handleErrors();
     } catch (Exception e) {
         if (e instanceof FileNotFoundException) {
             this.error(LinkStatus.ERROR_LOCAL_IO, _JDT._.download_error_message_localio(e.getMessage()));
         } else {
             LogSource.exception(logger, e);
         }
         handleErrors();
         return false;
     } finally {
         try {
             downloadLink.getDownloadLinkController().getConnectionHandler().removeConnectionHandler(this.getManagedConnetionHandler());
         } catch (final Throwable e) {
         }
         linkStatus.removeStatus(LinkStatus.DOWNLOADINTERFACE_IN_PROGRESS);
         try {
             this.connection.disconnect();
         } catch (Throwable e) {
         }
         /* make sure file is really closed */
         cleanupDownladInterface();
     }
 }
示例#22
0
  private void handleCaptchaAndPassword(final String partLink, final CryptedLink param)
      throws Exception {
    br.getPage(partLink);
    ALLFORM = br.getFormbyProperty("name", "form");
    boolean b = ALLFORM == null ? true : false;
    // 20150120 - raztoki
    if (ALLFORM == null
        && br.containsHTML(">Please Wait\\.\\.\\.<")
        && br.containsHTML("class=\"timer\">\\d+</span>\\s*seconds</div>")) {
      // pile of redirects happen here
      final String link =
          br.getRegex(
                  "class=\"timer\">\\d+</span>\\s*seconds</div>\\s*<a href=\"\\s*(https?://(\\w+\\.)?relink\\.us/.*?)\\s*\"")
              .getMatch(0);
      if (link != null) {
        br.getPage(link.trim());
        ALLFORM = br.getFormbyProperty("name", "form");
        b = ALLFORM == null ? true : false;
      } else {
        // possible plugin defect
        logger.warning("Possible Plugin Defect!");
      }
    }

    if (b) {
      ALLFORM = br.getForm(0);
      ALLFORM =
          ALLFORM != null
                  && ALLFORM.getAction() != null
                  && ALLFORM
                      .getAction()
                      .matches("^https?://(\\w+\\.)?relink\\.us/container_password\\.php.*")
              ? ALLFORM
              : null;
    }
    if (ALLFORM != null) {
      for (int i = 0; i < 5; i++) {
        if (ALLFORM.containsHTML("password")) {
          final String passCode = Plugin.getUserInput(null, param);
          ALLFORM.put("password", passCode);
        }
        if (ALLFORM.containsHTML("captcha")) {
          ALLFORM.remove("button");
          final String captchaLink = ALLFORM.getRegex("src=\"(.*?)\"").getMatch(0);
          if (captchaLink == null) {
            break;
          }
          final File captchaFile = this.getLocalCaptchaFile();
          Browser.download(
              captchaFile,
              br.cloneBrowser().openGetConnection("http://www.relink.us/" + captchaLink));
          final Point p =
              UserIO.getInstance()
                  .requestClickPositionDialog(
                      captchaFile, "relink.us | " + String.valueOf(i + 1) + "/5", null);
          if (p == null) {
            throw new DecrypterException(DecrypterException.CAPTCHA);
          }
          ALLFORM.put("button.x", String.valueOf(p.x));
          ALLFORM.put("button.y", String.valueOf(p.y));
        }
        br.submitForm(ALLFORM);
        if (br.getURL().contains("error.php")) {
          br.getPage(partLink);
          continue;
        }
        ALLFORM = br.getFormbyProperty("name", "form");
        ALLFORM = ALLFORM == null && b ? br.getForm(0) : ALLFORM;
        if (ALLFORM != null
            && ALLFORM.getAction().startsWith("http://www.relink.us/container_password.php")) {
          continue;
        }
        ALLFORM = null;
        break;
      }
    }
  }