Ejemplo n.º 1
0
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
   String parameter = param.toString();
   br.getPage(parameter);
   if (br.containsHTML("red>Bad Referrer!")) {
     String ref =
         br.getRegex("You could get this File only from t.*?<br><a.*?><b>(.*?)</b>").getMatch(0);
     if (ref == null) return null;
     br.getPage(ref);
     br.getPage(parameter);
   }
   boolean do_continue = false;
   for (int retrycounter = 1; retrycounter <= 5; retrycounter++) {
     if (br.containsHTML("<h1>PASSWORD PROTECTED LINK</h1>")
         || br.containsHTML("Incorrect Password")) {
       String passCode = getUserInput(null, param);
       Form pwForm = br.getForm(0);
       pwForm.put("u_password", passCode);
       br.submitForm(pwForm);
       System.out.print(br.toString());
     } else {
       do_continue = true;
       break;
     }
   }
   String link = null;
   if (do_continue == true) {
     link = br.getRegex("onClick=\"window.location='(.*?)'\" style=").getMatch(0);
     if (link == null) {
       link = br.getRegex("<form action=\"(.*?)\"").getMatch(0);
       if (link == null) link = br.getRegex("window\\.location = \"(.*?)\"").getMatch(0);
     }
     if (link == null)
       link = br.getRegex("METHOD=\"LINK\" ACTION=\"(http[^<>\"]*?)\"").getMatch(0);
     if (link == null || link.length() < 10) {
       Form form = br.getForm(0);
       if (form != null) {
         form.setMethod(MethodType.GET);
         br.setFollowRedirects(false);
         br.submitForm(form);
       }
       link = br.getRegex("frame name=\"protected\" src=\"(.*?)\"").getMatch(0);
     }
   }
   if (link != null && link.length() > 10) {
     decryptedLinks.add(createDownloadlink(link));
   } else {
     return null;
   }
   return decryptedLinks;
 }
Ejemplo n.º 2
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;
  }