Ejemplo n.º 1
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.º 2
0
 private AccountInfo fetchAccountInfoAPI(final Account account) {
   final AccountInfo ai = new AccountInfo();
   final String type = PluginJSonUtils.getJsonValue(br, "type");
   final String expireTime = PluginJSonUtils.getJsonValue(br, "expireTime");
   final String traffic = PluginJSonUtils.getJsonValue(br, "traffic");
   long expire_long = 0;
   if (expireTime != null) {
     expire_long = Long.parseLong(expireTime) * 1000l;
   }
   if ("Free".equals(type) || expire_long < System.currentTimeMillis()) {
     account.setType(AccountType.FREE);
     account.setMaxSimultanDownloads(1);
     ai.setStatus(getPhrase("FREE"));
   } else {
     account.setType(AccountType.PREMIUM);
     ai.setStatus(getPhrase("PREMIUM"));
   }
   if (traffic != null) {
     ai.setTrafficLeft(Long.parseLong(traffic));
   }
   if (expire_long > System.currentTimeMillis()) {
     ai.setValidUntil(Long.parseLong(expireTime) * 1000l);
   }
   return ai;
 }
Ejemplo n.º 3
0
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   AccountInfo ai = new AccountInfo();
   /* reset maxPrem workaround on every fetchaccount info */
   try {
     synchronized (account) {
       String token = api_getAccessToken(account, false);
       String tokenType = null;
       try {
         tokenType = api_getTokenType(account, token, true);
       } catch (final PluginException e) {
         token = api_getAccessToken(account, false);
         tokenType = api_getTokenType(account, token, true);
       }
       if ("free".equals(tokenType)) {
         /* free user */
         ai.setStatus("Free accounts are not supported");
         account.setValid(false);
         account.setProperty("token", null);
         account.setProperty("tokenType", null);
       } else if ("premium".equals(tokenType)) {
         String traffic = br.getRegex("traffic_left\":\\s*?\"?(\\d+)").getMatch(0);
         long max = 100 * 1024 * 1024 * 1024l;
         long current = Long.parseLong(traffic);
         ai.setTrafficMax(Math.max(max, current));
         ai.setTrafficLeft(current);
         String expireDate = br.getRegex("account_premium\":\\s*?\"?(\\d+)").getMatch(0);
         ai.setValidUntil(Long.parseLong(expireDate) * 1000);
         if (current <= 0 || br.containsHTML("download_available\":false")) {
           String refreshIn = br.getRegex("traffic_reset\":\\s*?(\\d+)").getMatch(0);
           if (refreshIn != null) {
             account.setProperty(
                 "PROPERTY_TEMP_DISABLED_TIMEOUT", Long.parseLong(refreshIn) * 1000);
           } else {
             account.setProperty("PROPERTY_TEMP_DISABLED_TIMEOUT", Property.NULL);
           }
           logger.info("Download_available: " + br.containsHTML("download_available\":true"));
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_TEMP_DISABLE);
         }
         ai.setStatus("Premium account");
         if (!ai.isExpired()) account.setValid(true);
       } else {
         throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       }
     }
   } catch (final PluginException e) {
     account.setProperty("token", null);
     account.setProperty("tokenType", null);
     throw e;
   }
   return ai;
 }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 5
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;
  }
  @Override
  public AccountInfo fetchAccountInfo(Account account) throws Exception {
    AccountInfo ai = new AccountInfo();
    setBrowserExclusive();
    HashMap<String, String> infos = null;
    try {
      infos = loginAPI(account, true);
    } catch (final PluginException e) {
      account.setValid(false);
      throw e;
    }
    /* evaluate expire date */
    final Long validUntil = Long.parseLong(infos.get("expire_date"));
    account.setValid(true);
    if (validUntil > 0) {
      ai.setValidUntil(validUntil * 1000);
    } else {
      ai.setValidUntil(-1);
    }
    if (infos.containsKey("points")) {
      ai.setPremiumPoints(Long.parseLong(infos.get("points")));
    }
    if (infos.containsKey("money")) {
      ai.setAccountBalance(infos.get("money"));
    }
    /* set account type */
    ai.setStatus(infos.get("group"));

    if (userTrafficWorkaround()) {
      long max = 100 * 1024 * 1024 * 1024l; // 100 GB per day - 420 GB per week
      String traffic = infos.get("traffic_1d"); // traffic_7d = week
      String trafficdata[] = traffic.split(";");
      long current = Long.parseLong(trafficdata[0].trim());
      ai.setTrafficMax(Math.max(max, current));
      ai.setTrafficLeft((max - current));
    }

    return ai;
  }
Ejemplo n.º 7
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.º 8
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);
          }
        }
      }
    }
  }
Ejemplo n.º 9
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.º 10
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.º 11
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.º 12
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;
  }
Ejemplo n.º 13
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;
  }
Ejemplo n.º 14
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.º 15
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.º 16
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;
 }