private void doLogin(final PremiumAccount pa) throws Exception {
    HttpMethod method =
        getMethodBuilder()
            .setAction("https://www.4shared.com/web/login")
            .setAjax()
            .setParameter("returnTo", fileURL)
            .setParameter("login", pa.getUsername())
            .setParameter("password", pa.getPassword())
            .toPostMethod();
    if (!makeRedirectedRequest(method)) {
      throw new ServiceConnectionProblemException("Error posting login info");
    }
    if (getContentAsString().contains("Invalid e-mail address or password")) {
      throw new BadLoginException("Invalid 4Shared account login information");
    }

    // language is based on account pref,
    // setting language cookie doesn't work
    Cookie langCookie = getCookieByName("4langcookie");
    if ((langCookie == null) || !langCookie.getValue().equalsIgnoreCase("en")) {
      method =
          getMethodBuilder()
              .setAction(
                  "http://www.4shared.com/web/user/language") // set account's language preference
              .setParameter("code", "en")
              .toPostMethod();
      if (!makeRedirectedRequest(method)) {
        throw new ServiceConnectionProblemException();
      }
      if (!getContentAsString().contains("\"status\":\"ok\"")) {
        throw new PluginImplementationException("Setting language to EN failed");
      }
    }
  }
 private void login() throws Exception {
   synchronized (Real_DebridFileRunner.class) {
     cz.vity.freerapid.plugins.services.real_debrid.Real_DebridServiceImpl service =
         (cz.vity.freerapid.plugins.services.real_debrid.Real_DebridServiceImpl)
             getPluginService();
     PremiumAccount pa = service.getConfig();
     if (!pa.isSet()) {
       pa = service.showConfigDialog();
       if (pa == null || !pa.isSet()) {
         throw new BadLoginException("No Real-Debrid account login information!");
       }
     }
     HttpMethod method =
         getMethodBuilder()
             .setAction(RD_LOGIN)
             .setParameter("user", pa.getUsername())
             .setParameter("pass", pa.getPassword())
             .setParameter("captcha_challenge", "")
             .setParameter("captcha_answer", "")
             .setParameter("time", "" + System.currentTimeMillis())
             .setBaseURL(RD_BASE_URL)
             .setReferer(RD_BASE_URL)
             .toGetMethod();
     if (!makeRedirectedRequest(method)) {
       throw new ServiceConnectionProblemException("Error posting login info");
     }
     if (getContentAsString().contains("Your login informations are incorrect")) {
       throw new BadLoginException("Invalid Real-Debrid account login information!");
     }
     final String auth = PlugUtils.getStringBetween(getContentAsString(), "cookie\":\"auth=", ";");
     addCookie(new Cookie(".real-debrid.com", "auth", auth, "/", 86400, false));
   }
 }
 @Override
 protected void doLogin(PremiumAccount pa) throws Exception {
   HttpMethod method =
       getMethodBuilder()
           .setReferer(getBaseURL())
           .setAction(getBaseURL() + "/login")
           .toGetMethod();
   if (!makeRedirectedRequest(method)) {
     throw new ServiceConnectionProblemException();
   }
   method =
       getMethodBuilder()
           .setReferer(getBaseURL() + "/login")
           .setAction(getBaseURL())
           .setActionFromFormByName("FL", true)
           .setParameter("login", pa.getUsername())
           .setParameter("password", pa.getPassword())
           .toPostMethod();
   if (!makeRedirectedRequest(method)) {
     throw new ServiceConnectionProblemException();
   }
   if (getContentAsString().contains("Incorrect Login or Password")) {
     throw new BadLoginException("Invalid account login information");
   }
 }