コード例 #1
0
  // returns true if downloaded something, false if didn't
  private boolean downloadLinks(String linksText, JDFeedMeFeed feed, JDFeedMePost post) {
    // make sure we have something to download
    if (linksText.trim().length() == 0) return false;

    boolean skip_grabber = feed.getSkiplinkgrabber();
    boolean autostart = gui.getConfig().getStartdownloads();

    // handle a direct download
    if (skip_grabber) {
      // get all the links from the text
      ArrayList<DownloadLink> links = new DistributeData(linksText).findLinks();

      // create a new package for the data
      FilePackage fp = FilePackage.getInstance();
      fp.setName(post.getTitle() + " [JDFeedMe]");
      fp.addLinks(links);

      // download the package
      LinkGrabberController.getInstance().addLinks(links, skip_grabber, autostart);

      // restart the downloads if needed
      if (autostart) DownloadWatchDog.getInstance().startDownloads();
    } else // throw into the link grabber using the old code
    {
      new DistributeData(linksText, skip_grabber).start();
    }

    return true;
  }
コード例 #2
0
  // returns true if downloaded something, false if didn't
  // old implementation - using DistributeDate, works ok, but no control over package name
  @SuppressWarnings("unused")
  private boolean downloadLinksOld(String linksText, boolean skipGrabber) {
    // make sure we have something to download
    if (linksText.trim().length() == 0) return false;

    // lots of cool code in jd/plugins/optional/remotecontrol/Serverhandler.java

    // LinkGrabberController.getInstance().addLinks(downloadLinks, skipGrabber, autostart);
    new DistributeData(linksText, skipGrabber).start();

    // see if we need to start downloads
    if (DownloadWatchDog.getInstance().getDownloadStatus() != DownloadWatchDog.STATE.RUNNING) {
      // check if we need to start downloads right now
      if (gui.getConfig().getStartdownloads()) {
        DownloadWatchDog.getInstance().startDownloads();
      }
    }

    return true;
  }