コード例 #1
0
ファイル: Rlnks.java プロジェクト: Irbidan/jdownloader
  private void handleCaptchaAndPassword(final String partLink, final CryptedLink param)
      throws Exception {
    br.getPage(partLink);
    ALLFORM = br.getFormbyProperty("name", "form");
    boolean b = ALLFORM == null ? true : false;
    // 20150120 - raztoki
    if (ALLFORM == null
        && br.containsHTML(">Please Wait\\.\\.\\.<")
        && br.containsHTML("class=\"timer\">\\d+</span>\\s*seconds</div>")) {
      // pile of redirects happen here
      final String link =
          br.getRegex(
                  "class=\"timer\">\\d+</span>\\s*seconds</div>\\s*<a href=\"\\s*(https?://(\\w+\\.)?relink\\.us/.*?)\\s*\"")
              .getMatch(0);
      if (link != null) {
        br.getPage(link.trim());
        ALLFORM = br.getFormbyProperty("name", "form");
        b = ALLFORM == null ? true : false;
      } else {
        // possible plugin defect
        logger.warning("Possible Plugin Defect!");
      }
    }

    if (b) {
      ALLFORM = br.getForm(0);
      ALLFORM =
          ALLFORM != null
                  && ALLFORM.getAction() != null
                  && ALLFORM
                      .getAction()
                      .matches("^https?://(\\w+\\.)?relink\\.us/container_password\\.php.*")
              ? ALLFORM
              : null;
    }
    if (ALLFORM != null) {
      for (int i = 0; i < 5; i++) {
        if (ALLFORM.containsHTML("password")) {
          final String passCode = Plugin.getUserInput(null, param);
          ALLFORM.put("password", passCode);
        }
        if (ALLFORM.containsHTML("captcha")) {
          ALLFORM.remove("button");
          final String captchaLink = ALLFORM.getRegex("src=\"(.*?)\"").getMatch(0);
          if (captchaLink == null) {
            break;
          }
          final File captchaFile = this.getLocalCaptchaFile();
          Browser.download(
              captchaFile,
              br.cloneBrowser().openGetConnection("http://www.relink.us/" + captchaLink));
          final Point p =
              UserIO.getInstance()
                  .requestClickPositionDialog(
                      captchaFile, "relink.us | " + String.valueOf(i + 1) + "/5", null);
          if (p == null) {
            throw new DecrypterException(DecrypterException.CAPTCHA);
          }
          ALLFORM.put("button.x", String.valueOf(p.x));
          ALLFORM.put("button.y", String.valueOf(p.y));
        }
        br.submitForm(ALLFORM);
        if (br.getURL().contains("error.php")) {
          br.getPage(partLink);
          continue;
        }
        ALLFORM = br.getFormbyProperty("name", "form");
        ALLFORM = ALLFORM == null && b ? br.getForm(0) : ALLFORM;
        if (ALLFORM != null
            && ALLFORM.getAction().startsWith("http://www.relink.us/container_password.php")) {
          continue;
        }
        ALLFORM = null;
        break;
      }
    }
  }
コード例 #2
0
  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;
  }