// @Override
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();

    br.getPage(parameter);

    Form form = br.getForm(1);
    for (int i = 0; i <= 5; i++) {
      String code = getCaptchaCode("http://alpha-link.eu/captcha/captcha.php", param);
      form.put("captcha", code);
      form.setAction(parameter);
      br.submitForm(form);
      if (!br.containsHTML("(Code ist falsch)|(kein Code eingegeben)")) break;
    }
    form = br.getForm(1);
    String[] ids = br.getRegex("class='btn' name='id' value='(\\d+)'").getColumn(0);
    if (ids.length == 0) return null;
    progress.setRange(ids.length);
    for (String id : ids) {
      form.put("id", id);
      br.submitForm(form);

      String codedLink = br.getRegex("src=.\"(.*?).\"").getMatch(0);
      if (codedLink == null) return null;
      String link = Encoding.htmlDecode(codedLink);

      decryptedLinks.add(createDownloadlink(link));
      progress.increase(1);
    }
    return decryptedLinks;
  }
  @Override
  public void handleFree(DownloadLink downloadLink) throws Exception {
    requestFileInformation(downloadLink);
    br.setFollowRedirects(false);

    if (br.containsHTML("You have reached")) {
      int minutes = 0, seconds = 0, hours = 0;
      String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0);
      if (tmphrs != null) hours = Integer.parseInt(tmphrs);
      String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0);
      if (tmpmin != null) minutes = Integer.parseInt(tmpmin);
      String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0);
      if (tmpsec != null) seconds = Integer.parseInt(tmpsec);
      int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000;
      throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime);
    } else {
      Form form = br.getFormbyProperty("name", "F1");
      if (form == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      /* "Captcha Method" */
      String[][] letters =
          br.getRegex(
                  "<span style='position:absolute;padding-left:(\\d+)px;padding-top:\\d+px;'>(\\d)</span>")
              .getMatches();
      if (letters.length == 0) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      SortedMap<Integer, String> capMap = new TreeMap<Integer, String>();
      for (String[] letter : letters) {
        capMap.put(Integer.parseInt(letter[0]), letter[1]);
      }
      StringBuilder code = new StringBuilder();
      for (String value : capMap.values()) {
        code.append(value);
      }

      form.put("code", code.toString());
      form.setAction(downloadLink.getDownloadURL());
      // Ticket Time
      int tt = Integer.parseInt(br.getRegex("countdown\">(\\d+)</span>").getMatch(0));
      sleep(tt * 1001, downloadLink);
      br.submitForm(form);
      URLConnectionAdapter con2 = br.getHttpConnection();
      String dllink = br.getRedirectLocation();
      if (con2.getContentType().contains("html")) {
        String error = br.getRegex("class=\"err\">(.*?)</font>").getMatch(0);
        if (error != null) {
          logger.warning(error);
          con2.disconnect();
          if (error.equalsIgnoreCase("Wrong captcha")
              || error.equalsIgnoreCase("Expired session")) {
            throw new PluginException(LinkStatus.ERROR_CAPTCHA);
          } else {
            throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, error, 10000);
          }
        }
        if (br.containsHTML("Download Link Generated"))
          dllink = br.getRegex("padding:7px;\">\\s+<a\\s+href=\"(.*?)\">").getMatch(0);
      }
      if (dllink == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, true, 0);
      dl.startDownload();
    }
  }
Exemple #3
0
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();
    br.setFollowRedirects(false);
    br.getPage(parameter);
    if (br.containsHTML("(\"This link does not exist\\.\"|ERROR - this link does not exist)"))
      throw new DecrypterException(
          JDL.L(
              "plugins.decrypt.errormsg.unavailable",
              "Perhaps wrong URL or the download is not available anymore."));
    if (br.containsHTML(">Not yet checked</span>")) throw new DecrypterException("Not yet checked");
    if (br.containsHTML("To use reCAPTCHA you must get an API key from"))
      throw new DecrypterException("Server error, please contact the safelinking.net support!");
    if (!parameter.contains("/d/")) {
      Form capForm = new Form();
      capForm.put("post-protect", "1");
      capForm.setMethod(MethodType.POST);
      capForm.setAction(parameter);
      for (int i = 0; i <= 5; i++) {
        if (br.containsHTML(PASSWORDPROTECTEDTEXT)) {
          capForm.put("link-password", getUserInput(null, param));
        }
        if (br.containsHTML(RECAPTCHATEXT)) {
          PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
          jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
          rc.parse();
          rc.load();
          File cf = rc.downloadCaptcha(getLocalCaptchaFile());
          capForm.put("recaptcha_challenge_field", rc.getChallenge());
          capForm.put("recaptcha_response_field", getCaptchaCode(cf, param));
        } else if (br.getRegex(CAPTCHAREGEX1).getMatch(0) != null) {
          capForm.put(
              "securimage_response_field",
              getCaptchaCode(br.getRegex(CAPTCHAREGEX1).getMatch(0), param));
        } else if (br.getRegex(CAPTCHAREGEX2).getMatch(0) != null) {
          capForm.put(
              "3dcaptcha_response_field",
              getCaptchaCode(br.getRegex(CAPTCHAREGEX2).getMatch(0), param));
        } else if (br.containsHTML(CAPTCHATEXT3)) {
          Browser xmlbrowser = br.cloneBrowser();
          xmlbrowser.getPage("http://safelinking.net/includes/captcha_factory/fancycaptcha.php");
          capForm.put("fancy-captcha", xmlbrowser.toString().trim());
        }
        br.submitForm(capForm);
        if (br.containsHTML(RECAPTCHATEXT)
            || br.getRegex(CAPTCHAREGEX1).getMatch(0) != null
            || br.getRegex(CAPTCHAREGEX2).getMatch(0) != null
            || br.containsHTML(PASSWORDPROTECTEDTEXT)) continue;
        if (br.containsHTML(CAPTCHATEXT3)) {
          logger.warning("Captcha3 captchahandling failed for link: " + parameter);
          return null;
        }
        break;
      }
      if (br.containsHTML(RECAPTCHATEXT)
          || br.getRegex(CAPTCHAREGEX1).getMatch(0) != null
          || br.getRegex(CAPTCHAREGEX2).getMatch(0) != null)
        throw new DecrypterException(DecrypterException.CAPTCHA);
      if (br.containsHTML(PASSWORDPROTECTEDTEXT))
        throw new DecrypterException(DecrypterException.PASSWORD);
      if (br.containsHTML(">All links are dead\\.<"))
        throw new DecrypterException(
            JDL.L(
                "plugins.decrypt.errormsg.unavailable",
                "Perhaps wrong URL or the download is not available anymore."));
      // container handling (if no containers found, use webprotection
      if (br.containsHTML("\\.dlc")) {
        decryptedLinks = loadcontainer(".dlc", param);
        if (decryptedLinks != null && decryptedLinks.size() > 0) return decryptedLinks;
      }

      if (br.containsHTML("\\.rsdf")) {
        decryptedLinks = loadcontainer(".rsdf", param);
        if (decryptedLinks != null && decryptedLinks.size() > 0) return decryptedLinks;
      }

      if (br.containsHTML("\\.ccf")) {
        decryptedLinks = loadcontainer(".ccf", param);
        if (decryptedLinks != null && decryptedLinks.size() > 0) return decryptedLinks;
      }
      decryptedLinks = new ArrayList<DownloadLink>();
      // Webprotection decryption
      String[] links =
          br.getRegex("class=\"linked\">(http://safelinking\\.net/d/.*?)</a>").getColumn(0);
      if (links == null || links.length == 0) {
        String allLinks =
            br.getRegex("class=\"link-box\" id=\"direct-links\".*?>(.*?<a href=\".*?)</div>")
                .getMatch(0);
        if (allLinks != null) links = new Regex(allLinks, "<a href=\"(.*?)\"").getColumn(0);
        if (links == null || links.length == 0) {
          links = br.getRegex("\"(http://safelinking\\.net/d/[a-z0-9]+)\"").getColumn(0);
          if (links == null || links.length == 0) {
            links = br.getRegex("class=\"linked\">(http://.*?)</a>").getColumn(0);
          }
        }
      }
      if (links == null || links.length == 0) return null;
      progress.setRange(links.length);
      for (String link : links) {
        if (!link.contains("safelinking.net/")) {
          decryptedLinks.add(createDownloadlink(link));
        } else {
          br.getPage(link);
          String finallink = br.getRedirectLocation();
          if (finallink == null) {
            logger.warning("Decrypter broken, decryption stopped at link: " + link);
            return null;
          }
          if (!parameter.equals(finallink)) decryptedLinks.add(createDownloadlink(finallink));
        }
        progress.increase(1);
      }
    } else {
      if (br.getRedirectLocation() == null) {
        logger.warning("Error in single-link handling for link: " + parameter);
        return null;
      }
      decryptedLinks.add(createDownloadlink(br.getRedirectLocation()));
    }
    return decryptedLinks;
  }
  public HashMap<Integer, String[]> getLinks(
      final String video, final boolean prem, Browser br, int retrycount) throws Exception {
    if (retrycount > 2) {
      // do not retry more often than 2 time
      return null;
    }
    if (br == null) {
      br = this.br;
    }

    try {
      // gsProxy(true);
    } catch (Throwable e) {
      /* does not exist in 09581 */
    }
    br.setFollowRedirects(true);
    /* this cookie makes html5 available and skip controversy check */
    br.setCookie("youtube.com", "PREF", "f2=40100000&hl=en-GB");
    br.getHeaders().put("User-Agent", "Wget/1.12");
    br.getPage(video);
    if (br.containsHTML("id=\"unavailable-submessage\" class=\"watch-unavailable-submessage\"")) {
      return null;
    }
    final String VIDEOID = new Regex(video, "watch\\?v=([\\w_\\-]+)").getMatch(0);
    boolean fileNameFound = false;
    String YT_FILENAME = VIDEOID;
    if (br.containsHTML("&title=")) {
      YT_FILENAME =
          Encoding.htmlDecode(
              br.getRegex("&title=([^&$]+)").getMatch(0).replaceAll("\\+", " ").trim());
      fileNameFound = true;
    }
    final String url = br.getURL();
    boolean ythack = false;
    if (url != null && !url.equals(video)) {
      /* age verify with activated premium? */
      if (url.toLowerCase(Locale.ENGLISH).indexOf("youtube.com/verify_age?next_url=") != -1) {
        verifyAge = true;
      }
      if (url.toLowerCase(Locale.ENGLISH).indexOf("youtube.com/verify_age?next_url=") != -1
          && prem) {
        final String session_token = br.getRegex("onLoadFunc.*?gXSRF_token = '(.*?)'").getMatch(0);
        final LinkedHashMap<String, String> p = Request.parseQuery(url);
        final String next = p.get("next_url");
        final Form form = new Form();
        form.setAction(url);
        form.setMethod(MethodType.POST);
        form.put("next_url", "%2F" + next.substring(1));
        form.put("action_confirm", "Confirm+Birth+Date");
        form.put("session_token", Encoding.urlEncode(session_token));
        br.submitForm(form);
        if (br.getCookie("http://www.youtube.com", "is_adult") == null) {
          return null;
        }
      } else if (url.toLowerCase(Locale.ENGLISH).indexOf("youtube.com/index?ytsession=") != -1
          || url.toLowerCase(Locale.ENGLISH).indexOf("youtube.com/verify_age?next_url=") != -1
              && !prem) {
        ythack = true;
        br.getPage("http://www.youtube.com/get_video_info?video_id=" + VIDEOID);
        if (br.containsHTML("&title=") && fileNameFound == false) {
          YT_FILENAME =
              Encoding.htmlDecode(
                  br.getRegex("&title=([^&$]+)").getMatch(0).replaceAll("\\+", " ").trim());
          fileNameFound = true;
        }
      } else if (url.toLowerCase(Locale.ENGLISH).indexOf("google.com/accounts/servicelogin?")
          != -1) {
        // private videos
        return null;
      }
    }
    Form forms[] = br.getForms();
    if (forms != null) {
      for (Form form : forms) {
        if (form.getAction() != null && form.getAction().contains("verify_age")) {
          LOG.info("Verify Age");
          br.submitForm(form);
          break;
        }
      }
    }
    /* html5_fmt_map */
    if (br.getRegex(YT_FILENAME_PATTERN).count() != 0 && fileNameFound == false) {
      YT_FILENAME = Encoding.htmlDecode(br.getRegex(YT_FILENAME_PATTERN).getMatch(0).trim());
      fileNameFound = true;
    }
    HashMap<Integer, String[]> links = parseLinks(br, video, YT_FILENAME, ythack, false);
    return links;
  }