Example #1
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;
 }
Example #2
0
  public String getDllink() {
    String dllink = null;
    /* 2016-12-22: Switched back from rtmp to http (flv videofiles) */
    final boolean preferRtmp = false;
    if (!preferRtmp) {
      dllink = br.getRedirectLocation();
      if (dllink == null) {
        dllink =
            new Regex(
                    correctedBR,
                    "(\"|')(https?://(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|([\\w\\-\\.]+\\.)?"
                        + DOMAINS
                        + ")(:\\d{1,4})?/((files|d|cgi\\-bin/dl\\.cgi)/(\\d+/)?[a-z0-9]+/[^<>\"/]*?|[a-z0-9]{20,}/v\\.(?:flv|mp4)))\\1")
                .getMatch(1);
        if (dllink == null) {
          final String cryptedScripts[] =
              new Regex(correctedBR, "p\\}\\((.*?)\\.split\\('\\|'\\)").getColumn(0);
          if (cryptedScripts != null && cryptedScripts.length != 0) {
            for (String crypted : cryptedScripts) {
              dllink = decodeDownloadLink(crypted);
              if (dllink != null) {
                break;
              }
            }
          }
        }
      }
      /* try rtmp workaround, thx to raztoki */
      if (dllink == null) {
        final String i = new Regex(correctedBR, "image:\\s*\"(https?://[^/]+/)").getMatch(0);
        final String h = new Regex(correctedBR, "\\?h=([a-z0-9]{30,70})").getMatch(0);
        if (h != null && i != null) {
          dllink = i + h + "/video.mp4";
        }
      }
    } else {
      // rtmp is required
      String in =
          new Regex(correctedBR, "jwplayer\\(\"vplayer\"\\)\\.setup\\(\\{(.*?)\\}\\);").getMatch(0);
      if (in != null) {
        String out1 = PluginJSonUtils.getJsonValue(in, "file");
        String out0 = PluginJSonUtils.getJsonValue(in, "streamer");
        if (out1 != null && out1.startsWith("http")) {
          // http link
          return out1;
        }
        if (out0 == null || out1 == null) {
          return null;
        }
        dllink = "http://streamin.to/player/player.swf";
        dllink = out0 + "@" + out1 + "@" + dllink;
      }
    }

    return dllink;
  }
Example #3
0
  private void decryptPost() throws Exception {
    // lets identify the unique id for this post, only use it for tumblr hosted content
    final String puid = new Regex(parameter, "/post/(\\d+)").getMatch(0);

    // Single posts
    br.setFollowRedirects(false);
    br.getPage(parameter);
    if (br.getHttpConnection().getResponseCode() == 404) {
      logger.info("Link offline (error 404): " + parameter);
      return;
    }
    br.followRedirect(true);
    if (this.handlePassword()) {
      br.getPage(parameter);
      br.followRedirect(true);
    }
    String fpName = br.getRegex("<title>(.*?)</title>").getMatch(0);
    if (fpName == null) {
      // use google carousel json...
      fpName = PluginJSonUtils.getJsonValue(getGoogleCarousel(br), "articleBody");
      if (fpName == null) {
        // this can get false positives. eg. "the funniest posts on tumblr," thenwhatyouwanthere.
        fpName = br.getRegex("<meta name=\"description\" content=\"([^/\"]+)").getMatch(0);
        if (fpName == null) {
          fpName = "Tumblr post " + puid;
        }
      }
    }
    fpName = Encoding.htmlDecode(fpName.trim());
    fpName = fpName.replace("\n", "");
    // isolate post html
    final String postBody = findPostBody();
    decryptedLinks.addAll(processGeneric(br, postBody, fpName, puid));
  }
Example #4
0
 @SuppressWarnings("deprecation")
 @Override
 public AccountInfo fetchAccountInfo(final Account account) throws Exception {
   final AccountInfo ai = new AccountInfo();
   try {
     login(account, true);
   } catch (PluginException e) {
     account.setValid(false);
     throw e;
   }
   prepBRAjax(account);
   this.br.getPage("https://www." + this.getHost() + "/api/payments?limit=25&offset=0");
   ai.setUnlimitedTraffic();
   final String subscriptioncount = PluginJSonUtils.getJsonValue(this.br, "count");
   if (subscriptioncount == null || subscriptioncount.equals("0")) {
     account.setType(AccountType.FREE);
     /* free accounts can still have captcha */
     account.setMaxSimultanDownloads(ACCOUNT_PREMIUM_MAXDOWNLOADS);
     account.setConcurrentUsePossible(false);
     ai.setStatus("Registered (free) user");
   } else {
     /* TODO: Add expire date */
     // final String expire = null;
     // if (expire != null) {
     // ai.setValidUntil(TimeFormatter.getMilliSeconds(expire, "dd MMMM yyyy", Locale.ENGLISH));
     // }
     account.setType(AccountType.PREMIUM);
     account.setMaxSimultanDownloads(ACCOUNT_PREMIUM_MAXDOWNLOADS);
     account.setConcurrentUsePossible(true);
     ai.setStatus("Premium account");
   }
   account.setValid(true);
   return ai;
 }
Example #5
0
 public static int getAPIStatuscode(final Browser br) {
   int code = -1;
   final String code_str = PluginJSonUtils.getJsonValue(br, "code");
   if (code_str != null) {
     code = Integer.parseInt(code_str);
   }
   return code;
 }
Example #6
0
 private String getValue(String s) {
   if (FLASHVARS != null) {
     return new Regex(FLASHVARS, "&" + s + "=(.*?)(&|$)").getMatch(0);
   }
   if (FLASHVARS_JSON != null) {
     return PluginJSonUtils.getJsonValue(FLASHVARS_JSON, s);
   }
   return null;
 }
Example #7
0
 @SuppressWarnings("deprecation")
 @Override
 public AvailableStatus requestFileInformation(final DownloadLink link)
     throws IOException, PluginException {
   /* Offline links should also get nice filenames */
   if (!link.isNameSet()) {
     link.setName(new Regex(link.getDownloadURL(), "solidfiles\\.com/v/([a-z0-9]+)").getMatch(0));
   }
   this.setBrowserExclusive();
   br.setFollowRedirects(true);
   br.getPage(link.getDownloadURL());
   if (br.getURL().contains("/error/")
       || br.containsHTML(
           ">404<|>Not found<|>We couldn\\'t find the file you requested|Access to this file was disabled|The file you are trying to download has|>File not available")
       || this.br.getHttpConnection().getResponseCode() == 404) {
     throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   }
   String filename = PluginJSonUtils.getJsonValue(br, "name");
   if (filename == null) {
     filename = br.getRegex("<title>([^<>\"]*?) (?:-|\\|) Solidfiles</title>").getMatch(0);
   }
   if (filename == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   link.setName(Encoding.htmlDecode(filename.trim()));
   String filesize = PluginJSonUtils.getJsonValue(br, "size");
   if (filesize == null) {
     filesize = br.getRegex("class=\"filesize\">\\(([^<>\"]*?)\\)</span>").getMatch(0);
     if (filesize == null) {
       filesize = br.getRegex("dt>File size<.*?dd>(.*?)</").getMatch(0);
     }
   }
   if (filesize != null) {
     link.setDownloadSize(SizeFormatter.getSize(filesize));
   }
   return AvailableStatus.TRUE;
 }
Example #8
0
 private void loginAPI(final Account account) throws Exception {
   synchronized (lock) {
     try {
       br.setCookiesExclusive(true);
       /* session_id might be stored for API usage */
       final Cookies cookies = account.loadCookies("");
       restoreSession(account);
       if (cookies != null && this.apiSession != null) {
         br.setCookies(this.getHost(), cookies);
         getPageAPI(getAPIProtocol() + this.getHost() + "/login/json_checkLogin");
         if (this.getAPIStatuscode(this.br) == api_status_all_ok) {
           logger.info("Successfully re-used previous session");
           return;
         }
         logger.info("Failed to re-use previous session --> Performing full login");
       }
       postPageAPI(
           getAPIProtocol() + this.getHost() + "/login/json",
           "user="******"&pass="******"session");
       if (this.apiSession == null) {
         /* Actually this should not happen as errorhandling is done inside postPageAPI() */
         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.saveCookies(br.getCookies(this.getHost()), "");
       saveSession(account);
     } catch (final PluginException e) {
       account.clearCookies("");
       throw e;
     }
   }
 }
Example #9
0
 private void handleErrorsAPI() throws PluginException {
   final int code = getAPIStatuscode(this.br);
   String msg = PluginJSonUtils.getJsonValue(this.br, "msg");
   if (msg == null) {
     msg = "Unknown API error";
   }
   switch (code) {
     case api_status_all_ok:
       /* Everything ok */
       break;
     case 0:
       /* Fatal API error - this should never happen! */
       throw new PluginException(LinkStatus.ERROR_FATAL, msg);
     case 1:
       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);
       }
     case 2:
       /* Folderlink does not exist --> This errorcode should only happen inside jd.plugins.decrypter.CatShareNetFolder !! */
       if (StringUtils.containsIgnoreCase(br.getURL(), "/login/")) {
         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);
       }
       throw new PluginException(LinkStatus.ERROR_FATAL, msg);
     case 8:
       /* Daily downloadlimit reached (usually happens for premium accounts) */
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, msg, PluginException.VALUE_ID_PREMIUM_TEMP_DISABLE);
     case 9:
       /* Not enough traffic available */
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, msg, PluginException.VALUE_ID_PREMIUM_TEMP_DISABLE);
     case 10:
       /* WTF - "U didnt follow the rules!" */
       throw new PluginException(LinkStatus.ERROR_FATAL, "FATAL API error: " + msg);
     case 11:
       /* Wrong captcha input */
       throw new PluginException(LinkStatus.ERROR_CAPTCHA, msg);
     case 12:
       /* "You have to wait" --> (Free) limit reached */
       long wait = 3 * 60 * 60 * 1001l;
       final String wait_str = PluginJSonUtils.getJsonValue(this.br, "wait_time");
       /* wait_time can also be of type Boolean! */
       if (wait_str != null && wait_str.matches("\\d+")) {
         wait = 1001 * Long.parseLong(wait_str);
       }
       throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, msg, wait);
     case 13:
       /* File offline */
       throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND, msg);
     case 14:
       /*
        * Too many links (if someone tried to check more than X(see CheckLinks mass-linkchecker-function) links per request - this
        * should NEVER happen!
        */
       throw new PluginException(LinkStatus.ERROR_FATAL, msg);
     default:
       throw new PluginException(LinkStatus.ERROR_FATAL, msg);
   }
 }
Example #10
0
  /** Handles Free, Free-Account and Premium-Account download via API */
  public void handleDownloadAPI(
      final DownloadLink downloadLink,
      final boolean resumable,
      final int maxChunks,
      final boolean premium,
      final String directlinkproperty)
      throws Exception, PluginException {
    String passCode = downloadLink.getDownloadPassword();
    String dllink = checkDirectLink(downloadLink, directlinkproperty);
    if (dllink == null) {
      String download_post_data =
          "linkid=" + getLinkid(downloadLink) + "&challenge=" + System.currentTimeMillis();
      /*
       * Premium users could skip this step but I left it in so in case a Premium Account just switches to Free or the admin wants
       * premium users to enter captchas/wait too --> Everything is possible ;)
       */
      postPageAPI(getAPIProtocol() + this.getHost() + "/download/json_wait", "");
      /* E.g. response for premium users: {"wait_time":0,"key":null} */

      long wait = 0;
      String wait_str = PluginJSonUtils.getJsonValue(br, "wait_time");
      if (wait_str != null) {
        wait = Long.parseLong(wait_str) * 1000;

        if (wait > System.currentTimeMillis()) {
          /* Change from timestamp of current time + wait TO Remaining wait */
          wait -= System.currentTimeMillis();
        }
        if (wait > 240000l) {
          /* Reconnect wait */
          throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, wait);
        }
      }
      /* 2016-05-19: json_challenge-call is not needed anymore as json_wait will return waittime AND reCaptcha key */
      // postPageAPI("/download/json_challenge", "");
      final String rcID = PluginJSonUtils.getJsonValue(br, "key");
      if (rcID != null && rcID.length() > 6) {
        /* Usually free users do have to enter captchas */
        final Recaptcha rc = new Recaptcha(br, this);
        rc.setId(rcID);
        rc.load();
        final File cf = rc.downloadCaptcha(getLocalCaptchaFile());
        final String c = getCaptchaCode("recaptcha", cf, downloadLink);
        download_post_data +=
            "&recaptcha_challenge_field="
                + Encoding.urlEncode(rc.getChallenge())
                + "&recaptcha_response_field="
                + Encoding.urlEncode(c);
      }
      if (wait > 0) {
        /* Usually free users do have to wait before they can start the download */
        logger.info(
            "We have the captcha answer of the user, waiting "
                + wait
                + " milliseconds until json_download request");
        this.sleep(wait, downloadLink);
      }
      postPageAPI("/download/json_download", download_post_data);

      dllink = PluginJSonUtils.getJsonValue(br, "downloadUrl");
      if (dllink == null || !dllink.startsWith("http")) {
        throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Unknown API issue");
      }
    }
    logger.info("Final downloadlink = " + dllink + " starting the download...");
    dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, resumable, maxChunks);
    if (dl.getConnection().getContentType().contains("html")) {
      logger.warning("The final dllink seems not to be a file!");
      br.followConnection();
      handleErrorsAPI();
      checkServerErrors();
      throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Unknown server issue");
    }
    if (passCode != null) {
      downloadLink.setDownloadPassword(passCode);
    }
    downloadLink.setProperty(directlinkproperty, dllink);
    dl.startDownload();
  }
Example #11
0
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       br.setCookiesExclusive(true);
       String bearertoken = getBearertoken(account);
       final Cookies cookies = account.loadCookies("");
       if (cookies != null && !force) {
         this.br.setCookies(this.getHost(), cookies);
         return;
       }
       br.setFollowRedirects(true);
       br.getPage("https://www." + this.getHost() + "/login");
       String token = this.br.getRegex("name=token content=([^<>\"]+)>").getMatch(0);
       if (token == null) {
         token = this.br.getCookie(this.br.getHost(), "csrftoken");
       }
       if (token == null) {
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin defekt, bitte den JDownloader Support kontaktieren!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else if ("pl".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nBłąd wtyczki, skontaktuj się z Supportem JDownloadera!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nPlugin broken, please contact the JDownloader Support!",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       br.postPage(
           "/login",
           "csrfmiddlewaretoken="
               + Encoding.urlEncode(token)
               + "&username="******"&password="******"access_token");
       if (br.getCookie(this.br.getHost(), "sessionid") == null || bearertoken == null) {
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           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);
         }
       }
       account.setProperty("bearertoken", bearertoken);
       account.saveCookies(this.br.getCookies(this.getHost()), "");
     } catch (final PluginException e) {
       account.clearCookies("");
       throw e;
     }
   }
 }