kostyasm123

Untitled

Dec 26th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 24.23 KB | None | 0 0
  1. package jd.plugins.hoster;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.net.URL;
  6. import java.util.Locale;
  7. import java.util.concurrent.atomic.AtomicReference;
  8. import jd.PluginWrapper;
  9. import jd.config.Property;
  10. import jd.http.Browser;
  11. import jd.http.Cookies;
  12. import jd.http.RequestHeader;
  13. import jd.http.URLConnectionAdapter;
  14. import jd.nutils.encoding.Encoding;
  15. import jd.parser.Regex;
  16. import jd.plugins.Account;
  17. import jd.plugins.Account.AccountType;
  18. import jd.plugins.AccountInfo;
  19. import jd.plugins.BrowserAdapter;
  20. import jd.plugins.DownloadLink;
  21. import jd.plugins.DownloadLink.AvailableStatus;
  22. import jd.plugins.HostPlugin;
  23. import jd.plugins.Plugin;
  24. import jd.plugins.PluginException;
  25. import jd.plugins.PluginForHost;
  26. import jd.plugins.components.SiteType.SiteTemplate;
  27. import jd.plugins.download.DownloadInterface;
  28. import org.appwork.utils.formatter.SizeFormatter;
  29. import org.appwork.utils.formatter.TimeFormatter;
  30. import org.appwork.utils.logging2.LogInterface;
  31. import org.jdownloader.captcha.v2.challenge.recaptcha.v1.Recaptcha;
  32. import org.jdownloader.captcha.v2.challenge.recaptcha.v2.CaptchaHelperHostPluginRecaptchaV2;
  33. import org.jdownloader.captcha.v2.challenge.solvemedia.SolveMedia;
  34.  
  35. @HostPlugin(revision="$Revision: 35558 $", interfaceVersion=2, names={"rapidpaid.com"}, urls={"https?://(?:www\\.)?rapidpaid\\.com/[A-Za-z0-9]+"})
  36. public class RapidpaidCom
  37.   extends PluginForHost
  38. {
  39.   public RapidpaidCom(PluginWrapper wrapper)
  40.   {
  41.     super(wrapper);
  42.     enablePremium("http://rapidpaid.com/upgrade.html");
  43.   }
  44.  
  45.   public String getAGBLink()
  46.   {
  47.     return "http://rapidpaid.com/terms.html";
  48.   }
  49.  
  50.   private final String mainpage = "http://rapidpaid.com";
  51.   private final String domains = "(rapidpaid\\.com)";
  52.   private final String type = "html";
  53.   private static final int wait_BETWEEN_DOWNLOADS_LIMIT_MINUTES_DEFAULT = 10;
  54.   private static final int additional_WAIT_SECONDS = 3;
  55.   private static final int directlinkfound_WAIT_SECONDS = 10;
  56.   private static final boolean supportshttps = false;
  57.   private static final boolean supportshttps_FORCED = false;
  58.   private static final boolean available_CHECK_OVER_INFO_PAGE = true;
  59.   private static final boolean useOldLoginMethod = false;
  60.   private static final boolean enable_RANDOM_UA = false;
  61.   private static final String url_ERROR_SIMULTANDLSLIMIT = "e=You+have+reached+the+maximum+concurrent+downloads";
  62.   private static final String url_ERROR_SERVER = "e=Error%3A+Could+not+open+file+for+reading.";
  63.   private static final String url_ERROR_WAIT_BETWEEN_DOWNLOADS_LIMIT = "e=You+must+wait+";
  64.   private static final String url_ERROR_PREMIUMONLY = "(.+e=You\\+must\\+register\\+for\\+a\\+premium\\+account\\+to.+|.+/register\\..+)";
  65.   private static final String errortext_ERROR_WAIT_BETWEEN_DOWNLOADS_LIMIT = "You must wait between downloads!";
  66.   private static final String errortext_ERROR_SERVER = "Server error";
  67.   private static final String errortext_ERROR_PREMIUMONLY = "This file can only be downloaded by premium (or registered) users";
  68.   private static final String errortext_ERROR_SIMULTANDLSLIMIT = "Max. simultan downloads limit reached, wait to start more downloads from this host";
  69.   private static final boolean free_RESUME = true;
  70.   private static final int free_MAXCHUNKS = 1;
  71.   private static final int free_MAXDOWNLOADS = 1;
  72.   private static final boolean account_FREE_RESUME = true;
  73.   private static final int account_FREE_MAXCHUNKS = 1;
  74.   private static final int account_FREE_MAXDOWNLOADS = 1;
  75.   private static final boolean account_PREMIUM_RESUME = true;
  76.   private static final int account_PREMIUM_MAXCHUNKS = 1;
  77.   private static final int account_PREMIUM_MAXDOWNLOADS = 1;
  78.   private static AtomicReference<String> agent = new AtomicReference(null);
  79.  
  80.   public void correctDownloadLink(DownloadLink link)
  81.   {
  82.     link.setUrlDownload(link.getDownloadURL().replaceFirst("https://", "http://"));
  83.   }
  84.  
  85.   public DownloadLink.AvailableStatus requestFileInformation(DownloadLink link)
  86.     throws IOException, PluginException
  87.   {
  88.     setBrowserExclusive();
  89.     this.br.setFollowRedirects(true);
  90.     prepBrowser(this.br);
  91.     String fid = getFID(link);
  92.     link.setLinkID(fid);
  93.    
  94.     this.br.getPage(link.getDownloadURL() + "~i");
  95.     if ((!this.br.getURL().contains("~i")) || (this.br.getHttpConnection().getResponseCode() == 404)) {
  96.       throw new PluginException(32);
  97.     }
  98.     String[] tableData = this.br.getRegex("class=\"responsiveInfoTable\">([^<>\"/]*?)<").getColumn(0);
  99.    
  100.     String filename = this.br.getRegex("data\\-animation\\-delay=\"\\d+\">(?:Information about|Informacion) ([^<>\"]*?)</div>").getMatch(0);
  101.     if (filename == null) {
  102.       filename = this.br.getRegex("class=\"description\\-1\">Information about ([^<>\"]+)<").getMatch(0);
  103.     }
  104.     if (filename == null) {
  105.       filename = this.br.getRegex("(?:Filename|Dateiname|??? ?????|Nome):[\t\n\r ]*?</td>[\t\n\r ]*?<td(?: class=\"responsiveInfoTable\")?>([^<>\"]*?)<").getMatch(0);
  106.     }
  107.     String filesize = this.br.getRegex("(?:Filesize|Dateigr??e|??? ?????|Tamanho):[\t\n\r ]*?</td>[\t\n\r ]*?<td(?: class=\"responsiveInfoTable\")?>([^<>\"]*?)<").getMatch(0);
  108.     try
  109.     {
  110.       if (filename == null) {
  111.         filename = tableData[0];
  112.       }
  113.       if (filesize == null) {
  114.         filesize = tableData[1];
  115.       }
  116.     }
  117.     catch (Throwable e) {}
  118.     if ((filename == null) || (inValidate(Encoding.htmlDecode(filename).trim())) || (Encoding.htmlDecode(filename).trim().equals("��"))) {
  119.       filename = fid;
  120.     }
  121.     if ((filename == null) || (filesize == null)) {
  122.       throw new PluginException(4194304);
  123.     }
  124.     link.setName(Encoding.htmlDecode(filename).trim());
  125.     link.setDownloadSize(SizeFormatter.getSize(Encoding.htmlDecode(filesize.replace(",", "")).trim()));
  126.     return DownloadLink.AvailableStatus.TRUE;
  127.   }
  128.  
  129.   public void handleFree(DownloadLink downloadLink)
  130.     throws Exception, PluginException
  131.   {
  132.     requestFileInformation(downloadLink);
  133.     doFree(downloadLink, true, 1, "free_directlink");
  134.   }
  135.  
  136.   public void doFree(DownloadLink link, boolean resume, int maxchunks, String directlinkproperty)
  137.     throws Exception, PluginException
  138.   {
  139.     boolean skipWaittime = false;
  140.     String continue_link = null;
  141.     boolean captcha = false;
  142.     boolean success = false;
  143.     long timeBeforeDirectlinkCheck = System.currentTimeMillis();
  144.    
  145.     continue_link = checkDirectLink(link, directlinkproperty);
  146.     if (continue_link != null)
  147.     {
  148.       if (System.currentTimeMillis() - timeBeforeDirectlinkCheck > 1500L) {
  149.         sleep(10000L, link);
  150.       }
  151.       this.dl = BrowserAdapter.openDownload(this.br, link, continue_link, resume, maxchunks);
  152.     }
  153.     else
  154.     {
  155.       this.br.getPage(link.getDownloadURL());
  156.      
  157.       handleErrors();
  158.      
  159.       handlePassword(link);
  160.       for (int i = 1; i <= 5; i++)
  161.       {
  162.         this.logger.info("Handling pre-download page #" + i);
  163.         long timeBeforeCaptchaInput = System.currentTimeMillis();
  164.         continue_link = getContinueLink();
  165.         if ((i == 1) && (continue_link == null))
  166.         {
  167.           this.logger.info("No continue_link available, plugin broken");
  168.           throw new PluginException(4194304);
  169.         }
  170.         if (continue_link == null)
  171.         {
  172.           this.logger.info("No continue_link available, stepping out of pre-download loop");
  173.           break;
  174.         }
  175.         this.logger.info("Found continue_link, continuing...");
  176.        
  177.         String rcID = this.br.getRegex("recaptcha/api/noscript\\?k=([^<>\"]*?)\"").getMatch(0);
  178.         if (isDownloadlink(continue_link))
  179.         {
  180.           this.dl = BrowserAdapter.openDownload(this.br, link, continue_link, resume, maxchunks);
  181.         }
  182.         else if (this.br.containsHTML("data\\-sitekey="))
  183.         {
  184.           captcha = true;
  185.           String recaptchaV2Response = new CaptchaHelperHostPluginRecaptchaV2(this, this.br).getToken();
  186.           success = true;
  187.           waitTime(link, timeBeforeCaptchaInput, skipWaittime);
  188.           this.dl = BrowserAdapter.openDownload(this.br, link, continue_link, "submit=Submit&submitted=1&d=1&capcode=false&g-recaptcha-response=" + recaptchaV2Response, resume, maxchunks);
  189.         }
  190.         else if (rcID != null)
  191.         {
  192.           captcha = true;
  193.           success = false;
  194.           Recaptcha rc = new Recaptcha(this.br, this);
  195.           rc.setId(rcID);
  196.           rc.load();
  197.           File cf = rc.downloadCaptcha(getLocalCaptchaFile());
  198.           String c = getCaptchaCode("recaptcha", cf, link);
  199.           waitTime(link, timeBeforeCaptchaInput, skipWaittime);
  200.           this.dl = BrowserAdapter.openDownload(this.br, link, continue_link, "submit=continue&submitted=1&d=1&recaptcha_challenge_field=" + rc.getChallenge() + "&recaptcha_response_field=" + c, resume, maxchunks);
  201.         }
  202.         else if (this.br.containsHTML("solvemedia\\.com/papi/"))
  203.         {
  204.           captcha = true;
  205.           success = false;
  206.           this.logger.info("Detected captcha method \"solvemedia\" for this host");
  207.           SolveMedia sm = new SolveMedia(this.br);
  208.           if (this.br.containsHTML("api\\-secure\\.solvemedia\\.com/")) {
  209.             sm.setSecure(true);
  210.           }
  211.           File cf = null;
  212.           try
  213.           {
  214.             cf = sm.downloadCaptcha(getLocalCaptchaFile());
  215.           }
  216.           catch (Exception e)
  217.           {
  218.             if ("SolveMedia Module fails --> Probably a host side bug/wrong key".equals(e.getMessage())) {
  219.               throw new PluginException(131072, "Host side solvemedia.com captcha error - please contact the " + getHost() + " support");
  220.             }
  221.             throw e;
  222.           }
  223.           String code = getCaptchaCode("solvemedia", cf, link);
  224.           String chid = sm.getChallenge(code);
  225.           waitTime(link, timeBeforeCaptchaInput, skipWaittime);
  226.           this.dl = BrowserAdapter.openDownload(this.br, link, continue_link, "submit=continue&submitted=1&d=1&adcopy_challenge=" + Encoding.urlEncode(chid) + "&adcopy_response=" + Encoding.urlEncode(code), resume, maxchunks);
  227.         }
  228.         else
  229.         {
  230.           success = true;
  231.           waitTime(link, timeBeforeCaptchaInput, skipWaittime);
  232.           this.dl = BrowserAdapter.openDownload(this.br, link, continue_link, resume, maxchunks);
  233.         }
  234.         checkResponseCodeErrors(this.dl.getConnection());
  235.         if (this.dl.getConnection().isContentDisposition())
  236.         {
  237.           success = true;
  238.           break;
  239.         }
  240.         this.br.followConnection();
  241.         handleErrors();
  242.         if ((captcha) && (this.br.containsHTML("(api\\.recaptcha\\.net|google\\.com/recaptcha/api/)"))) {
  243.           this.logger.info("Wrong captcha");
  244.         }
  245.       }
  246.     }
  247.     checkResponseCodeErrors(this.dl.getConnection());
  248.     if (!this.dl.getConnection().isContentDisposition())
  249.     {
  250.       this.br.followConnection();
  251.       if ((captcha) && (!success)) {
  252.         throw new PluginException(8);
  253.       }
  254.       handleErrors();
  255.       throw new PluginException(4194304);
  256.     }
  257.     continue_link = this.dl.getConnection().getURL().toString();
  258.     link.setProperty(directlinkproperty, continue_link);
  259.     this.dl.startDownload();
  260.   }
  261.  
  262.   private String getContinueLink()
  263.   {
  264.     String continue_link = this.br.getRegex("\\$\\(\\'\\.download\\-timer\\'\\)\\.html\\(\"<a href=\\'(https?://[^<>\"]*?)\\'").getMatch(0);
  265.     if (continue_link == null) {
  266.       continue_link = this.br.getRegex("class=\\'btn btn\\-free\\' href=\\'(https?://[^<>\"]*?)\\'>").getMatch(0);
  267.     }
  268.     if (continue_link == null) {
  269.       continue_link = this.br.getRegex("<div class=\"captchaPageTable\">[\t\n\r ]+<form method=\"POST\" action=\"(https?://[^<>\"]*?)\"").getMatch(0);
  270.     }
  271.     if (continue_link == null) {
  272.       continue_link = this.br.getRegex("(?:\"|\\')(https?://(www\\.)?(rapidpaid\\.com)/[^<>\"]*?pt=[^<>\"]*?)(?:\"|\\')").getMatch(0);
  273.     }
  274.     if (continue_link == null) {
  275.       continue_link = getDllink();
  276.     }
  277.     return continue_link;
  278.   }
  279.  
  280.   private String getDllink()
  281.   {
  282.     return this.br.getRegex("\"(https?://(www\\.)?(?:[A-Za-z0-9\\.]+\\.)?(rapidpaid\\.com)/[^<>\"\\?]*?\\?download_token=[A-Za-z0-9]+)\"").getMatch(0);
  283.   }
  284.  
  285.   private boolean isDownloadlink(String url)
  286.   {
  287.     boolean isdownloadlink = url.contains("download_token=");
  288.     return isdownloadlink;
  289.   }
  290.  
  291.   private void handlePassword(DownloadLink dl)
  292.     throws PluginException, IOException
  293.   {
  294.     if (this.br.getURL().contains("/file_password.html"))
  295.     {
  296.       this.logger.info("Current link is password protected");
  297.       String passCode = dl.getStringProperty("pass", null);
  298.       if (passCode == null)
  299.       {
  300.         passCode = Plugin.getUserInput("Password?", dl);
  301.         if ((passCode == null) || (passCode.equals("")))
  302.         {
  303.           this.logger.info("User has entered blank password, exiting handlePassword");
  304.           dl.setProperty("pass", Property.NULL);
  305.           throw new PluginException(4, "Wrong password entered");
  306.         }
  307.         dl.setProperty("pass", passCode);
  308.       }
  309.       this.br.postPage(this.br.getURL(), "submit=access+file&submitme=1&file=" + getFID(dl) + "&filePassword=" + Encoding.urlEncode(passCode));
  310.       if (this.br.getURL().contains("/file_password.html"))
  311.       {
  312.         this.logger.info("User entered incorrect password --> Retrying");
  313.         dl.setProperty("pass", Property.NULL);
  314.         throw new PluginException(4, "Wrong password entered");
  315.       }
  316.       this.logger.info("User entered correct password --> Continuing");
  317.     }
  318.   }
  319.  
  320.   private void waitTime(DownloadLink downloadLink, long timeBefore, boolean skipWaittime)
  321.     throws PluginException
  322.   {
  323.     if (skipWaittime)
  324.     {
  325.       this.logger.info("Skipping waittime");
  326.     }
  327.     else
  328.     {
  329.       int wait = 0;
  330.       int passedTime = (int)((System.currentTimeMillis() - timeBefore) / 1000L) - 1;
  331.      
  332.       String ttt = this.br.getRegex("\\$\\(\\'\\.download\\-timer\\-seconds\\'\\)\\.html\\((\\d+)\\);").getMatch(0);
  333.       if (ttt == null) {
  334.         ttt = this.br.getRegex("var\\s*?seconds\\s*?= (\\d+);").getMatch(0);
  335.       }
  336.       if (ttt != null)
  337.       {
  338.         this.logger.info("Found waittime, parsing waittime: " + ttt);
  339.         wait = Integer.parseInt(ttt) + 3;
  340.         wait -= passedTime;
  341.         if (wait > 0)
  342.         {
  343.           this.logger.info("Waittime minus captcha input time: " + wait);
  344.           sleep(wait * 1000L, downloadLink);
  345.         }
  346.         else
  347.         {
  348.           this.logger.info("Waittime is zero or lower, not waiting");
  349.         }
  350.       }
  351.       else
  352.       {
  353.         this.logger.info("Failed to find waittime, either there is none or plugin is out of date");
  354.       }
  355.     }
  356.   }
  357.  
  358.   private void handleErrors()
  359.     throws PluginException
  360.   {
  361.     if (this.br.containsHTML("Error: Too many concurrent download requests")) {
  362.       throw new PluginException(4096, "Wait before starting new downloads", 180000L);
  363.     }
  364.     if (this.br.getURL().contains("e=You+have+reached+the+maximum+concurrent+downloads")) {
  365.       throw new PluginException(4096, "Max. simultan downloads limit reached, wait to start more downloads from this host", 60000L);
  366.     }
  367.     if (this.br.getURL().contains("error.php?e=Error%3A+Could+not+open+file+for+reading")) {
  368.       throw new PluginException(4096, "Server error", 3600000L);
  369.     }
  370.     if (this.br.getURL().contains("e=You+must+wait+"))
  371.     {
  372.       String wait_minutes = new Regex(this.br.getURL(), "wait\\+(\\d+)\\+minutes?").getMatch(0);
  373.       if (wait_minutes != null) {
  374.         throw new PluginException(16, "You must wait between downloads!", Integer.parseInt(wait_minutes) * 60 * 1001L);
  375.       }
  376.       throw new PluginException(16, "You must wait between downloads!", 600600L);
  377.     }
  378.     if (this.br.getURL().matches("(.+e=You\\+must\\+register\\+for\\+a\\+premium\\+account\\+to.+|.+/register\\..+)")) {
  379.       throw new PluginException(256, PluginException.VALUE_ID_PREMIUM_ONLY);
  380.     }
  381.     if (this.br.getURL().contains("You+have+reached+the+maximum+permitted+downloads+in")) {
  382.       throw new PluginException(16, "Daily limit reached", 10810800L);
  383.     }
  384.     if (this.br.toString().equals("unknown user")) {
  385.       throw new PluginException(2048, "Server error 'Unknown user'", 1800000L);
  386.     }
  387.     checkResponseCodeErrors(this.br.getHttpConnection());
  388.   }
  389.  
  390.   private void checkResponseCodeErrors(URLConnectionAdapter con)
  391.     throws PluginException
  392.   {
  393.     if (con == null) {
  394.       return;
  395.     }
  396.     long responsecode = con.getResponseCode();
  397.     if (responsecode == 403L) {
  398.       throw new PluginException(2048, "Server error 403", 300000L);
  399.     }
  400.     if (responsecode == 404L) {
  401.       throw new PluginException(2048, "Server error 404", 300000L);
  402.     }
  403.     if (responsecode == 416L) {
  404.       throw new PluginException(2048, "Server error 416", 120000L);
  405.     }
  406.     if (responsecode == 429L) {
  407.       throw new PluginException(4096, "Server error 429 connection limit reached, please contact our support!", 300000L);
  408.     }
  409.   }
  410.  
  411.   private String checkDirectLink(DownloadLink downloadLink, String property)
  412.   {
  413.     dllink = downloadLink.getStringProperty(property);
  414.     if (dllink != null)
  415.     {
  416.       Browser br2 = this.br.cloneBrowser();
  417.       br2.setFollowRedirects(true);
  418.       URLConnectionAdapter con = null;
  419.       try
  420.       {
  421.         con = br2.openHeadConnection(dllink);
  422.         if ((con.getContentType().contains("html")) || (con.getLongContentLength() == -1L)) {
  423.           downloadLink.setProperty(property, Property.NULL);
  424.         }
  425.         return null;
  426.       }
  427.       catch (Exception e)
  428.       {
  429.         downloadLink.setProperty(property, Property.NULL);
  430.         dllink = null;
  431.       }
  432.       finally
  433.       {
  434.         try
  435.         {
  436.           con.disconnect();
  437.         }
  438.         catch (Throwable e) {}
  439.       }
  440.     }
  441.   }
  442.  
  443.   private String getFID(DownloadLink dl)
  444.   {
  445.     return new Regex(dl.getDownloadURL(), "([A-Za-z0-9]+)$").getMatch(0);
  446.   }
  447.  
  448.   private boolean inValidate(String s)
  449.   {
  450.     if ((s == null) || ((s != null) && ((s.matches("[\r\n\t ]+")) || (s.equals(""))))) {
  451.       return true;
  452.     }
  453.     return false;
  454.   }
  455.  
  456.   private String getProtocol()
  457.   {
  458.     if ((this.br.getURL() != null) && (this.br.getURL().contains("https://"))) {
  459.       return "https://";
  460.     }
  461.     return "http://";
  462.   }
  463.  
  464.   public int getMaxSimultanFreeDownloadNum()
  465.   {
  466.     return 1;
  467.   }
  468.  
  469.   private Browser prepBrowser(Browser br)
  470.   {
  471.     br.setAllowedResponseCodes(new int[] { 416, 429 });
  472.    
  473.     return br;
  474.   }
  475.  
  476.   private static final Object LOCK = new Object();
  477.  
  478.   private void login(Account account, boolean force)
  479.     throws Exception
  480.   {
  481.     synchronized (LOCK)
  482.     {
  483.       try
  484.       {
  485.         this.br.setCookiesExclusive(true);
  486.         prepBrowser(this.br);
  487.         this.br.setFollowRedirects(true);
  488.         Cookies cookies = account.loadCookies("");
  489.         if ((cookies != null) && (!force))
  490.         {
  491.           this.br.setCookies(getHost(), cookies);
  492.           return;
  493.         }
  494.         this.br.getPage(getProtocol() + getHost() + "/");
  495.         String lang = System.getProperty("user.language");
  496.         String loginstart = new Regex(this.br.getURL(), "(https?://(www\\.)?)").getMatch(0);
  497.        
  498.         this.br.getPage(getProtocol() + getHost() + "/login." + "html");
  499.         String loginpostpage = loginstart + getHost() + "/ajax/_account_login.ajax.php";
  500.         this.br.getHeaders().put("X-Requested-With", "XMLHttpRequest");
  501.         this.br.getHeaders().put("Accept", "application/json, text/javascript, */*; q=0.01");
  502.         this.br.postPage(loginpostpage, "username=" + Encoding.urlEncode(account.getUser()) + "&password=" + Encoding.urlEncode(account.getPass()));
  503.         if (!this.br.containsHTML("\"login_status\":\"success\""))
  504.         {
  505.           if ("de".equalsIgnoreCase(lang)) {
  506.             throw new PluginException(256, "\r\nUng?ltiger Benutzername oder ung?ltiges 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);
  507.           }
  508.           throw new PluginException(256, "\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);
  509.         }
  510.         this.br.getPage(loginstart + getHost() + "/account_home." + "html");
  511.         account.saveCookies(this.br.getCookies(getHost()), "");
  512.       }
  513.       catch (PluginException e)
  514.       {
  515.         account.clearCookies("");
  516.         throw e;
  517.       }
  518.     }
  519.   }
  520.  
  521.   public AccountInfo fetchAccountInfo(Account account)
  522.     throws Exception
  523.   {
  524.     AccountInfo ai = new AccountInfo();
  525.     try
  526.     {
  527.       login(account, true);
  528.     }
  529.     catch (PluginException e)
  530.     {
  531.       account.setValid(false);
  532.       throw e;
  533.     }
  534.     if (!this.br.containsHTML("class=\"badge badge\\-success\">(?:PAID USER|USUARIO DE PAGO)</span>"))
  535.     {
  536.       account.setType(Account.AccountType.FREE);
  537.       account.setMaxSimultanDownloads(1);
  538.      
  539.       account.setConcurrentUsePossible(false);
  540.       ai.setStatus("Registered (free) account");
  541.     }
  542.     else
  543.     {
  544.       this.br.getPage("http://" + getHost() + "/upgrade." + "html");
  545.      
  546.       String expire = this.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);
  547.       if (expire == null) {
  548.         expire = this.br.getRegex(">[\t\n\r ]*?(\\d{2}/\\d{2}/\\d{4} \\d{2}:\\d{2}:\\d{2})[\t\n\r ]*?<").getMatch(0);
  549.       }
  550.       if (expire == null)
  551.       {
  552.         account.setValid(false);
  553.         return ai;
  554.       }
  555.       long expire_milliseconds = 0L;
  556.       expire_milliseconds = TimeFormatter.getMilliSeconds(expire, "MM/dd/yyyy hh:mm:ss", Locale.ENGLISH);
  557.       if (expire_milliseconds - System.currentTimeMillis() <= 0L)
  558.       {
  559.         account.setType(Account.AccountType.FREE);
  560.         account.setMaxSimultanDownloads(1);
  561.        
  562.         account.setConcurrentUsePossible(false);
  563.         ai.setStatus("Registered (free) user");
  564.       }
  565.       else
  566.       {
  567.         ai.setValidUntil(expire_milliseconds);
  568.         account.setType(Account.AccountType.PREMIUM);
  569.         account.setMaxSimultanDownloads(1);
  570.         ai.setStatus("Premium account");
  571.       }
  572.     }
  573.     account.setValid(true);
  574.     ai.setUnlimitedTraffic();
  575.     return ai;
  576.   }
  577.  
  578.   public void handlePremium(DownloadLink link, Account account)
  579.     throws Exception
  580.   {
  581.     requestFileInformation(link);
  582.     login(account, false);
  583.     if (account.getType() == Account.AccountType.FREE)
  584.     {
  585.       doFree(link, true, 1, "free_acc_directlink");
  586.     }
  587.     else
  588.     {
  589.       String dllink = link.getDownloadURL();
  590.       this.dl = BrowserAdapter.openDownload(this.br, link, dllink, true, 1);
  591.       checkResponseCodeErrors(this.dl.getConnection());
  592.       if (!this.dl.getConnection().isContentDisposition())
  593.       {
  594.         this.logger.warning("The final dllink seems not to be a file, checking for errors...");
  595.         this.br.followConnection();
  596.         handleErrors();
  597.         this.logger.info("Found no errors, let's see if we can find the dllink now...");
  598.         handlePassword(link);
  599.         dllink = getDllink();
  600.         if (dllink == null)
  601.         {
  602.           handleErrors();
  603.           throw new PluginException(4194304);
  604.         }
  605.         this.dl = BrowserAdapter.openDownload(this.br, link, dllink, true, 1);
  606.         checkResponseCodeErrors(this.dl.getConnection());
  607.       }
  608.       if (!this.dl.getConnection().isContentDisposition())
  609.       {
  610.         this.logger.warning("The final dllink seems not to be a file!");
  611.         this.br.followConnection();
  612.         handleErrors();
  613.         throw new PluginException(4194304);
  614.       }
  615.       this.dl.startDownload();
  616.     }
  617.   }
  618.  
  619.   public int getMaxSimultanPremiumDownloadNum()
  620.   {
  621.     return 1;
  622.   }
  623.  
  624.   public void reset() {}
  625.  
  626.   public void resetDownloadlink(DownloadLink link) {}
  627.  
  628.   public SiteType.SiteTemplate siteTemplateType()
  629.   {
  630.     return SiteType.SiteTemplate.MFScripts_YetiShare;
  631.   }
  632. }
Add Comment
Please, Sign In to add comment