public void prepBrowser() { // define custom browser headers and language settings. if (agent == null) { /* we first have to load the plugin, before we can reference it */ JDUtilities.getPluginForHost("mediafire.com"); agent = jd.plugins.hoster.MediafireCom.stringUserAgent(); } br.getHeaders().put("User-Agent", agent); br.getHeaders().put("Accept-Language", "en-gb, en;q=0.9, de;q=0.8"); br.setCookie(COOKIE_HOST, "lang", "english"); }
private void prepBrowser(final Browser br) { /* define custom browser headers and language settings */ br.getHeaders().put("Accept-Language", "en-gb, en;q=0.9"); br.setCookie(COOKIE_HOST, "lang", "english"); if (ENABLE_RANDOM_UA) { if (agent.get() == null) { /* we first have to load the plugin, before we can reference it */ JDUtilities.getPluginForHost("mediafire.com"); agent.set(jd.plugins.hoster.MediafireCom.stringUserAgent()); } br.getHeaders().put("User-Agent", agent.get()); } }
public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress) throws Exception { ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>(); String parameter = param.toString(); br.setFollowRedirects(true); br.getPage(parameter); if (br.getURL().equals("http://imagearn.com/")) { logger.info("Link offline: " + parameter); return decryptedLinks; } String fpName = br.getRegex("<h3 class=\"page-title\"><strong>([^<>\"/]+)</strong>").getMatch(0); if (parameter.matches("http://(www\\.)?imagearn\\.com//?gallery\\.php\\?id=\\d+")) { if (br.containsHTML(">There are no images in this gallery")) { logger.info("Link empty: " + parameter); return decryptedLinks; } if (fpName == null) fpName = br.getRegex("<title>(.*?) \\- Image Earn</title>").getMatch(0); if (fpName == null) { logger.warning("Decrypter broken for link: " + parameter); return null; } fpName = Encoding.htmlDecode(fpName.trim()); final String[] links = br.getRegex("\"(http://imagearn\\.com/?/image\\.php\\?id=\\d+)\"").getColumn(0); if (links == null || links.length == 0) { logger.warning("Decrypter broken for link: " + parameter); return null; } DecimalFormat df = new DecimalFormat("0000"); int counter = 1; String currentUA = null; for (final String singleLink : links) { for (int i = 1; i <= 3; i++) { if (currentUA != null) br.getHeaders().put("User-Agent", currentUA); br.getPage(singleLink); if (br.containsHTML("Do not use autorefresh programs")) { this.sleep(new Random().nextInt(4) * 1000l, param); continue; } else if (br.containsHTML("Congratulations you received a ban")) { logger.info("Trying to avoid ban"); br.clearCookies("http://imagearn.com/"); JDUtilities.getPluginForHost("mediafire.com"); currentUA = jd.plugins.hoster.MediafireCom.stringUserAgent(); this.sleep(new Random().nextInt(4) * 1000l, param); continue; } break; } if (br.containsHTML("Do not use autorefresh programs")) { logger.warning("Stopped at: " + singleLink); logger.warning("Decrypter broken for link: " + parameter); logger.info("JD = blocked"); return null; } final String finallink = getDirectlink(); if (finallink == null) { logger.warning("Stopped at: " + singleLink); logger.warning("Decrypter broken for link: " + parameter); return null; } final DownloadLink dl = createDownloadlink("directhttp://" + finallink); dl.setAvailable(true); dl.setFinalFileName(fpName + "_" + df.format(counter) + ".jpg"); decryptedLinks.add(dl); counter++; sleep(1500, param); } } else { if (fpName == null) fpName = br.getRegex("<title>Image - (.*?) \\- Image Earn</title>").getMatch(0); String finallink = getDirectlink(); if (finallink == null) { logger.warning("Decrypter broken for link: " + parameter); return null; } final DownloadLink dl = createDownloadlink("directhttp://" + finallink); dl.setAvailable(true); decryptedLinks.add(dl); } if (fpName != null) { FilePackage fp = FilePackage.getInstance(); fp.setName(Encoding.htmlDecode(fpName.trim())); fp.addLinks(decryptedLinks); } return decryptedLinks; }
@HostPlugin( revision = "$Revision: 29614 $", interfaceVersion = 2, names = {"remixshare.com"}, urls = {"http://[\\w\\.]*?remixshare\\.com/(.*?\\?file=|download/|dl/)[a-z0-9]+"}, flags = {0}) public class RemixShareCom extends PluginForHost { public static final String BLOCKED = "(class=\"blocked\"|>Von Deiner IP Adresse kamen zu viele Anfragen innerhalb kurzer Zeit\\.)"; public RemixShareCom(PluginWrapper wrapper) { super(wrapper); this.setStartIntervall(3000l); } @Override public void correctDownloadLink(final DownloadLink link) throws PluginException { // clean links so prevent dupes and has less side effects with multihosters... final String fuid = getFileID(link); final String pnd = new Regex(link.getDownloadURL(), "https?://[\\w\\.]*?remixshare\\.com/").getMatch(-1); if (fuid == null || pnd == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } link.setUrlDownload(pnd + "download/" + fuid); final String linkID = getHost() + "://" + fuid; try { link.setLinkID(linkID); } catch (Throwable e) { link.setProperty("LINKDUPEID", linkID); } // invalid linkformat for open in browser you need to nullify it. if (link.getContentUrl() != null && link.getContentUrl().matches("http://[\\w\\.]*?remixshare\\.com/dl/[a-z0-9]+")) { link.setContentUrl(link.getDownloadURL()); } } private String getFileID(DownloadLink link) { return new Regex(link.getDownloadURL(), "(\\?file=|download/|dl/)([a-z0-9]+)").getMatch(1); } private static final AtomicReference<String> userAgent = new AtomicReference<String>(jd.plugins.hoster.MediafireCom.stringUserAgent()); public AvailableStatus requestFileInformation(final DownloadLink downloadLink) throws IOException, InterruptedException, PluginException { correctDownloadLink(downloadLink); this.setBrowserExclusive(); br.getHeaders().put("User-Agent", userAgent.get()); br.setCookie("http://remixshare.com", "lang_en", "english"); br.setFollowRedirects(true); br.getPage(downloadLink.getDownloadURL()); if (br.containsHTML(BLOCKED)) { return AvailableStatus.UNCHECKABLE; } br.setFollowRedirects(false); // 300 = The uploader has deleted the file // 400 = File deleted, maybe abused // 500 = Wrong link or maybe deleted some time ago if (br.containsHTML("<b>Error Code: [345]00\\.") || br.containsHTML("Please check the downloadlink")) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } String filename = Encoding.htmlDecode( br.getRegex( Pattern.compile( "<span title=\\'([0-9]{10}_)?(.*?)\\'>", Pattern.CASE_INSENSITIVE)) .getMatch(1)); if (filename == null) { filename = Encoding.htmlDecode( br.getRegex( Pattern.compile( "<title>(.*?)Download at remiXshare Filehosting", Pattern.CASE_INSENSITIVE)) .getMatch(0)); } String filesize = br.getRegex("(>|\\.\\.\\.)\\ \\((.*?)\\)<").getMatch(1); if (filename == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } downloadLink.setName(filename.trim()); if (filesize != null) { filesize = Encoding.htmlDecode(filesize); downloadLink.setDownloadSize(SizeFormatter.getSize(filesize.replace(",", "."))); } String md5Hash = br.getRegex("/>MD5:(.*?)<").getMatch(0); if (md5Hash != null && md5Hash.trim().length() == 32) { downloadLink.setMD5Hash(md5Hash.trim()); } else { /* fix broken md5 sums */ downloadLink.setMD5Hash(null); } return AvailableStatus.TRUE; } private String execJS() throws Exception { // we have established he is a dick String fun = null; final String elementid = br.getRegex( "= '<a id=\"(\\w+)\" href=\"#\".*?title=\"START\" onclick=\"return OnSubmitForm\\(\\);") .getMatch(0); if (elementid != null) { final String[] s1 = br.getRegex("<script[^>]+>").getColumn(-1); final ArrayList<String> s0 = new ArrayList<String>(); if (s1 != null) { for (String s : s1) { if (s != null /* && new Regex(s, "type=('|\")text/javascript\\1").matches() */) { final String s2 = new Regex(s, "src=(\"|')(.*?)\\1").getMatch(1); if (s2 != null) { s0.add(s2); } } } } final LinkedHashSet<String> dupe = new LinkedHashSet<String>(); for (final String s : s0) { if (!dupe.add(s) || ((s.startsWith("://") || s.startsWith("http")) && !Browser.getHost(s).contains(this.getHost()))) { continue; } Browser a = br.cloneBrowser(); a.getPage(s); fun = a.getRegex( "document\\.getElementById\\('" + elementid + "'\\)\\.href\\s*(=\\s*[^\r\n]+)") .getMatch(0); } } if (fun == null) { fun = br.getRegex( "document\\.getElementById\\('[\\w\\-]+'\\)\\.href\\s*(=\\s*\"((?:(?:https?:)?//(?:\\w+\\.)?remixshare\\.com)?/(?:[^/]+/){4})[^\r\n]+)") .getMatch(0); if (fun == null) { fun = br.getRegex( "var \\w+\\s*(=\\s*\"((?:(?:https?:)?//(?:\\w+\\.)?remixshare\\.com)?/(?:[^/]+/){4})[^\r\n]+)") .getMatch(0); } } if (fun == null) { fun = br.getRegex( "<a[^>]*href=\"((?:(?:https?:)?//(?:\\w+\\.)?remixshare\\.com)?/(?:[^/]+/){4,}\\d+)\"[^>]+><img[^>]+src=\"/images/dl_btn\\.png\"") .getMatch(0); if (fun == null) { fun = br.getRegex( "<a[^>]*href=\"((?:(?:https?:)?//(?:\\w+\\.)?remixshare\\.com)?/(?:[^/]+/){4,}\\d+)\"") .getMatch(0); } if (fun != null) { return fun; } throw new PluginException( LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Retry in 15 minutes", 15 * 60 * 1000l); } fun = "var url" + fun; // fun = "function url() { return url; }"; Object result = null; // prevent infinate loop int t = -1; while (t++ < 15 && true) { final ScriptEngineManager manager = jd.plugins.hoster.DummyScriptEnginePlugin.getScriptEngineManager(this); final ScriptEngine engine = manager.getEngineByName("javascript"); final Invocable inv = (Invocable) engine; try { engine.eval(fun); engine.eval("function result(){return url}"); result = inv.invokeFunction("result", fun); break; } catch (final Throwable e) { if (e.getMessage() != null) { // do not use language components of the error message. Only static identifies, otherwise // other languages will // fail! // -raztoki final String ee = new Regex(e.getMessage(), "\"([\\$\\w]+)\" .+").getMatch(0); // should only be needed on the first entry, then on after 'cache' should get result the // first time! if (ee != null) { // lets look for missing reference final String ref = new Regex(br, "var\\s+" + Pattern.quote(ee) + "\\s*=\\s*.*?;").getMatch(-1); if (ref != null) { fun = ref + "\r\n" + fun; continue; } else { logger.warning("Could not find missing var/function"); } } else { logger.warning("Could not find reference Error"); } // getLogger().log(e); // prevent infinate loop break; } } } if (result == null) { throw new PluginException( LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Retry in 15 minutes", 15 * 60 * 1000l); } return result.toString(); } public String getAGBLink() { return "http://remixshare.com/information/"; } public int getMaxSimultanFreeDownloadNum() { return -1; } public void handleFree(DownloadLink downloadLink) throws Exception { requestFileInformation(downloadLink); br.setFollowRedirects(false); if (br.containsHTML(BLOCKED)) { throw new PluginException(LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE, 10 * 1000l); } if (br.containsHTML("Download password")) { Form pw = br.getFormbyProperty("name", "pass"); String pass = downloadLink.getStringProperty("pass", null); if (pass == null) { pass = Plugin.getUserInput("Password?", downloadLink); } pw.put("passwd", pass); br.submitForm(pw); br.getPage(br.getRedirectLocation()); if (br.containsHTML("Incorrect password entered")) { downloadLink.setProperty("pass", null); throw new PluginException( LinkStatus.ERROR_FATAL, JDL.L("plugins.errors.wrongpassword", "Password wrong")); } else { downloadLink.setProperty("pass", pass); } } String lnk = execJS(); if (lnk == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } if (!lnk.matches("https?://.+") && !lnk.matches("^/.+$")) { lnk = new Regex(lnk, "<a href=\"(http://.*?)\"").getMatch(0); } br.getPage(lnk); String dllink = br.getRedirectLocation(); if (dllink == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } br.setFollowRedirects(true); dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, false, 1); if (dl.getConnection().getLongContentLength() == 0) { throw new PluginException( LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error", 2 * 60 * 60 * 1000l); } if (!(dl.getConnection().isContentDisposition())) { br.followConnection(); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } dl.startDownload(); } public void reset() {} public void resetDownloadlink(DownloadLink link) {} public void resetPluginGlobals() {} }