Search code examples
javajdownloader

JDownloader, check link, add link, read captcha


I don't now if it's place for this question...

I am developing some plugin for jDownloader, I have some problems. First question: How to check link ? I tried this way (but it doesn't work):

LinkChecker lc = new LinkChecker();
lc.check("http://rapidshare...");

I want to check if link is downloadable and after that add it to queue (how to do this ?)

Another question: How to handle captcha ? I want to get captcha code (if appears) and send to service DeathByCaptcha.com.

Thank you very much in advance,


Solution

  • Ok, thank you for suggestions. Here are solutions (maybe it'ill be useable for someone):

    // CAPTCHA
    // class: CaptchaDialogQueueEntry.java
    // method: viaGui()
    // This method handle all captcha requests and you can read it in this way:
    
    captchaController.getCaptchaFile().toURI().toURL().toString() // this is the path of captcha file on your computer, you can read this and do anything
    

    Checking a link

    You have to add link to LinkCollector and after that you can add files do download list. Here is the code:

        LinkCollector
                .getInstance()
                .addCrawlerJob(
                        new LinkCollectingJob(
                                "http://bitshare.com/files/vddhv6sd/2002-Habakuk---Muzyka--slowa--liczba--kolor.rar.html"));
    

    And after that you can add all added files to download list:

            for (int i = 0, c = LinkCollector.getInstance().getPackages()
                    .size(); i < c; i++) {
    
                if (LinkCollector.getInstance().getPackages().get(i)
                        .getChildren().get(0).getSize() > 0) {
                    DownloadController.getInstance().addAll(
                            LinkCollector.getInstance().convert(
                                    LinkCollector.getInstance().getPackages()
                                            .get(i).getChildren(), true));
                }
            }
    

    Everything works statically so you can create own plugin and implement it anywhere.