Package com.github.axet.wget.info

Examples of com.github.axet.wget.info.DownloadInfo


                // if we continue to download from old source, and this proxy
                // server is
                // down we have to try to extract new info and try to resume
                // download

                DownloadInfo infoOld = info.getInfo();
                info.extract(user, stop, notify);
                DownloadInfo infoNew = info.getInfo();

                if (infoOld != null && infoOld.resume(infoNew)) {
                    infoNew.copy(infoOld);
                } else {
                    if (targetFile != null) {
                        FileUtils.deleteQuietly(targetFile);
                        targetFile = null;
                    }
View Full Code Here


                extract(user, stop, notify);
            }

            while (!done(stop)) {
                try {
                    final DownloadInfo dinfo = info.getInfo();

                    if (dinfo.getContentType() == null || !dinfo.getContentType().contains("video/")) {
                        throw new DownloadRetry("unable to download video, bad content");
                    }

                    target(dinfo);

                    Direct direct;

                    if (dinfo.multipart()) {
                        // multi part? overwrite.
                        direct = new DirectMultipart(dinfo, targetFile);
                    } else if (dinfo.getRange()) {
                        // range download? try to resume download from last
                        // position
                        if (targetFile.exists() && targetFile.length() != dinfo.getCount())
                            targetFile = null;
                        direct = new DirectRange(dinfo, targetFile);
                    } else {
                        // single download? overwrite file
                        direct = new DirectSingle(dinfo, targetFile);
                    }

                    direct.download(stop, new Runnable() {
                        @Override
                        public void run() {
                            switch (dinfo.getState()) {
                            case DOWNLOADING:
                                info.setState(States.DOWNLOADING);
                                notify.run();
                                break;
                            case RETRYING:
                                info.setDelay(dinfo.getDelay(), dinfo.getException());
                                notify.run();
                                break;
                            default:
                                // we can safely skip all statues. (extracting -
                                // already
View Full Code Here

            AtomicBoolean stop = new AtomicBoolean(false);
            Runnable notify = new Runnable() {
                @Override
                public void run() {
                    VideoInfo i1 = info;
                    DownloadInfo i2 = i1.getInfo();

                    // notify app or save download state
                    // you can extract information from DownloadInfo info;
                    switch (i1.getState()) {
                    case EXTRACTING:
                    case EXTRACTING_DONE:
                    case DONE:
                        System.out.println(i1.getState() + " " + i1.getVideoQuality());
                        break;
                    case RETRYING:
                        System.out.println(i1.getState() + " " + i1.getDelay());
                        break;
                    case DOWNLOADING:
                        long now = System.currentTimeMillis();
                        if (now - 1000 > last) {
                            last = now;

                            String parts = "";

                            List<Part> pp = i2.getParts();
                            if (pp != null) {
                                // multipart download
                                for (Part p : pp) {
                                    if (p.getState().equals(States.DOWNLOADING)) {
                                        parts += String.format("Part#%d(%.2f) ", p.getNumber(), p.getCount()
                                                / (float) p.getLength());
                                    }
                                }
                            }

                            System.out.println(String.format("%s %.2f %s", i1.getState(),
                                    i2.getCount() / (float) i2.getLength(), parts));
                        }
                        break;
                    default:
                        break;
                    }
View Full Code Here

            if (user.getUserQuality() != null)
                found &= user.getUserQuality().equals(v.vq);

            if (found) {
                vvi.setVideoQuality(v.vq);
                DownloadInfo info = new DownloadInfo(v.url);
                vvi.setInfo(info);
                return;
            }
        }
View Full Code Here

TOP

Related Classes of com.github.axet.wget.info.DownloadInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.