@Override public void handlePremium(DownloadLink downloadLink, Account account) throws Exception { setBrowserExclusive(); workAroundTimeOut(br); showDialog = false; br.setDebug(true); String user = Encoding.urlEncode(account.getUser()); String pw = Encoding.urlEncode(account.getPass()); String link = downloadLink.getDownloadURL(); if (link.contains("getFiles.aspx")) { showMessage(downloadLink, "Downloading file"); user = account.getUser(); pw = account.getPass(); String basicauth = "Basic " + Encoding.Base64Encode(user + ":" + pw); br.getHeaders().put("Authorization", basicauth); br.setFollowRedirects(true); dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, link, true, 0); } else { showMessage(downloadLink, "Phase 1/2: Get FileID"); String FileID = Zevera.getID(link); if (FileID == null) { throw new PluginException( LinkStatus.ERROR_FILE_NOT_FOUND, "Error adding file, FileID null"); } while (true) { showMessage(downloadLink, "Phase 2/3: Check download:"); br.getPage( "http://www.zevera.com/jDownloader.ashx?cmd=fileinfo&login="******"&pass="******"&FileID=" + FileID); String infos[] = br.getRegex("(.*?)(,|$)").getColumn(0); if (infos[0].contains("FileID:0")) { throw new PluginException( LinkStatus.ERROR_FILE_NOT_FOUND, "Error adding file, FileID doesnt exist"); } if (infos[6].contains("Status:Downloaded")) { String DownloadURL = br.getRegex("DownloadURL:(Http.*?),").getMatch(0); if (DownloadURL == null) { throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE); } showMessage(downloadLink, "Phase 3/3: OK Download starting"); dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, DownloadURL, true, 0); break; } else { this.sleep(15 * 1000l, downloadLink, "Waiting for download to finish on Zevera"); } } } if (dl.getConnection().isContentDisposition()) { long filesize = dl.getConnection().getLongContentLength(); if (filesize == 0) { throw new PluginException( LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "ServerError", 10 * 60 * 1000l); } dl.startDownload(); } else { br.followConnection(); throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE); } }
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); } } } } }