Example #1
0
  @Override
  public void handleFree(final DownloadLink downloadLink) throws Exception, PluginException {
    requestFileInformation(downloadLink);
    String dllink = this.checkDirectLink(downloadLink, "cache");
    if (dllink == null) {
      final Form f = br.getForm(0);
      InputField i = null;
      for (final InputField inputfield : f.getInputFields()) {
        if ("trackvalue".equals(inputfield.getKey())
            && inputfield.getValue().equals(downloadLink.getStringProperty("iFilename", null))) {
          i = inputfield;
          break;
        }
      }
      // lets remove all other files execpt the one we want, they are all prechecked.
      while (f.getInputField("trackvalue") != null) {
        f.remove("trackvalue");
      }
      // add the one we want
      f.addInputField(i);
      if (f != null && f.hasInputFieldByName("securityCode")) {
        // has captcha
        final String captcha =
            new Regex(br.getURL(), "https?://(?:www\\.)?oshoworld\\.com/[^/]+/").getMatch(-1)
                + "CAPTCHA/CAPTCHA_image.asp";
        final String code = this.getCaptchaCode(captcha, downloadLink);
        f.put("securityCode", Encoding.urlEncode(code));
      }
      br.setFollowRedirects(false);
      br.submitForm(f);
      // redirect show show correct.
      // they come in the form of
      // http://www.oshoarchive.com/ow-english/download.php?id=T1NITy1UaGVfQXJ0X29mX0R5aW5nXzEwLm1wMw
      // the id = base64 iFilename, if we knew the /ow-english/ (for english section) was static we
      // could theoretically bypass
      // captcha..

      dllink = br.getRedirectLocation();
      if (dllink == null) {
        throw new PluginException(LinkStatus.ERROR_CAPTCHA);
      }
    }
    dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, false, 1);
    if (dl.getConnection().getContentType().contains("html")) {
      if (dl.getConnection().getResponseCode() == 404) {
        throw new PluginException(
            LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error 404", 30 * 60 * 1000l);
      }
      br.followConnection();
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    downloadLink.setProperty("cache", dllink);
    dl.startDownload();
  }
Example #2
0
 /**
  * Returns the first form that has a 'key' that equals 'value'.
  *
  * @param key
  * @param value
  * @return
  */
 private Form getFormByKey(final String key, final String value) {
   Form[] workaround = br.getForms();
   if (workaround != null) {
     for (Form f : workaround) {
       for (InputField field : f.getInputFields()) {
         if (key != null && key.equals(field.getKey())) {
           if (value == null && field.getValue() == null) return f;
           if (value != null && value.equals(field.getValue())) return f;
         }
       }
     }
   }
   return null;
 }