/** * Bietet der hoster eine Möglichkeit mehrere links gleichzeitig zu prüfen, kann das über diese * Funktion gemacht werden. */ @Override public boolean checkLinks(final DownloadLink[] urls) { if (urls == null || urls.length == 0) { return false; } try { if (Rapidshare.RS_API_WAIT > System.currentTimeMillis()) { for (final DownloadLink u : urls) { u.setAvailable(true); u.getLinkStatus() .setStatusText( JDL.L("plugin.host.rapidshare.status.apiflood", "unchecked (API Flood)")); } return true; } logger.finest("OnlineCheck: " + urls.length + " links"); final StringBuilder idlist = new StringBuilder(); final StringBuilder namelist = new StringBuilder(); final ArrayList<DownloadLink> links = new ArrayList<DownloadLink>(); int size = 0; for (final DownloadLink u : urls) { if (size > 3000) { logger.finest("OnlineCheck: SplitCheck " + links.size() + "/" + urls.length + " links"); /* do not stop here because we are not finished yet */ this.checkLinksIntern2(links); links.clear(); idlist.delete(0, idlist.capacity()); namelist.delete(0, namelist.capacity()); } /* workaround reset */ u.setProperty("htmlworkaround", null); idlist.append(",").append(Rapidshare.getID(u.getDownloadURL())); namelist.append(",").append(this.getName(u)); links.add(u); size = ("https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles&files=" + idlist.toString().substring(1) + "&filenames=" + namelist.toString().substring(1) + "&incmd5=1") .length(); } if (links.size() != 0) { if (links.size() != urls.length) { logger.finest("OnlineCheck: SplitCheck " + links.size() + "/" + urls.length + " links"); } else { logger.finest("OnlineCheck: Check " + urls.length + " links"); } if (!this.checkLinksIntern2(links)) { return false; } } } catch (final Exception e) { e.printStackTrace(); return false; } return true; }
/** * Korrigiert die URL und befreit von subdomains etc. * * @param link * @return */ private String getCorrectedURL(String link) { if (link == null) { return null; } if (link.contains("://ssl.") || !link.startsWith("http://rapidshare.com")) { link = "http://rapidshare.com" + link.substring(link.indexOf("rapidshare.com") + 14); } String filename = new Regex(link, "http://[\\w\\.]*?rapidshare\\.com/files/\\d+/?(.*?)($|\\?)").getMatch(0); if (filename == null) { filename = new Regex(link, "\\#\\!download\\|(\\d+.*?)\\|(\\d+)\\|(.+?)($|\\|)").getMatch(2); } return "http://rapidshare.com/files/" + Rapidshare.getID(link) + "/" + filename; }
public boolean checkLinksIntern(final DownloadLink[] urls) { if (urls == null) { return false; } final ArrayList<DownloadLink> checkurls = new ArrayList<DownloadLink>(); final ArrayList<DownloadLink> finishedurls = new ArrayList<DownloadLink>(); for (final DownloadLink u : urls) { checkurls.add(u); } try { for (int retry = 0; retry < 3; retry++) { final StringBuilder idlist = new StringBuilder(); final StringBuilder namelist = new StringBuilder(); checkurls.removeAll(finishedurls); for (final DownloadLink u : checkurls) { idlist.append(",").append(Rapidshare.getID(u.getDownloadURL())); namelist.append(",").append(this.getName(u)); } final String req = "https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles&files=" + idlist.toString().substring(1) + "&filenames=" + namelist.toString().substring(1) + "&incmd5=1"; this.queryAPI(null, req, null); if (this.br.containsHTML("access flood")) { logger.warning("RS API flooded! Will not check again the next 5 minutes!"); Rapidshare.RS_API_WAIT = System.currentTimeMillis() + 5 * 60 * 1000l; return false; } final String[][] matches = this.br .getRegex("([^\n^\r^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^\n^\r]*)") .getMatches(); int i = 0; boolean doretry = false; for (final DownloadLink u : checkurls) { finishedurls.add(u); if (i > matches.length - 1) { doretry = true; break; } u.setDownloadSize(Long.parseLong(matches[i][2])); u.setFinalFileName(matches[i][1]); if (matches[i][6].trim().length() == 32) { u.setMD5Hash(matches[i][6]); } else { u.setMD5Hash(null); } // 0=File not found 1=File OK 2=File OK (direct download) // 3=Server down 4=File abused 5 switch (Integer.parseInt(matches[i][4])) { case 0: if (new Regex(u.getDownloadURL(), ".*?(html?)$").matches() && tryWorkaround(u)) { /* retry this link with workaround */ finishedurls.remove(u); doretry = true; } u.getLinkStatus() .setErrorMessage( JDL.L("plugin.host.rapidshare.status.filenotfound", "File not found")); u.getLinkStatus() .setStatusText( JDL.L("plugin.host.rapidshare.status.filenotfound", "File not found")); u.setAvailable(false); break; case 1: // u.getLinkStatus().setStatusText("alles prima"); u.setAvailable(true); u.getLinkStatus().setStatusText(""); u.getLinkStatus().setErrorMessage(null); break; case 5: u.setAvailable(true); u.getLinkStatus() .setStatusText( JDL.L("plugin.host.rapidshare.status.directdownload", "Direct Download")); u.getLinkStatus().setErrorMessage(null); break; case 3: u.getLinkStatus() .setErrorMessage( JDL.L( "plugin.host.rapidshare.status.servernotavailable", "Server temp. not available. Try later!")); u.getLinkStatus() .setStatusText( JDL.L( "plugin.host.rapidshare.status.servernotavailable", "Server temp. not available. Try later!")); u.setAvailable(false); break; case 4: u.setAvailable(false); u.getLinkStatus() .setErrorMessage(JDL.L("plugin.host.rapidshare.status.abused", "File abused")); u.getLinkStatus() .setStatusText(JDL.L("plugin.host.rapidshare.status.abused", "File abused")); break; } i++; } if (!doretry) { return true; } } return false; } catch (final Exception e) { if (this.br.containsHTML("access flood")) { logger.warning("RS API flooded! Will not check again the next 5 minutes!"); Rapidshare.RS_API_WAIT = System.currentTimeMillis() + 5 * 60 * 1000l; } return false; } }