/**
   * Find the C Challenge URL from the given K Challenge URL.
   *
   * @param kCaptchaUrl The K Challenge URL as a String.
   * @return The C Challenge URL as a String..
   * @throws IOException
   */
  @Override
  public String findCCaptchaUrlFromK(String kCaptchaUrl) throws IOException, Exception {
    cCaptchaUrl = null;

    if (kCaptchaUrl == null) {
      return null;
    }

    String body = NUHttpClientUtils.getData(kCaptchaUrl, httpContext);

    // CommonUploaderTasks.saveInFile("Recaptcha.html", body);

    regex = Pattern.compile(googleRegC);
    regexMatcher = regex.matcher(body);

    if (regexMatcher.find()) {
      NULogger.getLogger().info("Google C recaptcha found!");
      cCaptchaUrl = body.substring(regexMatcher.start(), regexMatcher.end());
      cCaptchaUrl = StringUtils.stringBetweenTwoStrings(cCaptchaUrl, "'", "'");
      NULogger.getLogger().log(Level.INFO, "cCaptchaUrl: {0}", cCaptchaUrl);
      return cCaptchaUrl;
    }

    NULogger.getLogger().log(Level.INFO, "kCaptchaUrl: {0}", kCaptchaUrl);

    return cCaptchaUrl;
  }
  private void fileupload() throws Exception {

    if (!solidfilesAccount.loginsuccessful) {
      NUHttpClientUtils.getData("http://www.solidfiles.com/", httpContext);
    }

    httpPost = new NUHttpPost("http://www.solidfiles.com/upload/process/0/");

    MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    reqEntity.addPart("name", new StringBody(file.getName()));
    reqEntity.addPart("file", createMonitoredFileBody());

    httpPost.setEntity(reqEntity);
    uploading();
    NULogger.getLogger().info("Now uploading your file into solidfiles.com. Please wait...");
    httpResponse = httpclient.execute(httpPost, httpContext);
    HttpEntity resEntity = httpResponse.getEntity();

    String downloadCode;
    if (resEntity != null) {
      gettingLink();
      downloadCode = EntityUtils.toString(resEntity);
      NULogger.getLogger().log(Level.INFO, "Download code :{0}", downloadCode);
      downloadlink = String.format(downloadlink, downloadCode);
    }

    downURL = downloadlink;
    uploadFinished();
  }
  private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    NULogger.getLogger().info("** Ex-Load.com ** => Attempting to log-out before logging in.");
    responseString = NUHttpClientUtils.getData("http://ex-load.com/?op=logout", httpContext);
    Thread.sleep(2000);
    NULogger.getLogger().info("** Ex-Load.com ** => Retrieving login page");
    responseString = NUHttpClientUtils.getData("http://ex-load.com/login.html", httpContext);
    doc = Jsoup.parse(responseString);
    captcha = captchaSolver();
    NULogger.getLogger().info("** Ex-Load.com ** => FINAL captcha value: [" + captcha + "]");
    rand = doc.select("input[name=rand]").attr("value");
    Thread.sleep(2000);
  }
  private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    NULogger.getLogger().info("Getting startup cookies & link from TopUpload1.com");
    responseString = NUHttpClientUtils.getData("http://topupload1.com/login.html", httpContext);
  }
  private void initialize() throws Exception {
    responseString = NUHttpClientUtils.getData("http://streamin.to?op=upload", httpContext);

    doc = Jsoup.parse(responseString);
    uploadURL = doc.select("form[name=file").first().attr("action");
    sv_id = doc.select("input[name=srv_id").first().attr("value");
    disk_id = doc.select("input[name=disk_id").first().attr("value");
    String uploadId = StringUtils.uuid(12, 10);
    uploadURL += uploadId + "&utype=" + userType + "&disk_id=" + disk_id;
  }
  private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    NULogger.getLogger().info("Getting startup cookies & link from OpenLoad.co");
    responseString = NUHttpClientUtils.getData("https://openload.co/login", httpContext);
    doc = Jsoup.parse(responseString);

    csrfToken = doc.select("form[id=login-form]").first().select("input[name=_csrf]").attr("value");
  }
  @Override
  public void login() {
    loginsuccessful = false;
    try {
      initialize();

      NULogger.getLogger().info("Trying to log in to OpenLoad.co");
      httpPost = new NUHttpPost("https://openload.co/login");

      List<NameValuePair> formparams = new ArrayList<NameValuePair>();
      formparams.add(new BasicNameValuePair("_csrf", csrfToken));
      formparams.add(new BasicNameValuePair("LoginForm[rememberMe]", "1"));
      formparams.add(new BasicNameValuePair("LoginForm[email]", getUsername()));
      formparams.add(new BasicNameValuePair("LoginForm[password]", getPassword()));

      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
      httpPost.setEntity(entity);
      httpResponse = httpclient.execute(httpPost, httpContext);
      NULogger.getLogger().info(httpResponse.getStatusLine().toString());

      responseString = NUHttpClientUtils.getData("https://openload.co/upload", httpContext);

      if (responseString.contains("logout")) {
        EntityUtils.consume(httpResponse.getEntity());
        loginsuccessful = true;
        username = getUsername();
        password = getPassword();
        NULogger.getLogger().info("OpenLoad.co login successful!");

      } else {
        // Get error message
        responseString = EntityUtils.toString(httpResponse.getEntity());
        Document doc = Jsoup.parse(responseString);
        String error = doc.select(".err").first().text();

        if ("Incorrect Login or Password".equals(error)) {
          throw new NUInvalidLoginException(getUsername(), HOSTNAME);
        }

        // Generic exception
        throw new Exception("Login error: " + error);
      }
    } catch (NUException ex) {
      resetLogin();
      ex.printError();
      accountUIShow().setVisible(true);
    } catch (Exception e) {
      resetLogin();
      NULogger.getLogger().log(Level.SEVERE, "{0}: {1}", new Object[] {getClass().getName(), e});
      showWarningMessage(Translation.T().loginerror(), HOSTNAME);
      accountUIShow().setVisible(true);
    }
  }
  @Override
  public void run() {
    try {
      if (depositFilesAccount.loginsuccessful) {
        httpContext = depositFilesAccount.getHttpContext();
        host = depositFilesAccount.username + " | DepositFiles.com";
      } else {
        host = "DepositFiles.com";
        CookieStore cookieStore = new BasicCookieStore();
        httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
      }

      if (!depositFilesAccount.loginsuccessful) {
        if (file.length() > notLogMaxFileSizeLimit) {
          throw new NUMaxFileSizeException(
              notLogMaxFileSizeLimit, file.getName(), depositFilesAccount.getHOSTNAME());
        }
      } else {
        if (file.length() > logMaxFileSizeLimit) {
          throw new NUMaxFileSizeException(
              logMaxFileSizeLimit, file.getName(), depositFilesAccount.getHOSTNAME());
        }
      }

      if (file.length() == 0) {
        throw new NUMinFileSizeException(
            minFileSizeLimit, file.getName(), depositFilesAccount.getHOSTNAME());
      }

      uploadInitialising();
      NULogger.getLogger().info("Now getting deposifiles page post action value........");
      if (depositFilesAccount.loginsuccessful) {
        uploadresponse = NUHttpClientUtils.getData("http://depositfiles.com/en/", httpContext);
        doc = Jsoup.parse(uploadresponse);
        postURL = doc.select("form[id=upload_form]").first().attr("action");
        MAX_FILE_SIZE =
            doc.select("form[id=upload_form]")
                .first()
                .select("input[name=MAX_FILE_SIZE]")
                .attr("value");
        UPLOAD_IDENTIFIER =
            doc.select("form[id=upload_form]")
                .first()
                .select("input[name=UPLOAD_IDENTIFIER]")
                .attr("value");
        go = doc.select("form[id=upload_form]").first().select("input[name=go]").attr("value");
      } else {
        postURL =
            NUHttpClientUtils.getData(
                "http://depositfiles.com/api/get_upload_info.php", httpContext);
        postURL = Jsoup.parse(postURL, "", Parser.xmlParser()).select("http_upload_path").text();
      }

      NULogger.getLogger().log(Level.INFO, "Post URL  : {0}", postURL);
      fileUpload();

      uploadFinished();
    } catch (NUException ex) {
      ex.printError();

      uploadInvalid();
    } catch (Exception ex) {
      NULogger.getLogger().severe(ex.toString());

      uploadFailed();
    } finally {
      postURL = null;
      uploadresponse = null;
      downloadlink = null;
      deletelink = null;
    }
  }
 private void initialize() throws Exception {
   responseString = NUHttpClientUtils.getData("http://privatefiles.com", httpContext);
   doc = Jsoup.parse(responseString);
   uploadURL =
       StringUtils.stringBetweenTwoStrings(responseString, "name=\"srv_tmp_url\" value=\"", "\"");
 }