Esempio n. 1
0
 public AccountInfo fetchAccountInfoWebsite(final Account account) throws Exception {
   final AccountInfo ai = new AccountInfo();
   synchronized (HotFileCom.LOCK) {
     setBrowserExclusive();
     try {
       loginWebsite(account);
     } catch (final PluginException e) {
       account.setProperty("cookies", null);
       account.setValid(false);
       return ai;
     }
     final String validUntil[] =
         br.getRegex("Premium until.*?>(.*?)<.*?>(\\d+:\\d+:\\d+)").getRow(0);
     if (validUntil == null || validUntil[0] == null || validUntil[1] == null) {
       logger.severe("HotFileDebug(WebsiteAccCheck): " + br.toString());
       account.setProperty("cookies", null);
       account.setValid(false);
     } else {
       final String valid = validUntil[0].trim() + " " + validUntil[1].trim() + " CDT";
       ai.setValidUntil(TimeFormatter.getMilliSeconds(valid, "yyyy-MM-dd HH:mm:ss zzz", null));
       account.setValid(true);
     }
   }
   return ai;
 }
Esempio n. 2
0
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   AccountInfo ai = new AccountInfo();
   try {
     login(account);
   } catch (final PluginException e) {
     account.setValid(false);
     throw e;
   }
   account.setValid(true);
   ai.setUnlimitedTraffic();
   if (!nopremium) {
     String expire = br.getRegex("You have <b>premium</b> account till(.*?)</p>").getMatch(0);
     if (expire == null) {
       ai.setExpired(true);
       account.setValid(false);
       return ai;
     } else {
       ai.setValidUntil(TimeFormatter.getMilliSeconds(expire.trim(), "dd.MM.yyyy HH:mm", null));
     }
     ai.setStatus("Premium Account");
   } else {
     ai.setStatus("Registered (free) User");
   }
   return ai;
 }
Esempio n. 3
0
 @SuppressWarnings("deprecation")
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   final AccountInfo ai = new AccountInfo();
   /* reset maxPrem workaround on every fetchaccount info */
   MAXPREM.set(1);
   try {
     login(account, true);
   } catch (final PluginException e) {
     account.setValid(false);
     throw e;
   }
   if (!br.containsHTML("class=\"badge badge\\-success\">(?:PAID USER|USUARIO DE PAGO)</span>")) {
     account.setType(AccountType.FREE);
     account.setMaxSimultanDownloads(account_FREE_MAXDOWNLOADS);
     /* All accounts get the same (IP-based) downloadlimits --> Simultan free account usage makes no sense! */
     account.setConcurrentUsePossible(false);
     MAXPREM.set(account_FREE_MAXDOWNLOADS);
     ai.setStatus("Registered (free) account");
   } else {
     br.getPage("http://" + this.getHost() + "/upgrade." + type);
     /* If the premium account is expired we'll simply accept it as a free account. */
     String expire =
         br.getRegex(
                 "Reverts To Free Account:[\t\n\r ]+</td>[\t\n\r ]+<td>[\t\n\r ]+(\\d{2}/\\d{2}/\\d{4} \\d{2}:\\d{2}:\\d{2})")
             .getMatch(0);
     if (expire == null) {
       /* More wide RegEx to be more language independant */
       expire =
           br.getRegex(">[\t\n\r ]*?(\\d{2}/\\d{2}/\\d{4} \\d{2}:\\d{2}:\\d{2})[\t\n\r ]*?<")
               .getMatch(0);
     }
     if (expire == null) {
       account.setValid(false);
       return ai;
     }
     long expire_milliseconds = 0;
     expire_milliseconds =
         TimeFormatter.getMilliSeconds(expire, "MM/dd/yyyy hh:mm:ss", Locale.ENGLISH);
     if ((expire_milliseconds - System.currentTimeMillis()) <= 0) {
       account.setType(AccountType.FREE);
       account.setMaxSimultanDownloads(account_FREE_MAXDOWNLOADS);
       /* All accounts get the same (IP-based) downloadlimits --> Simultan free account usage makes no sense! */
       account.setConcurrentUsePossible(false);
       MAXPREM.set(account_FREE_MAXDOWNLOADS);
       ai.setStatus("Registered (free) user");
     } else {
       ai.setValidUntil(expire_milliseconds);
       account.setType(AccountType.PREMIUM);
       account.setMaxSimultanDownloads(account_PREMIUM_MAXDOWNLOADS);
       MAXPREM.set(account_PREMIUM_MAXDOWNLOADS);
       ai.setStatus("Premium account");
     }
   }
   account.setValid(true);
   ai.setUnlimitedTraffic();
   return ai;
 }
Esempio n. 4
0
 @Override
 public AccountInfo fetchAccountInfo(Account account) throws Exception {
   AccountInfo ai = new AccountInfo();
   try {
     login(account, true);
   } catch (PluginException e) {
     account.setValid(false);
     return ai;
   }
   String space =
       br.getRegex(
               Pattern.compile(
                   "<td>Used space:</td>.*?<td.*?b>([0-9\\.]+) of [0-9\\.]+ (Mb|GB)</b>",
                   Pattern.DOTALL | Pattern.CASE_INSENSITIVE))
           .getMatch(0);
   if (space != null) {
     ai.setUsedSpace(space.trim() + " Mb");
   }
   account.setValid(true);
   String availabletraffic =
       new Regex(correctedBR, "Traffic available.*?:</TD><TD><b>([^<>\"\\']+)</b>").getMatch(0);
   if (availabletraffic != null
       && !availabletraffic.contains("nlimited")
       && !availabletraffic.equalsIgnoreCase(" Mb")) {
     availabletraffic.trim();
     // need to set 0 traffic left, as getSize returns positive result, even when negative value
     // supplied.
     if (!availabletraffic.startsWith("-")) {
       ai.setTrafficLeft(SizeFormatter.getSize(availabletraffic));
     } else {
       ai.setTrafficLeft(0);
     }
   } else {
     ai.setUnlimitedTraffic();
   }
   if (account.getBooleanProperty("nopremium")) {
     ai.setStatus("Registered (free) User");
   } else {
     String expire =
         new Regex(
                 correctedBR,
                 Pattern.compile(
                     "<td>Premium(\\-| )Account expires?:</td>.*?<td>(<b>)?(\\d{1,2} [A-Za-z]+ \\d{4})(</b>)?</td>",
                     Pattern.CASE_INSENSITIVE))
             .getMatch(2);
     if (expire == null) {
       ai.setExpired(true);
       account.setValid(false);
       return ai;
     } else {
       expire = expire.replaceAll("(<b>|</b>)", "");
       ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMMM yyyy", null));
     }
     ai.setStatus("Premium User");
   }
   return ai;
 }
Esempio n. 5
0
 private String convertInputDateToJsonDateFormat(final String input) {
   if (input == null) {
     return null;
   }
   final long date;
   if (input.matches("\\d{4}-\\d{2}-\\d{2}")) {
     date = TimeFormatter.getMilliSeconds(input, "yyyy-MM-dd", Locale.ENGLISH);
   } else {
     date = TimeFormatter.getMilliSeconds(input, "yyyy_MM_dd", Locale.ENGLISH);
   }
   String formattedDate = null;
   final String targetFormat = "dd-MM-yyyy";
   Date theDate = new Date(date);
   try {
     final SimpleDateFormat formatter = new SimpleDateFormat(targetFormat);
     formattedDate = formatter.format(theDate);
   } catch (Exception e) {
     /* prevent input error killing plugin */
     formattedDate = input;
   }
   return formattedDate;
 }
Esempio n. 6
0
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   final AccountInfo ai = new AccountInfo();
   if (account.getUser().trim().equalsIgnoreCase("cookie")) {
     account.setValid(false);
     ai.setStatus("Cookie login no longer possible! API does not support it!");
     return ai;
   }
   if (getPluginConfig().getBooleanProperty(HotFileCom.TRY_IWL_BYPASS, false)) {
     return fetchAccountInfoWebsite(account);
   }
   final HashMap<String, String> info;
   try {
     info = callAPI(null, "getuserinfo", account, null);
   } catch (PluginException e) {
     account.setValid(false);
     return ai;
   }
   final String rawAnswer = info.get("httpresponse");
   logger.severe("HotFileDebug(ApiAccountCheck): " + rawAnswer);
   if (rawAnswer != null && rawAnswer.startsWith(".too many failed")) {
     /* fallback to normal website */
     logger.severe("api reports: too many failed logins(check logins)! using website fallback!");
     return fetchAccountInfoWebsite(account);
   }
   if (!info.containsKey("is_premium") || !"1".equalsIgnoreCase(info.get("is_premium"))) {
     account.setValid(false);
     if (info.get("httpresponse").contains("invalid username")) {
       ai.setStatus("invalid username or password");
     } else {
       ai.setStatus("No Premium Account");
     }
     return ai;
   }
   String validUntil = info.get("premium_until");
   if (validUntil == null) {
     account.setValid(false);
   } else {
     account.setValid(true);
     validUntil = validUntil.replaceAll(":|T", "");
     validUntil = validUntil.replaceFirst("-", "");
     validUntil = validUntil.replaceFirst("-", "");
     ai.setValidUntil(TimeFormatter.getMilliSeconds(validUntil, "yyyyMMddHHmmssZ", null));
     ai.setStatus("Premium");
   }
   return ai;
 }
Esempio n. 7
0
  @SuppressWarnings("deprecation")
  @Override
  public AccountInfo fetchAccountInfo(final Account account) throws Exception {
    final AccountInfo ai = new AccountInfo();
    try {
      login(account, true);
    } catch (final PluginException e) {
      account.setValid(false);
      throw e;
    }

    account.setValid(true);
    ai.setUnlimitedTraffic();
    final String expire =
        br.getRegex("expire:</span><span class=\"info\">([^<>\"]*?)</span>").getMatch(0);
    ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMM yyyy", Locale.ENGLISH));
    ai.setStatus("Premium user");
    return ai;
  }
Esempio n. 8
0
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   AccountInfo ai = new AccountInfo();
   try {
     login(account);
   } catch (PluginException e) {
     account.setValid(false);
     return ai;
   }
   account.setValid(true);
   ai.setUnlimitedTraffic();
   String expire = br.getRegex("<TD>Premium-Account expire:</TD><TD><b>(.*?)</b>").getMatch(0);
   if (expire != null) {
     expire = expire.replaceAll("(<b>|</b>)", "");
     ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMMM yyyy", null));
   }
   ai.setStatus("Premium User");
   return ai;
 }
Esempio n. 9
0
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   final AccountInfo ai = new AccountInfo();
   /* reset maxPrem workaround on every fetchaccount info */
   maxPrem.set(1);
   try {
     login(account, true);
   } catch (final PluginException e) {
     account.setValid(false);
     throw e;
   }
   if (account.getBooleanProperty("free", false)) {
     try {
       account.setType(AccountType.FREE);
       account.setMaxSimultanDownloads(ACCOUNT_FREE_MAXDOWNLOADS);
     } catch (final Throwable e) {
       /* Not available in old 0.9.581 Stable */
     }
     maxPrem.set(ACCOUNT_FREE_MAXDOWNLOADS);
     ai.setStatus("Registered (free) user");
   } else {
     br.getPage("http://www." + this.getHost() + "/upgrade." + TYPE);
     final String expire =
         br.getRegex(
                 "Reverts To Free Account:[\t\n\r ]+</td>[\t\n\r ]+<td>[\t\n\r ]+(\\d{2}/\\d{2}/\\d{4} \\d{2}:\\d{2}:\\d{2})")
             .getMatch(0);
     if (expire != null) {
       ai.setValidUntil(
           TimeFormatter.getMilliSeconds(expire, "dd/MM/yyyy hh:mm:ss", Locale.ENGLISH));
     }
     account.setValid(true);
     try {
       account.setType(AccountType.PREMIUM);
       account.setMaxSimultanDownloads(ACCOUNT_PREMIUM_MAXDOWNLOADS);
     } catch (final Throwable e) {
       /* Not available in old 0.9.581 Stable */
     }
     maxPrem.set(ACCOUNT_PREMIUM_MAXDOWNLOADS);
     ai.setStatus("Premium User");
   }
   ai.setUnlimitedTraffic();
   return ai;
 }
Esempio n. 10
0
  @Override
  public AccountInfo fetchAccountInfo(Account account) throws Exception {
    AccountInfo ac = new AccountInfo();
    br.setConnectTimeout(60 * 1000);
    br.setReadTimeout(60 * 1000);
    String hosts;
    login(account);

    ac.setTrafficLeft(GetTrasferLeft(Info));

    ArrayList<String> supportedHosts = new ArrayList<String>();
    hosts = br.getPage("https://www.twojlimit.pl/clipboard.php");
    if (hosts != null) {
      String hoster[] = new Regex(hosts, "(.*?)(<br />|$)").getColumn(0);
      if (hosts != null) {
        for (String host : hoster) {
          if (hosts == null || host.length() == 0) {
            continue;
          }
          supportedHosts.add(host.trim());
        }
      }
    }
    if (expired) {
      ac.setExpired(true);
      ac.setStatus("Account expired");
      ac.setValidUntil(0);
      return ac;
    } else {
      ac.setExpired(false);
      if (validUntil != null) {
        if (validUntil.trim().equals("expire=00")) {
          ac.setValidUntil(-1);
        } else {
          ac.setValidUntil(TimeFormatter.getMilliSeconds(validUntil));
        }
      }
    }
    ac.setMultiHostSupport(this, supportedHosts);
    ac.setStatus("Account valid");
    return ac;
  }
Esempio n. 11
0
  @SuppressWarnings({"deprecation"})
  @Override
  public AccountInfo fetchAccountInfo(final Account account) throws Exception {
    this.setConstants(account, null);
    this.br = newBrowser();
    final AccountInfo ai = new AccountInfo();
    br.setFollowRedirects(true);

    this.login(account, true);

    this.getAPISafe("/user_dashboard.php");

    final String accounttype = br.getRegex(">Status</td>.*?value=([^<>\"]*?)>").getMatch(0);
    final String validuntil = br.getRegex(">Expire Date</td>.*?value=([^<>\"]*?)>").getMatch(0);

    if (accounttype.equalsIgnoreCase("Premium")) {
      if (validuntil != null) {
        ai.setValidUntil(
            TimeFormatter.getMilliSeconds(validuntil, "yyyy-MM-dd HH:mm:ss", Locale.ENGLISH));
      }
      account.setType(AccountType.PREMIUM);
      ai.setStatus("Premium Account");
      ai.setUnlimitedTraffic();
    } else {
      account.setType(AccountType.FREE);
      ai.setStatus("Free Account");
      /* It's impossible to download anything with free accounts of this service. */
      ai.setTrafficLeft(0);
    }
    this.getAPISafe("/user_download.php");
    final String[] supportedHosts =
        br.getRegex("\\s+<img src=\"images/hosts/.*?\\.png\" title=\"(.*?)\"").getColumn(0);
    final List<String> list = Arrays.asList(supportedHosts);
    account.setValid(true);
    account.setConcurrentUsePossible(true);

    hostMaxchunksMap.clear();
    hostMaxdlsMap.clear();
    ai.setMultiHostSupport(this, list);
    return ai;
  }
  public java.util.List<ReconnectResult> autoFind(final ProcessCallBack feedback)
      throws InterruptedException {

    StatsManager.I().track("reconnectAutoFind/start");
    final java.util.List<ReconnectResult> scripts = new ArrayList<ReconnectResult>();

    for (final RouterPlugin plg : ReconnectPluginController.this.plugins) {
      if (Thread.currentThread().isInterrupted()) {
        throw new InterruptedException();
      }
      if (plg instanceof UPNPRouterPlugin || plg instanceof LiveHeaderReconnect) {
        try {

          feedback.setStatus(plg, null);

          java.util.List<ReconnectResult> founds = plg.runDetectionWizard(feedback);

          if (founds != null) {
            scripts.addAll(founds);
          }
          if (scripts.size() > 0) {
            break;
          }
        } catch (InterruptedException e) {
          throw e;
        } catch (Exception e) {

        }
      }
    }
    if (scripts.size() > 0) {
      HashMap<String, String> map = new HashMap<String, String>();
      map.put("plg", scripts.get(0).getInvoker().getPlugin().getID());
      StatsManager.I().track("reconnectAutoFind/success", map);
    } else {
      StatsManager.I().track("reconnectAutoFind/failed");
    }
    if (JsonConfig.create(ReconnectConfig.class).getOptimizationRounds() > 1
        && scripts.size() > 0) {
      int i = 1;
      long bestTime = Long.MAX_VALUE;
      long optiduration = 0;
      for (ReconnectResult found : scripts) {

        bestTime = Math.min(bestTime, found.getSuccessDuration());
        optiduration +=
            found.getSuccessDuration()
                * (JsonConfig.create(ReconnectConfig.class).getOptimizationRounds() - 1)
                * 1.5;
      }
      try {

        Dialog.getInstance()
            .showConfirmDialog(
                0,
                _GUI.T.AutoDetectAction_actionPerformed_dooptimization_title(),
                _GUI.T.AutoDetectAction_actionPerformed_dooptimization_msg(
                    scripts.size(),
                    TimeFormatter.formatMilliSeconds(optiduration, 0),
                    TimeFormatter.formatMilliSeconds(bestTime, 0)),
                new AbstractIcon(IconKey.ICON_OK, 32),
                _GUI.T.AutoDetectAction_run_optimization(),
                _GUI.T.AutoDetectAction_skip_optimization());
        feedback.setProgress(this, 0);
        for (int ii = 0; ii < scripts.size(); ii++) {
          ReconnectResult found = scripts.get(ii);
          feedback.setStatusString(
              this, _GUI.T.AutoDetectAction_run_optimize(found.getInvoker().getName()));
          final int step = ii;
          found.optimize(
              new ProcessCallBackAdapter() {

                public void setProgress(Object caller, int percent) {
                  feedback.setProgress(
                      caller, (step) * (100 / scripts.size()) + percent / scripts.size());
                }

                public void setStatusString(Object caller, String string) {
                  feedback.setStatusString(caller, _GUI.T.AutoDetectAction_run_optimize(string));
                }
              });
        }
      } catch (DialogNoAnswerException e) {

      }
    }
    try {
      Collections.sort(
          scripts,
          new Comparator<ReconnectResult>() {

            public int compare(ReconnectResult o1, ReconnectResult o2) {
              return new Long(o1.getAverageSuccessDuration())
                  .compareTo(new Long(o2.getAverageSuccessDuration()));
            }
          });
    } catch (final Throwable e) {

      org.appwork.utils.logging2.extmanager.LoggerFactory.getDefaultLogger().log(e);
    }
    return scripts;
  }
Esempio n. 13
0
 @Override
 public AccountInfo fetchAccountInfo(Account account) throws Exception {
   AccountInfo ai = new AccountInfo();
   synchronized (LOCK) {
     try {
       login(account, true, true);
     } catch (PluginException e) {
       if (br.containsHTML("Your IP is temporarily blocked due to 3 incorrect login attempts")) {
         ai.setStatus("Your IP is temporarily blocked due to 3 incorrect login attempts");
       }
       account.setValid(false);
       return ai;
     }
     // account disabled due to breach of terms and conditions
     if (br.containsHTML(
         ">Your account was disabled due to violation of our Terms of Service\\.<")) {
       logger.warning("Hoster disabled account due to violation of hosters Terms of Service.");
       ai.setStatus("Hoster disabled account due to violation of hosters Terms of Service.");
       account.setValid(false);
       return ai;
     }
     String space =
         br.getRegex(
                 Pattern.compile(
                     "<td>Used space:</td>.*?<td.*?b>([0-9\\.]+) of [0-9\\.]+ (Mb|GB)</b>",
                     Pattern.DOTALL | Pattern.CASE_INSENSITIVE))
             .getMatch(0);
     if (space != null) ai.setUsedSpace(space.trim() + " Mb");
     String points =
         br.getRegex(
                 Pattern.compile(
                     "<td>You have collected:</td.*?b>([^<>\"\\']+)premium points",
                     Pattern.CASE_INSENSITIVE))
             .getMatch(0);
     if (points != null) {
       /** Who needs half points ? If we have a dot in the points, just remove it */
       if (points.contains(".")) {
         String dot = new Regex(points, ".*?(\\.(\\d+))").getMatch(0);
         points = points.replace(dot, "");
       }
       ai.setPremiumPoints(Long.parseLong(points.trim()));
     }
     account.setValid(true);
     String availabletraffic =
         new Regex(BRBEFORE, "Traffic available.*?:</TD><TD><b>([^<>\"\\']+)</b>").getMatch(0);
     if (availabletraffic != null
         && !availabletraffic.contains("nlimited")
         && !availabletraffic.equalsIgnoreCase(" Mb")) {
       availabletraffic.trim();
       // need to set 0 traffic left, as getSize returns positive result, even when negative value
       // supplied.
       if (!availabletraffic.startsWith("-")) {
         ai.setTrafficLeft(SizeFormatter.getSize(availabletraffic));
       } else {
         ai.setTrafficLeft(0);
       }
     } else {
       ai.setUnlimitedTraffic();
     }
     if (account.getBooleanProperty("nopremium")) {
       ai.setStatus("Registered (free) User");
     } else {
       String expire =
           new Regex(
                   BRBEFORE,
                   Pattern.compile(
                       "<td>Premium(\\-| )Account expires?:</td>.*?<td>(<b>)?(\\d{1,2} [A-Za-z]+ \\d{4})(</b>)?</td>",
                       Pattern.CASE_INSENSITIVE))
               .getMatch(2);
       if (expire == null) {
         account.setProperty("cookies", null);
         ai.setExpired(true);
         account.setValid(false);
         return ai;
       } else {
         expire = expire.replaceAll("(<b>|</b>)", "");
         ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMMM yyyy", Locale.ENGLISH));
       }
       ai.setStatus("Premium User");
     }
   }
   return ai;
 }
Esempio n. 14
0
 public String getEtaString() {
     return eta > 0 ? TimeFormatter.formatSeconds(eta, 0) : "~";
 }
Esempio n. 15
0
  @SuppressWarnings("deprecation")
  @Override
  public AccountInfo fetchAccountInfo(final Account account) throws Exception {
    final AccountInfo ai = new AccountInfo();

    try {
      login(account, true);
    } catch (final PluginException e) {
      ai.setStatus("Login failed");
      account.setValid(false);
      throw e;
    }
    final String trafficleft =
        br.getRegex("id=\"info_credit\" class=\"va-middle\">[\n\t\r ]+<strong>(.*?)</strong>")
            .getMatch(0);
    String premiumActive =
        br.getRegex(
                "<div class=\"icon-timecredit icon\">[\n\t\r]+<h4>Premium account</h4>[\n\t\r]+(.*)[\n\t\r]+<br />[\n\t\r]+<a href=\"/credit/time\">Buy</a>")
            .getMatch(0);

    if (premiumActive == null) {
      // Premium User
      premiumActive =
          br.getRegex(
                  "<div class=\"icon-timecredit icon\">[\n\t\r]+<h4>Premium account</h4>[\n\t\r]+(.*)<br />[\n\t\r]+<a href=\"/credit/time\">Buy</a>")
              .getMatch(0);
    }

    if (premiumActive == null) {
      // User with Credits
      premiumActive =
          br.getRegex(
                  "<div class=\"icon-credit icon\">[\n\t\r]+<h4>(.*)</h4>[\n\t\r]+<table>+[\n\t\r]+<tr>[\n\t\r]+<th>Current:</th>[\n\t\r]+<td>(.*?)</td>[\n\t\r]+</tr>")
              .getMatch(0);
    }

    if (trafficleft != null) {
      ai.setTrafficLeft(SizeFormatter.getSize(trafficleft));
      ai.setValidUntil(-1);
      ai.setStatus("Account with credits");
      account.setValid(true);
      account.setProperty("free", false);
    } else if (premiumActive == null) {
      ai.setStatus("Invalid/Unknown");
      account.setValid(false);
    } else if (premiumActive.contains("Inactive")) {
      ai.setStatus("Free User");
      // for inactive - set traffic left to 0
      ai.setTrafficLeft(0l);
      account.setValid(true);
      account.setProperty("free", true);
    } else if (premiumActive.contains("Active")) {
      String validUntil = premiumActive.substring(premiumActive.indexOf(":") + 1);
      // page only displays full day, so JD fails in the last day of Premium
      // added time as if the account is Premium until the midnight
      validUntil += " 23:59:59";
      ai.setValidUntil(TimeFormatter.getMilliSeconds(validUntil, "dd.MM.yyyy HH:mm:ss", null));
      ai.setStatus("Premium accoount");
      ai.setExpired(false);
      account.setValid(true);
      account.setProperty("free", false);
    }
    return ai;
  }
Esempio n. 16
0
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   final AccountInfo ai = new AccountInfo();
   /* reset maxPrem workaround on every fetchaccount info */
   maxPrem.set(1);
   try {
     login(account, true);
   } catch (final PluginException e) {
     account.setValid(false);
     throw e;
   }
   final String space[] =
       new Regex(correctedBR, ">Used space:</td>.*?<td.*?b>([0-9\\.]+) ?(KB|MB|GB|TB)?</b>")
           .getRow(0);
   if ((space != null && space.length != 0) && (space[0] != null && space[1] != null)) {
     // free users it's provided by default
     ai.setUsedSpace(space[0] + " " + space[1]);
   } else if ((space != null && space.length != 0) && space[0] != null) {
     // premium users the Mb value isn't provided for some reason...
     ai.setUsedSpace(space[0] + "Mb");
   }
   account.setValid(true);
   final String availabletraffic =
       new Regex(correctedBR, "Traffic available.*?:</TD><TD><b>([^<>\"\\']+)</b>").getMatch(0);
   if (availabletraffic != null
       && !availabletraffic.contains("nlimited")
       && !availabletraffic.equalsIgnoreCase(" Mb")) {
     availabletraffic.trim();
     // need to set 0 traffic left, as getSize returns positive result, even when negative value
     // supplied.
     if (!availabletraffic.startsWith("-")) {
       ai.setTrafficLeft(SizeFormatter.getSize(availabletraffic));
     } else {
       ai.setTrafficLeft(0);
     }
   } else {
     ai.setUnlimitedTraffic();
   }
   if (account.getBooleanProperty("nopremium")) {
     ai.setStatus("Registered (free) User");
     try {
       maxPrem.set(1);
       // free accounts can still have captcha.
       totalMaxSimultanFreeDownload.set(maxPrem.get());
       account.setMaxSimultanDownloads(maxPrem.get());
       account.setConcurrentUsePossible(false);
     } catch (final Throwable e) {
       // not available in old Stable 0.9.581
     }
   } else {
     final String expire =
         new Regex(
                 correctedBR,
                 "(\\d{1,2} (January|February|March|April|May|June|July|August|September|October|November|December) \\d{4})")
             .getMatch(0);
     if (expire == null) {
       ai.setExpired(true);
       account.setValid(false);
       return ai;
     } else {
       ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMMM yyyy", Locale.ENGLISH));
       try {
         maxPrem.set(20);
         account.setMaxSimultanDownloads(maxPrem.get());
         account.setConcurrentUsePossible(true);
       } catch (final Throwable e) {
         // not available in old Stable 0.9.581
       }
     }
     ai.setStatus("Premium User");
   }
   return ai;
 }
Esempio n. 17
0
  private AccountInfo fetchAccountInfoWebsite(final Account account) {
    final AccountInfo ai = new AccountInfo();
    boolean hours = false;

    if (account.getType() == AccountType.PREMIUM) {
      final String dailyLimitLeft =
          br.getRegex("<li><a href=\"/premium\">([^<>\"\\']+)</a></li>").getMatch(0);
      if (dailyLimitLeft != null) {
        ai.setTrafficMax(SizeFormatter.getSize("20 GB"));
        ai.setTrafficLeft(SizeFormatter.getSize(dailyLimitLeft, true, true));
      } else {
        ai.setUnlimitedTraffic();
      }

      String expire =
          br.getRegex(
                  ">Konto premium ważne do : <strong>(\\d{4}\\-\\d+{2}\\-\\d{2} \\d{2}:\\d{2}:\\d{2})<")
              .getMatch(0);
      if (expire == null) {
        expire = br.getRegex("(\\d{4}\\-\\d+{2}\\-\\d{2} \\d{2}:\\d{2}:\\d{2})").getMatch(0);
        if (expire == null) {
          // for the last day of the premium period
          if (br.containsHTML("Konto premium ważne do : <strong>-</strong></span>")) {
            // 0 days left
            expire =
                br.getRegex(
                        "<a href=\"/premium\">(Konto:[\t\n\r ]+)*Premium \\(<b>(\\d) dni</b>\\)+[ \t\n\r]+</a>")
                    .getMatch(1);
            if (expire == null) {
              expire =
                  br.getRegex(
                          "(Konto:[\r\t\n ]+)+Premium \\(<b><span style=\"color: red\">(\\d+) godzin</span></b>\\)")
                      .getMatch(1);
              hours = true;
            }
          }
          if (expire == null) {
            ai.setExpired(true);
            return ai;
          }
        }
      }
      if (expire.equals("0") && (dailyLimitLeft != null)) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateNow = formatter.format(Calendar.getInstance().getTime());
        dateNow = dateNow + " 23:59:59";
        ai.setValidUntil(
            TimeFormatter.getMilliSeconds(dateNow, "yyyy-MM-dd HH:mm:ss", Locale.ENGLISH));
      } else {
        if (hours) {
          SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          Calendar cal = Calendar.getInstance();
          cal.setTime(new Date());
          cal.add(Calendar.HOUR_OF_DAY, Integer.parseInt(expire));
          String dateExpire = formatter.format(cal.getTime());

          ai.setValidUntil(
              TimeFormatter.getMilliSeconds(dateExpire, "yyyy-MM-dd HH:mm:ss", Locale.ENGLISH));

        } else {
          ai.setValidUntil(
              TimeFormatter.getMilliSeconds(expire, "yyyy-MM-dd HH:mm:ss", Locale.ENGLISH));
        }
      }
      account.setMaxSimultanDownloads(-1);
      account.setConcurrentUsePossible(true);

      ai.setStatus(getPhrase("PREMIUM"));
    } else {
      account.setMaxSimultanDownloads(1);
      ai.setStatus(getPhrase("FREE"));
    }

    return ai;
  }
    protected void onChunksReady() {
        logger.info("Close connections if they are not closed yet");
        try {
            for (RAFChunk c : this.getChunks()) {
                c.closeConnections();
            }
        } finally {
            logger.info("Close File. Let AV programs run");
            try {
                outputPartFile.close();
            } catch (Throwable e) {
            }
        }
        downloadLink.getLinkStatus().setStatusText(null);
        if (!handleErrors()) return;
        try {
            File part = new File(outputCompleteFile.getAbsolutePath() + ".part");
            /* lets check the hash/crc/sfv */
            if (JsonConfig.create(GeneralSettings.class).isHashCheckEnabled()) {
                synchronized (HASHCHECKLOCK) {
                    /*
                     * we only want one hashcheck running at the same time. many finished downloads can cause heavy diskusage here
                     */
                    String hash = null;
                    String type = null;
                    Boolean success = null;

                    // StatsManager
                    if ((hash = downloadLink.getMD5Hash()) != null && hash.length() == 32) {
                        /* MD5 Check */
                        type = "MD5";
                        downloadLink.getLinkStatus().setStatusText(_JDT._.system_download_doCRC2("MD5"));
                        String hashFile = Hash.getMD5(part);
                        success = hash.equalsIgnoreCase(hashFile);
                    } else if (!StringUtils.isEmpty(hash = downloadLink.getSha1Hash()) && hash.length() == 40) {
                        /* SHA1 Check */
                        type = "SHA1";
                        downloadLink.getLinkStatus().setStatusText(_JDT._.system_download_doCRC2("SHA1"));
                        String hashFile = Hash.getSHA1(part);
                        success = hash.equalsIgnoreCase(hashFile);
                    } else if ((hash = new Regex(downloadLink.getName(), ".*?\\[([A-Fa-f0-9]{8})\\]").getMatch(0)) != null) {
                        type = "CRC32";
                        String hashFile = Long.toHexString(Hash.getCRC32(part));
                        success = hash.equalsIgnoreCase(hashFile);
                    } else {
                        DownloadLink sfv = null;
                        synchronized (downloadLink.getFilePackage()) {
                            for (DownloadLink dl : downloadLink.getFilePackage().getChildren()) {
                                if (dl.getFileOutput().toLowerCase().endsWith(".sfv")) {
                                    sfv = dl;
                                    break;
                                }
                            }
                        }
                        /* SFV File Available, lets use it */
                        if (sfv != null && sfv.getLinkStatus().hasStatus(LinkStatus.FINISHED)) {
                            String sfvText = IO.readFileToString(new File(sfv.getFileOutput()));
                            if (sfvText != null) {
                                /* Delete comments */
                                sfvText = sfvText.replaceAll(";(.*?)[\r\n]{1,2}", "");
                                if (sfvText != null && sfvText.contains(downloadLink.getName())) {
                                    downloadLink.getLinkStatus().setStatusText(_JDT._.system_download_doCRC2("CRC32"));
                                    type = "CRC32";
                                    String crc = Long.toHexString(Hash.getCRC32(part));
                                    success = new Regex(sfvText, downloadLink.getName() + "\\s*" + crc).matches();
                                }
                            }
                        }
                    }
                    if (success != null) {
                        hashCheckFinished(type, success);
                    }
                }
            }

            boolean renameOkay = false;
            int retry = 5;
            /* rename part file to final filename */
            while (retry > 0) {
                /* first we try normal rename method */
                if ((renameOkay = part.renameTo(outputCompleteFile)) == true) {
                    break;
                }
                /* this may fail because something might lock the file */
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    break;
                }
                retry--;
            }
            /* Fallback */
            if (renameOkay == false) {
                /* rename failed, lets try fallback */
                logger.severe("Could not rename file " + part + " to " + outputCompleteFile);
                logger.severe("Try copy workaround!");
                try {
                    //DISKSPACECHECK freeSpace = DownloadWatchDog.getInstance().checkFreeDiskSpace(part.getParentFile(), part.length());
                    //if (DISKSPACECHECK.FAILED.equals(freeSpace)) throw new Throwable("not enough diskspace free to copy part to complete file");
                    IO.copyFile(part, outputCompleteFile);
                    renameOkay = true;
                    part.deleteOnExit();
                    part.delete();
                } catch (Throwable e) {
                    LogSource.exception(logger, e);
                    /* error happened, lets delete complete file */
                    if (outputCompleteFile.exists() && outputCompleteFile.length() != part.length()) {
                        outputCompleteFile.delete();
                        outputCompleteFile.deleteOnExit();
                    }
                }
                if (!renameOkay) {
                    logger.severe("Copy workaround: :(");
                    error(LinkStatus.ERROR_LOCAL_IO, _JDT._.system_download_errors_couldnotrename());
                } else {
                    logger.severe("Copy workaround: :)");
                }
            }
            if (renameOkay) {

                /*if (StatsManager.I().isEnabled()) {
                    long speed = 0;
                    long startDelay = -1;
                    try {
                        speed = (outputCompleteFile.length() - Math.max(0, sizeBefore)) / ((System.currentTimeMillis() - getStartTimeStamp()) / 1000);
                    } catch (final Throwable e) {
                        LogSource.exception(logger, e);
                    }
                    try {
                        startDelay = System.currentTimeMillis() - downloadLink.getDownloadLinkController().getStartTimestamp();
                    } catch (final Throwable e) {
                        LogSource.exception(logger, e);
                    }
                    StatsManager.I().onFileDownloaded(outputCompleteFile, downloadLink, speed, startDelay, getChunks().size());
                }*/

                /* save absolutepath as final location property */
                downloadLink.setProperty(DownloadLink.PROPERTY_FINALLOCATION, outputCompleteFile.getAbsolutePath());
                Date last = TimeFormatter.parseDateString(connection.getHeaderField("Last-Modified"));
                if (last != null && JsonConfig.create(GeneralSettings.class).isUseOriginalLastModified()) {
                    /* set original lastModified timestamp */
                    outputCompleteFile.setLastModified(last.getTime());
                } else {
                    /* set current timestamp as lastModified timestamp */
                    outputCompleteFile.setLastModified(System.currentTimeMillis());
                }
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Exception", e);
            addException(e);
        }
    }
Esempio n. 19
0
 @Override
 public AccountInfo fetchAccountInfo(Account account) throws Exception {
   AccountInfo ai = new AccountInfo();
   /* reset maxPrem workaround on every fetchaccount info */
   maxPrem.set(1);
   try {
     login(account, true);
   } catch (PluginException e) {
     account.setValid(false);
     return ai;
   }
   String space[][] =
       new Regex(
               correctedBR,
               "<td>Used space:</td>.*?<td.*?b>([0-9\\.]+) of [0-9\\.]+ (KB|MB|GB|TB)</b>")
           .getMatches();
   if ((space != null && space.length != 0) && (space[0][0] != null && space[0][1] != null))
     ai.setUsedSpace(space[0][0] + " " + space[0][1]);
   account.setValid(true);
   String availabletraffic =
       new Regex(correctedBR, "Traffic available.*?:</TD><TD><b>([^<>\"\\']+)</b>").getMatch(0);
   if (availabletraffic != null
       && !availabletraffic.contains("nlimited")
       && !availabletraffic.equalsIgnoreCase(" Mb")) {
     ai.setTrafficLeft(SizeFormatter.getSize(availabletraffic));
   } else {
     ai.setUnlimitedTraffic();
   }
   if (account.getBooleanProperty("nopremium")) {
     ai.setStatus("Registered (free) User");
     try {
       maxPrem.set(4);
       // free accounts can still have captcha.
       totalMaxSimultanFreeDownload.set(maxPrem.get());
       account.setMaxSimultanDownloads(4);
       account.setConcurrentUsePossible(false);
     } catch (final Throwable e) {
     }
   } else {
     String expire =
         new Regex(
                 correctedBR,
                 "<td>Premium(\\-| )Account expires?:</td>.*?<td>(<b>)?(\\d{1,2} [A-Za-z]+ \\d{4})(</b>)?</td>")
             .getMatch(2);
     if (expire == null)
       expire = new Regex(correctedBR, "(\\d{1,2} [A-Za-z]+ \\d{4})").getMatch(0);
     if (expire == null) {
       ai.setExpired(true);
       account.setValid(false);
       return ai;
     } else {
       expire = expire.replaceAll("(<b>|</b>)", "");
       ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMMM yyyy", null));
       try {
         maxPrem.set(-1);
         account.setMaxSimultanDownloads(-1);
         account.setConcurrentUsePossible(true);
       } catch (final Throwable e) {
       }
     }
     ai.setStatus("Premium User");
   }
   return ai;
 }
Esempio n. 20
0
 @Override
 public AccountInfo fetchAccountInfo(Account account) throws Exception {
   AccountInfo ai = new AccountInfo();
   try {
     login(account, true);
   } catch (PluginException e) {
     account.setValid(false);
     return ai;
   }
   String space =
       br.getRegex(
               Pattern.compile(
                   "<td>Used space:</td>.*?<td.*?b>([0-9\\.]+) of [0-9\\.]+ (Mb|GB)</b>",
                   Pattern.DOTALL | Pattern.CASE_INSENSITIVE))
           .getMatch(0);
   if (space != null) ai.setUsedSpace(space.trim() + " Mb");
   String points =
       br.getRegex(
               Pattern.compile(
                   "<td>You have collected:</td.*?b>([^<>\"\\']+)premium points",
                   Pattern.CASE_INSENSITIVE))
           .getMatch(0);
   if (points != null) {
     /** Who needs half points ? If we have a dot in the points, just remove it */
     if (points.contains(".")) {
       String dot = new Regex(points, ".*?(\\.(\\d+))").getMatch(0);
       points = points.replace(dot, "");
     }
     ai.setPremiumPoints(Long.parseLong(points.trim()));
   }
   account.setValid(true);
   String availabletraffic =
       new Regex(correctedBR, "Traffic available.*?:</TD><TD><b>([^<>\"\\']+)</b>").getMatch(0);
   if (availabletraffic != null
       && !availabletraffic.contains("nlimited")
       && !availabletraffic.equalsIgnoreCase(" Mb")) {
     ai.setTrafficLeft(SizeFormatter.getSize(availabletraffic));
   } else {
     ai.setUnlimitedTraffic();
   }
   if (account.getBooleanProperty("nopremium")) {
     ai.setStatus("Registered (free) User");
   } else {
     String expire =
         new Regex(
                 correctedBR,
                 Pattern.compile(
                     "<td>Premium(\\-| )Account expires?:</td>.*?<td>(<b>)?(\\d{1,2} [A-Za-z]+ \\d{4})(</b>)?</td>",
                     Pattern.CASE_INSENSITIVE))
             .getMatch(2);
     if (expire == null) {
       ai.setExpired(true);
       account.setValid(false);
       return ai;
     } else {
       expire = expire.replaceAll("(<b>|</b>)", "");
       ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMMM yyyy", null));
     }
     ai.setStatus("Premium User");
   }
   return ai;
 }
  @Override
  public AccountInfo fetchAccountInfo(Account account) throws Exception {
    final AccountInfo ac = new AccountInfo();
    br.setConnectTimeout(60 * 1000);
    br.setReadTimeout(60 * 1000);
    ac.setProperty("multiHostSupport", Property.NULL);
    // check if account is valid
    if (!login(account, true)) {
      final String lang = System.getProperty("user.language");
      if ("de".equalsIgnoreCase(lang)) {
        throw new PluginException(
            LinkStatus.ERROR_PREMIUM,
            "\r\nUngültiger Benutzername/Passwort oder Login Captcha falsch eingegeben!\r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen? Versuche folgendes:\r\n1. Falls dein Passwort Sonderzeichen enthält, ändere es (entferne diese) und versuche es erneut!\r\n2. Gib deine Zugangsdaten per Hand (ohne kopieren/einfügen) ein.",
            PluginException.VALUE_ID_PREMIUM_DISABLE);
      } else {
        throw new PluginException(
            LinkStatus.ERROR_PREMIUM,
            "\r\nInvalid username/password or wrong login captcha input!\r\nYou're sure that the username and password you entered are correct? Some hints:\r\n1. If your password contains special characters, change it (remove them) and try again!\r\n2. Type in your username/password by hand without copy & paste.",
            PluginException.VALUE_ID_PREMIUM_DISABLE);
      }
    }
    br.getPage("http://www.premiumax.net/profile/");
    boolean is_freeaccount = false;
    final String expire =
        br.getRegex("<span>Premium until: </span><strong>([^<>\"]*?)</strong>").getMatch(0);
    if (expire != null) {
      ac.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd.MM.yyyy hh:mm", Locale.ENGLISH));
      ac.setStatus("Premium User");
    } else {
      ac.setStatus("Registered (free) user");
      is_freeaccount = true;
    }
    ac.setUnlimitedTraffic();
    // now let's get a list of all supported hosts:
    final ArrayList<String> supportedHosts = new ArrayList<String>();

    br.getPage("http://www.premiumax.net/hosts.html");
    /* Apply supported hosts depending on account type */
    for (final String[] filehost : HOSTS) {
      final String crippledHost = filehost[0];
      final String realHost = filehost[1];
      final String hostText =
          br.getRegex("<span>" + crippledHost + "</span>(.*?)</tr>").getMatch(0);
      if (hostText != null) {
        final String[] imgs = new Regex(hostText, "src=\"(tmpl/images/[^<>\"]*?)\"").getColumn(0);
        if (imgs != null
            && imgs.length >= 4
            && imgs[3].equals("tmpl/images/ico_yes.png")
            && (!is_freeaccount && imgs[2].equals("tmpl/images/ico_yes.png")
                || is_freeaccount && imgs[1].equals("tmpl/images/ico_yes.png"))) {
          supportedHosts.add(realHost);
        }
      }
    }
    if (supportedHosts.contains("uploaded.net")
        || supportedHosts.contains("ul.to")
        || supportedHosts.contains("uploaded.to")) {
      if (!supportedHosts.contains("uploaded.net")) {
        supportedHosts.add("uploaded.net");
      }
      if (!supportedHosts.contains("ul.to")) {
        supportedHosts.add("ul.to");
      }
      if (!supportedHosts.contains("uploaded.to")) {
        supportedHosts.add("uploaded.to");
      }
    }
    ac.setProperty("multiHostSupport", supportedHosts);
    return ac;
  }
Esempio n. 22
0
  private void loginAPI(Account account, AccountInfo ai) throws IOException, PluginException {
    synchronized (LOGINLOCK) {
      workAroundTimeOut(br);
      if (ai == null) {
        ai = account.getAccountInfo();
        if (ai == null) {
          ai = new AccountInfo();
          account.setAccountInfo(ai);
        }
      }
      br.getPage("http://www.zevera.com/");
      String res =
          br.getPage(
              "http://www.zevera.com/jDownloader.ashx?cmd=accountinfo&login="******"&pass="******"user.language");
      if ("No trafic".equals(res) || res == null || res.trim().length() == 0) {
        if ("de".equalsIgnoreCase(lang)) {
          throw new PluginException(
              LinkStatus.ERROR_PREMIUM,
              "\r\nUngültiger Benutzername/Passwort oder Traffic aufgebraucht!\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 or no traffic left!\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);
        }
      }
      res = res.trim();
      account.setValid(true);
      if ("Login Error".equalsIgnoreCase(res)) {
        ai.setStatus("Unknown user");
        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);
        }
      } else {
        /* normal premium */
        // 0 DayTrafficLimit:5120,
        // 1 EndSubscriptionDate:2012/6/29 0:0:0,
        // 2 TrafficUsedToday:0,
        // 3 AvailableTodayTraffic5120,
        // 4 OronDayTrafficLimit:5120
        ai.setStatus("Premium");
        String infos[] = br.getRegex("(.*?)(,|$)").getColumn(0);
        if (infos == null || infos.length != 6) {
          logger.info(br.toString());
        }
        String EndSubscriptionDate = new Regex(infos[1], "EndSubscriptionDate:(.+)").getMatch(0);
        ai.setValidUntil(
            TimeFormatter.getMilliSeconds(EndSubscriptionDate, "yyyy/MM/dd HH:mm:ss", null));

        /* Traffic balance not working in Zevera JD API */
        // Integer DayTraffic = Integer.parseInt(new
        // Regex(infos[0],"DayTrafficLimit:(.+)").getMatch(0).trim());
        // Integer TrafficUsedToday = Integer.parseInt(new
        // Regex(infos[0],"TrafficUsedToday:(.+)").getMatch(0).trim());
        // Integer Balance = DayTraffic - TrafficUsedToday;
        // ai.setAccountBalance(Balance * 1024);
        String AvailableTodayTraffic =
            new Regex(infos[3], "AvailableTodayTraffic:(\\d+)").getMatch(0);
        logger.info("Zevera: AvailableTodayTraffic=" + AvailableTodayTraffic);
        ai.setTrafficLeft(SizeFormatter.getSize(AvailableTodayTraffic + "mb"));
        if (ai.isExpired()) {
          if ("de".equalsIgnoreCase(lang)) {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nAccount abgelaufen!",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          } else {
            throw new PluginException(
                LinkStatus.ERROR_PREMIUM,
                "\r\nAccount expired!",
                PluginException.VALUE_ID_PREMIUM_DISABLE);
          }
        }
      }
    }
  }
Esempio n. 23
0
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   final AccountInfo ai = new AccountInfo();
   /* reset maxPrem workaround on every fetchaccount info */
   maxPrem.set(1);
   try {
     login(account, true);
   } catch (PluginException e) {
     account.setValid(false);
     return ai;
   }
   getPage(this.br, "/accounts");
   if (account.getBooleanProperty("free", false) || br.containsHTML(">expired")) {
     try {
       maxPrem.set(1);
       // free accounts can still have captcha.
       account.setMaxSimultanDownloads(maxPrem.get());
       account.setConcurrentUsePossible(false);
     } catch (final Throwable e) {
       // not available in old Stable 0.9.581
     }
     ai.setUnlimitedTraffic();
     ai.setStatus("Registered (free) user");
   } else {
     String ends = br.getRegex("Ends:</span>.*?<span>(.*?)<").getMatch(0);
     /* there are 2 different versions of account info pages */
     if (ends == null) {
       ends = br.getRegex("End time:(.*?)<").getMatch(0);
     }
     if (ends == null) {
       ends = br.getRegex("Starts:.*?Ends: (.*?)<").getMatch(0);
     }
     if (ends == null) {
       ends = br.getRegex("Duration:(.*?)<").getMatch(0);
     }
     if (ends != null) {
       ends = ends.trim();
     }
     if (ends == null) {
       account.setValid(false);
       return ai;
     }
     if ("unlimited".equalsIgnoreCase(ends)) {
       ai.setValidUntil(-1);
     } else {
       ai.setValidUntil(
           TimeFormatter.getMilliSeconds(
               ends.replaceAll(", in", "").trim(), "dd MMM yyyy HH:mm:ss", null));
     }
     try {
       maxPrem.set(20);
       account.setMaxSimultanDownloads(maxPrem.get());
       account.setConcurrentUsePossible(true);
     } catch (final Throwable e) {
       // not available in old Stable 0.9.581
     }
     final String trafficLeft = br.getRegex("Traffic left:(.*?)<").getMatch(0);
     if (trafficLeft != null) {
       /* it seems they have unlimited traffic */
       // ai.setTrafficLeft(SizeFormatter.getSize(trafficLeft));
       ai.setUnlimitedTraffic();
     } else {
       ai.setUnlimitedTraffic();
     }
     ai.setStatus("Premium user");
   }
   account.setValid(true);
   return ai;
 }