Пример #1
0
 @Override
 public boolean checkLinks(final DownloadLink[] urls) {
   if (urls == null || urls.length == 0) {
     return false;
   }
   java.util.List<DownloadLink> failedLinkCheck = new ArrayList<DownloadLink>();
   Account acc = AccountController.getInstance().getValidAccount(this);
   setConstants(acc);
   for (DownloadLink url : urls) {
     try {
       requestFileInformation(url);
     } catch (Exception a) {
       failedLinkCheck.add(url);
     }
   }
   while (!failedLinkCheck.isEmpty()) {
     try {
       // not extensively tested.
       final Browser br = new Browser();
       br.setCookie(COOKIE_HOST, "lang", "english");
       br.setCookiesExclusive(true);
       final StringBuilder sb = new StringBuilder();
       final ArrayList<DownloadLink> links = new ArrayList<DownloadLink>();
       while (!failedLinkCheck.isEmpty()) {
         links.clear();
         for (DownloadLink link : failedLinkCheck) {
           links.add(link);
           if (links.size() == 50) break;
         }
         sb.delete(0, sb.capacity());
         sb.append("op=checkfiles&process=Check+URLs&list=");
         for (final DownloadLink dl : links) {
           sb.append(dl.getDownloadURL());
           sb.append("%0A");
         }
         br.postPage(COOKIE_HOST + "/?op=checkfiles", sb.toString());
         for (final DownloadLink dllink : links) {
           final String fid = new Regex(dllink.getDownloadURL(), "([a-z0-9]+)$").getMatch(0);
           if (br.containsHTML("filebox\\.com/" + fid + " found</font>")) {
             dllink.setAvailable(true);
             dllink.setName(fid);
           } else if (br.containsHTML("filebox\\.com/" + fid + " not found\\!</font>")) {
             dllink.setAvailable(false);
           } else {
             dllink.setAvailable(false);
             dllink.getLinkStatus().setStatusText("Linkchecker is probably broken!");
           }
           failedLinkCheck.remove(dllink);
         }
       }
     } catch (Exception b) {
     }
   }
   return true;
 }
Пример #2
0
  // this function takes a page containing links or a description and cleans it so only interesting
  // file links remain
  private String extractLinksFromHtml(String html, String limit_to_host, String[] exclude_hosters) {
    String result = "";

    // get all links in the html

    // there is a bug in HTMLParser.getHttpLinks() - it does not handle <br/> correctly, so we must
    // take action ourselves
    html = html.replace("http://", " http://");

    // use HTMLParser.getHttpLinks to get links, maybe make our own link extractor some day
    String[] links = HTMLParser.getHttpLinks(html, null);

    // go over all links
    for (String link : links) {
      // go over all host plugins
      try {
        // HostPluginWrapper.readLock.lock();
        for (final HostPluginWrapper pHost : HostPluginWrapper.getHostWrapper()) {
          // make sure this hoster is enabled
          if (!pHost.isEnabled()) continue;

          // check if we need to ignore certain hosters
          if (exclude_hosters != null) {
            boolean in_ignore_list = false;
            for (final String exclude_hoster : exclude_hosters) {
              if (pHost.getHost().equalsIgnoreCase(exclude_hoster)) in_ignore_list = true;
            }
            if (in_ignore_list) continue;
          }

          // check if we limit to certain hosters
          if ((limit_to_host != null) && (!limit_to_host.equals(JDFeedMeFeed.HOSTER_ANY_HOSTER))) {
            if (limit_to_host.equals(JDFeedMeFeed.HOSTER_ANY_PREMIUM)) {
              // make sure we have a premium account for this hoster

              if (!pHost.isPremiumEnabled()) continue;
              Account account = AccountController.getInstance().getValidAccount(pHost.getPlugin());
              if (account == null) continue;
            } else // regular hoster limit
            {
              if (!pHost.getHost().equalsIgnoreCase(limit_to_host)) continue;
            }
          }
          if (!pHost.canHandle(link)) continue;

          // if here than this link is ok
          result += link + "\r\n";
        }
      } finally {
        // HostPluginWrapper.readLock.unlock();
      }
    }

    return result;
  }
 private boolean getUserLogin() throws Exception {
   /*
    * we have to load the plugins first! we must not reference a plugin class without loading it before
    */
   final PluginForHost hosterPlugin = JDUtilities.getPluginForHost("mediafire.com");
   final Account aa = AccountController.getInstance().getValidAccount(hosterPlugin);
   if (aa != null) {
     // Try to re-use session token as long as possible (it's valid for 10 minutes)
     final String savedusername = this.getPluginConfig().getStringProperty("username");
     final String savedpassword = this.getPluginConfig().getStringProperty("password");
     final String sessiontokenCreateDateObject =
         this.getPluginConfig().getStringProperty("sessiontokencreated2");
     long sessiontokenCreateDate = -1;
     if (sessiontokenCreateDateObject != null && sessiontokenCreateDateObject.length() > 0) {
       sessiontokenCreateDate = Long.parseLong(sessiontokenCreateDateObject);
     }
     if ((savedusername != null && savedusername.matches(aa.getUser()))
         && (savedpassword != null && savedpassword.matches(aa.getPass()))
         && System.currentTimeMillis() - sessiontokenCreateDate < 600000) {
       SESSIONTOKEN = this.getPluginConfig().getStringProperty("sessiontoken");
     } else {
       // Get token for user account
       apiRequest(
           br,
           "https://www.mediafire.com/api/user/get_session_token.php",
           "?email="
               + Encoding.urlEncode(aa.getUser())
               + "&password="******"&application_id="
               + MdfrFldr.APPLICATIONID
               + "&signature="
               + JDHash.getSHA1(
                   aa.getUser()
                       + aa.getPass()
                       + MdfrFldr.APPLICATIONID
                       + Encoding.Base64Decode(MdfrFldr.APIKEY))
               + "&version=1");
       SESSIONTOKEN = getXML("session_token", br.toString());
       this.getPluginConfig().setProperty("username", aa.getUser());
       this.getPluginConfig().setProperty("password", aa.getPass());
       this.getPluginConfig().setProperty("sessiontoken", SESSIONTOKEN);
       this.getPluginConfig().setProperty("sessiontokencreated2", "" + System.currentTimeMillis());
       this.getPluginConfig().save();
     }
   }
   return false;
 }
Пример #4
0
  @Override
  public AvailableStatus requestFileInformation(DownloadLink downloadLink) throws Exception {
    this.setBrowserExclusive();
    br.setDebug(true);
    // We need to log in to get the file status^M
    Account aa = AccountController.getInstance().getValidAccount(this);
    if (aa == null) {
      throw new PluginException(
          LinkStatus.ERROR_FATAL, "Links are only checkable if a registered account is entered!");
    }
    String link = downloadLink.getDownloadURL();
    String user = Encoding.urlEncode(aa.getUser());
    String pw = Encoding.urlEncode(aa.getPass());

    if (link.contains("getFiles.aspx")) {
      String ourl = new Regex(link, ".*ourl=(.+)").getMatch(0);
      if (ourl == null) {
        throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE);
      }
      String res =
          br.getPage(
              "http://www.zevera.com/jDownloader.ashx?cmd=checklink&login="******"&pass="******"&olink="
                  + ourl);
      String filename = new Regex(link, ".*/(.+)").getMatch(0);
      downloadLink.setName(filename.trim());
      if (res.contains("Alive")) {
        return AvailableStatus.TRUE;
      } else {
        throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
      }
    }

    String FileID = Zevera.getID(link);
    String res =
        br.getPage(
            "http://www.zevera.com/jDownloader.ashx?cmd=fileinfo&login="******"&pass="******"&FileID="
                + FileID);

    if (res.contains("Conversion")) {
      throw new PluginException(
          LinkStatus.ERROR_FILE_NOT_FOUND, "Error adding file, bad FileID format");
    }
    String infos[] = br.getRegex("(.*?)(,|$)").getColumn(0);
    if (infos[0].contains("FileID:0")) {
      throw new PluginException(
          LinkStatus.ERROR_FILE_NOT_FOUND, "Error adding file, FileID doesnt exist");
    }

    String filename = new Regex(infos[1], "FileName:(.+)").getMatch(0);
    String filesize = new Regex(infos[4], "FileSizeInBytes:(.+)").getMatch(0);

    if (filename == null || filesize == null) {
      throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE);
    }
    downloadLink.setName(filename.trim());
    downloadLink.setDownloadSize(SizeFormatter.getSize(filesize));

    return AvailableStatus.TRUE;
  }
Пример #5
0
 public static boolean addAccount(final Account ac) throws DialogNoAnswerException {
   try {
     checkAccount(ac);
   } catch (DialogNoAnswerException e) {
     throw e;
   } catch (Throwable e) {
     Dialog.getInstance()
         .showExceptionDialog(
             _GUI.T.accountdialog_check_failed(), _GUI.T.accountdialog_check_failed_msg(), e);
   }
   AccountError error = ac.getError();
   String errorMessage = ac.getErrorString();
   if (StringUtils.isEmpty(errorMessage)) {
     AccountInfo ai = ac.getAccountInfo();
     if (ai != null) {
       errorMessage = ai.getStatus();
     }
   }
   if (error != null) {
     switch (error) {
       case PLUGIN_ERROR:
         if (StringUtils.isEmpty(errorMessage)) {
           errorMessage = _JDT.T.AccountController_updateAccountInfo_status_plugin_defect();
         }
         Dialog.getInstance().showMessageDialog(_GUI.T.accountdialog_check_invalid(errorMessage));
         return false;
       case EXPIRED:
         Dialog.getInstance()
             .showConfirmDialog(
                 0,
                 _GUI.T.accountdialog_check_expired_title(),
                 _GUI.T.accountdialog_check_expired(ac.getUser()),
                 null,
                 _GUI.T.accountdialog_check_expired_renew(),
                 null);
         AccountController.getInstance().addAccount(ac, false);
         return true;
       case TEMP_DISABLED:
         if (StringUtils.isEmpty(errorMessage)) {
           errorMessage = _GUI.T.accountdialog_check_failed();
         }
         Dialog.getInstance().showMessageDialog(_GUI.T.accountdialog_check_result(errorMessage));
         AccountController.getInstance().addAccount(ac, false);
         return true;
       default:
       case INVALID:
         if (StringUtils.isEmpty(errorMessage)) {
           errorMessage = _GUI.T.accountdialog_check_failed_msg();
         }
         Dialog.getInstance().showMessageDialog(_GUI.T.accountdialog_check_invalid(errorMessage));
         return false;
     }
   } else {
     String message = null;
     AccountInfo ai = ac.getAccountInfo();
     if (ai != null) {
       message = ai.getStatus();
     }
     if (StringUtils.isEmpty(message)) {
       message = _GUI.T.lit_yes();
     }
     Dialog.getInstance().showMessageDialog(_GUI.T.accountdialog_check_valid(message));
     AccountController.getInstance().addAccount(ac, false);
     return true;
   }
 }
Пример #6
0
 @SuppressWarnings("deprecation")
 public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
     throws Exception {
   br = new Browser();
   decryptedLinks = new ArrayList<DownloadLink>();
   this.param = param;
   if (param.toString().matches(TYPE_INVALID)) {
     decryptedLinks.add(createOfflinelink(parameter));
     return decryptedLinks;
   }
   parameter = param.toString().replace("www.", "");
   passCode = new Regex(parameter, "\\?password=(.+)").getMatch(0);
   if (passCode != null) {
     /* Remove this from our url as it is only needed for this decrypter internally. */
     parameter = parameter.replace("?password="******"");
   }
   useOriginalFilename =
       PluginJsonConfig.get(TumblrComConfig.class).isUseOriginalFilenameEnabled();
   final Account aa =
       AccountController.getInstance()
           .getValidAccount(JDUtilities.getPluginForHost(this.getHost()));
   if (aa != null) {
     /* Login whenever possible to be able to download account-only-stuff */
     try {
       jd.plugins.hoster.TumblrCom.login(this.br, aa, false);
     } catch (final Throwable e) {
     }
   }
   try {
     if (parameter.matches(TYPE_FILE)) {
       decryptFile();
     } else if (parameter.matches(TYPE_POST)) {
       decryptPost();
     } else if (parameter.matches(TYPE_IMAGE)) {
       decryptedLinks.addAll(processImage(parameter, null, null));
     } else {
       /*
        * 2016-08-26: Seems like when logged in, users now get the same view they have when not logged in. Using the "old"
        * logged-in method, the crawler will not find all entries which is why we now use the normal method (again).
        */
       // if (loggedin) {
       // decryptUserLoggedIn();
       // } else {
       // parameter = convertUserUrlToLoggedOutUser();
       // decryptUser();
       // }
       parameter = convertUserUrlToLoggedOutUser();
       decryptUser();
     }
   } catch (final BrowserException e) {
     logger.info("Server error, couldn't decrypt link: " + parameter);
     return decryptedLinks;
   } catch (final UnknownHostException eu) {
     logger.info("UnknownHostException, couldn't decrypt link: " + parameter);
     return decryptedLinks;
   } catch (final DecrypterException d) {
     if (StringUtils.equals(d.getMessage(), PLUGIN_DEFECT)) {
       logger.warning("Decrypter broken for link: " + parameter);
       return null;
     } else if (StringUtils.equals(d.getMessage(), OFFLINE)) {
       decryptedLinks.add(createOfflinelink(parameter));
       return decryptedLinks;
     }
     throw d;
   }
   return decryptedLinks;
 }