Ejemplo n.º 1
0
 @SuppressWarnings("deprecation")
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   final AccountInfo ai = new AccountInfo();
   try {
     login(account, true);
   } catch (PluginException e) {
     account.setValid(false);
     throw e;
   }
   prepBRAjax(account);
   this.br.getPage("https://www." + this.getHost() + "/api/payments?limit=25&offset=0");
   ai.setUnlimitedTraffic();
   final String subscriptioncount = PluginJSonUtils.getJsonValue(this.br, "count");
   if (subscriptioncount == null || subscriptioncount.equals("0")) {
     account.setType(AccountType.FREE);
     /* free accounts can still have captcha */
     account.setMaxSimultanDownloads(ACCOUNT_PREMIUM_MAXDOWNLOADS);
     account.setConcurrentUsePossible(false);
     ai.setStatus("Registered (free) user");
   } else {
     /* TODO: Add expire date */
     // final String expire = null;
     // if (expire != null) {
     // ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMMM yyyy", Locale.ENGLISH));
     // }
     account.setType(AccountType.PREMIUM);
     account.setMaxSimultanDownloads(ACCOUNT_PREMIUM_MAXDOWNLOADS);
     account.setConcurrentUsePossible(true);
     ai.setStatus("Premium account");
   }
   account.setValid(true);
   return ai;
 }
Ejemplo 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;
 }
Ejemplo 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;
 }
Ejemplo n.º 4
0
 private void updateAccountInfo(final Account account, final Browser br) {
   if (account == null || br == null) {
     return;
   }
   AccountInfo ai = account.getAccountInfo();
   if (ai == null) {
     ai = new AccountInfo();
     account.setAccountInfo(ai);
   }
   /* let hoster report traffic limit reached! */
   // ai.setSpecialTraffic(true);
   /* reset expired flag */
   ai.setExpired(false);
   ai.setValidUntil(-1);
   account.setValid(true);
   ai.setUnlimitedTraffic();
   try {
     final String[][] matches = br.getRegex("(\\w+)=([^\r^\n]+)").getMatches();
     final HashMap<String, String> data = this.getMap(matches);
     final long rapids = Long.parseLong(data.get("rapids"));
     /* account infos */
     ai.setFilesNum(Long.parseLong(data.get("curfiles")));
     ai.setPremiumPoints(Long.parseLong(data.get("rapids")));
     ai.setUsedSpace(Long.parseLong(data.get("curspace")));
     boolean autoextend = "1".equals(data.get("autoextend"));
     final String billedUntilTime = data.get("billeduntil");
     final String serverTimeString = data.get("servertime");
     long nextBill = 0;
     if (billedUntilTime != null && serverTimeString != null) {
       /* next billing in */
       nextBill = Long.parseLong(billedUntilTime) - Long.parseLong(serverTimeString);
       if (nextBill <= 0) {
         String possible = "";
         if (autoextend) {
           long days = (rapids / 495) * 30;
           if (days > 0) {
             possible = "(enough rapids for " + days + " days RapidPro left)";
           }
         }
         ai.setStatus("No RapidPro" + possible);
         ai.setExpired(true);
         account.setValid(false);
       } else {
         if (autoextend) {
           long days = (rapids / 495) * 30;
           if (days > 0) {
             nextBill = nextBill + (days * 24 * 60);
           }
         }
         final String left = Formatter.formatSeconds(nextBill, false);
         ai.setValidUntil((Long.parseLong(serverTimeString) + nextBill) * 1000l);
         ai.setStatus("Valid for " + left);
       }
     }
   } catch (final Throwable e) {
     logger.severe("RS-API change detected, please inform support!");
   }
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
 @Override
 public AccountInfo fetchAccountInfo(Account account) throws Exception {
   AccountInfo ai = new AccountInfo();
   try {
     login(account);
   } catch (PluginException e) {
     account.setValid(false);
     return ai;
   }
   ai.setUnlimitedTraffic();
   ai.setStatus("Registered User");
   return ai;
 }
Ejemplo n.º 7
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 hostedFiles = br.getRegex("<td>Files Hosted:</td>[\t\r\n ]+<td>(\\d+)</td>").getMatch(0);
   if (hostedFiles != null) ai.setFilesNum(Integer.parseInt(hostedFiles));
   String space =
       br.getRegex("<td>Spaced Used:</td>[\t\n\r ]+<td>(.*?) " + PREMIUMLIMIT).getMatch(0);
   if (space != null) ai.setUsedSpace(space.trim());
   account.setValid(true);
   ai.setUnlimitedTraffic();
   ai.setStatus("Premium User");
   return ai;
 }
Ejemplo 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;
 }
Ejemplo 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;
 }
Ejemplo n.º 10
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;
  }
Ejemplo 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;
  }
Ejemplo n.º 12
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;
 }
Ejemplo n.º 13
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;
 }
Ejemplo n.º 14
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;
 }
Ejemplo n.º 15
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;
   }
   final 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);
   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(20);
       // 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 {
     // String expire = new Regex(correctedBR,
     // "<td>Premium(\\-| )Account expires?:</td>.*?<td>(<b>)?(\\d{1,2} [A-Za-z]+
     // \\d{4})(</b>)?</td>").getMatch(2);
     // admin wants us to use this instead of the standard, as you can still access the site on
     // that expire day..
     String timeleft =
         new Regex(correctedBR, "<tr><td><b>Expires:</b></td><td>([^<]+)</td></tr><br>")
             .getMatch(0);
     if (timeleft != null) {
       String tmpdays = new Regex(timeleft, "(\\d+)\\s+days?").getMatch(0);
       String tmphrs = new Regex(timeleft, "(\\d+)\\s+hours?").getMatch(0);
       String tmpmin = new Regex(timeleft, "(\\d+)\\s+minutes?").getMatch(0);
       String tmpsec = new Regex(timeleft, "(\\d+)\\s+seconds?").getMatch(0);
       if (tmphrs == null && tmpmin == null && tmpsec == null && tmpdays == null) {
         logger.info("timeleft regexes seem to be broken");
         throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 60 * 60 * 1000l);
       } else {
         long years = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
         if (tmpdays != null) days = Integer.parseInt(tmpdays);
         if (tmphrs != null) hours = Integer.parseInt(tmphrs);
         if (tmpmin != null) minutes = Integer.parseInt(tmpmin);
         if (tmpsec != null) seconds = Integer.parseInt(tmpsec);
         long timeLeft =
             ((years * 86400000 * 365)
                     + (days * 86400000)
                     + (hours * 3600000)
                     + (minutes * 60000)
                     + (seconds * 1000))
                 + System.currentTimeMillis();
         ai.setValidUntil(timeLeft);
         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");
     }
     if (timeleft == null) {
       ai.setExpired(true);
       account.setValid(false);
       return ai;
     }
   }
   return ai;
 }
Ejemplo n.º 16
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;
  }
  @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;
  }
Ejemplo n.º 18
0
  @Override
  public AccountInfo fetchAccountInfo(final Account account) throws Exception {
    setConstants(account, null);
    final AccountInfo ac = new AccountInfo();
    br.setFollowRedirects(true);
    getPage(
        mProt
            + mName
            + "/filehostapi?action=accountstatus&user_id="
            + Encoding.urlEncode(account.getUser())
            + "&pin="
            + Encoding.urlEncode(account.getPass()));
    if ("error".equals(this.getJson("status"))) {
      if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
        throw new PluginException(
            LinkStatus.ERROR_PREMIUM,
            "\r\nUngültiger Benutzername/Passwort!\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!\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);
      }
    }
    /* Account is valid, let's fetch account details */
    final String premium_until = getJson("premium_until");
    long premium_until_long = 0;
    if (premium_until.matches("\\d+")) {
      premium_until_long = Long.parseLong(premium_until);
    }
    try {
      if (premium_until_long > 0) {
        premium_until_long *= 1000l;
        ac.setValidUntil(premium_until_long);
        ac.setUnlimitedTraffic();
        account.setType(AccountType.PREMIUM);
        ac.setStatus("Premium Account");
      } else {
        ac.setTrafficLeft(0);
        /* TODO: Get this information via API and also show it for premium accounts */
        ac.setTrafficMax(maxtraffic_daily);
        account.setType(AccountType.FREE);
        ac.setStatus("Registered (free) account");
      }
    } catch (Exception e) {
      throw new PluginException(
          LinkStatus.ERROR_PREMIUM,
          "\r\nCan not parse premium_until!",
          PluginException.VALUE_ID_PREMIUM_DISABLE);
    }

    // now it's time to get all supported hosts
    getPage(
        "/filehostapi?action=hosts&user_id="
            + Encoding.urlEncode(account.getUser())
            + "&pin="
            + Encoding.urlEncode(account.getPass()));
    if (inValidStatus()) {
      throw new PluginException(
          LinkStatus.ERROR_PREMIUM,
          "\r\nCan not parse supported hosts!",
          PluginException.VALUE_ID_PREMIUM_TEMP_DISABLE);
    }
    final String hostsArray = getJsonArray("hosts");
    final String[] hosts = new Regex(hostsArray, "\"(.*?)\"").getColumn(0);
    ArrayList<String> supportedHosts = new ArrayList<String>(Arrays.asList(hosts));
    ac.setMultiHostSupport(this, supportedHosts);
    account.setValid(true);
    return ac;
  }
Ejemplo n.º 19
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;
 }
Ejemplo n.º 20
0
  @Override
  public AccountInfo fetchAccountInfo(Account account) throws Exception {

    AccountInfo ai = new AccountInfo();

    // Always Authenticate (in case the user changed username/password in the settings)
    LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.put("email", account.getUser());
    parameters.put("password", account.getPass());

    APIResponse response = this.unauthorizedApiRequest("/v1/auth", parameters);

    if (response.getResponseCode() == 401) {
      throw new PluginException(
          LinkStatus.ERROR_PREMIUM, "Wrong Login", PluginException.VALUE_ID_PREMIUM_DISABLE);
    } else if (response.getResponseCode() != 200) {
      throw new PluginException(
          LinkStatus.ERROR_PLUGIN_DEFECT,
          "Unknown Error during authentication. Code: " + response.getResponseCode());
    }

    String authenticationToken =
        (String) ((JSonValue) response.getData().get("authentication_token")).getValue();
    account.setProperty("authentication_token", authenticationToken);

    // Query client configuration data
    APIResponse clientConfigurationResponse =
        this.authorizedApiGetRequest(account, "/v1/clientconfiguration/jdownloader");

    if (clientConfigurationResponse.getResponseCode() == 200) {

      // Prepare and store new configuration data
      Map<String, Object> clientConfiguration =
          (Map<String, Object>)
              this.convertJSonToSerializableData(clientConfigurationResponse.getData());
      if (clientConfiguration != null) {

        Map<String, Object> clientConfigurationRoot =
            (Map<String, Object>) clientConfiguration.get("client_configuration");
        if (clientConfigurationRoot != null) {

          System.out.println("New Client Configuration: " + clientConfigurationRoot.toString());
          ai.setProperty(CLIENT_CONFIGURATION_KEY, clientConfigurationRoot);

          // Extract supported hosters
          Map<String, Object> supportedHosters =
              (Map<String, Object>) clientConfigurationRoot.get("supported_hosters");

          ArrayList<String> supportedHosts = new ArrayList<String>();
          for (String hosterName : supportedHosters.keySet()) {
            supportedHosts.add(hosterName);
          }

          ai.setMultiHostSupport(this, supportedHosts);
          account.setConcurrentUsePossible(true);
          account.setMaxSimultanDownloads(-1);
          ai.setStatus("Good");
          ai.setUnlimitedTraffic();

          return ai;
        }
      }
    }
    throw new PluginException(
        LinkStatus.ERROR_PLUGIN_DEFECT,
        "Unknown Error while fetching client configuration data. Code: "
            + response.getResponseCode());
  }
Ejemplo n.º 21
0
 @Override
 public AccountInfo fetchAccountInfo(Account account) throws Exception {
   AccountInfo ac = new AccountInfo();
   br.setConnectTimeout(60 * 1000);
   br.setReadTimeout(60 * 1000);
   String username = Encoding.urlEncode(account.getUser());
   String pass = Encoding.urlEncode(account.getPass());
   String page = null;
   String hosts = null;
   try {
     page =
         br.getPage(
             "http://www."
                 + hostPublicDomain
                 + "/api/get_pa_info.php?login="******"&password="******"http://www." + hostPublicDomain + "/api/get_filehosters.php");
   } catch (Exception e) {
     account.setTempDisabled(true);
     account.setValid(true);
     ac.setProperty("multiHostSupport", Property.NULL);
     return ac;
   }
   if (page.startsWith("ERROR: Auth")) {
     account.setValid(false);
     ac.setProperty("multiHostSupport", Property.NULL);
     ac.setStatus(page);
     return ac;
   }
   /* parse api response in easy2handle hashmap */
   String info[] = new Regex(page, "(\\d+)($|\\|)").getColumn(0);
   boolean isunlimited = "1".equalsIgnoreCase(info[1]);
   long validUntil = Long.parseLong(info[2]);
   long inC = Long.parseLong(info[0]) * 1024 * 1024l;
   long outC = Long.parseLong(info[3]) * 1024 * 1024l;
   if (validUntil == 0) {
     account.setValid(false);
     ac.setProperty("multiHostSupport", Property.NULL);
     return ac;
   }
   ac.setValidUntil(validUntil * 1000);
   if (!isunlimited) {
     ac.setTrafficLeft(Math.min(inC, outC));
   } else {
     ac.setUnlimitedTraffic();
   }
   ArrayList<String> supportedHosts = new ArrayList<String>();
   if (hosts != null) {
     String hoster[] = new Regex(hosts, "(.+?)($|\\|)").getColumn(0);
     for (String host : hoster) {
       if (hosts != null) {
         supportedHosts.add(host.trim());
       }
     }
   }
   if (account.isValid()) {
     ac.setMultiHostSupport(this, supportedHosts);
   } else {
     account.setValid(false);
     ac.setProperty("multiHostSupport", Property.NULL);
     ac.setStatus("Account invalid");
   }
   return ac;
 }
Ejemplo n.º 22
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;
 }