void checkRetry(DownloadMultipartError e) { for (Part ee : e.getInfo().getParts()) { if (!retry(ee.getException())) { throw e; } } }
public String getContentExt(DownloadInfo dinfo) { String ct = dinfo.getContentType(); if (ct == null) throw new DownloadRetry("null content type"); // for multi file download keep content type and extension. some video can have same extensions for booth // audio/video streams ct = ct.replaceFirst("/", "."); return "." + ct.replaceAll("x-", "").toLowerCase(); }
@Override public void run() { switch (info.getState()) { case EXTRACTING: case EXTRACTING_DONE: case DONE: LOG.info("" + info.getState()); break; case RETRYING: LOG.info(info.getState() + " " + info.getDelay()); break; case DOWNLOADING: info.getSource(), info.getCount() / (1024*1024.0), info.getLength() / (1024*1024.0), info.getCount() * 100.0 / info.getLength()) );
for (Part ee : e.getInfo().getParts()) { if (ee.getException() == null) continue; if (ee.getException().getCause() == null) return; if (ee.getException().getCause() instanceof FileNotFoundException) { f = (FileNotFoundException) ee.getException().getCause(); } else { FileNotFoundException ff = (FileNotFoundException) ee.getException().getCause(); if (!ff.getMessage().equals(f.getMessage())) { throw new DownloadError(f);
try { AtomicBoolean stop = new AtomicBoolean(false); DownloadInfo info = new DownloadInfo(url); DownloadMonitor monitor = new DownloadMonitor(info); info.extract(stop, monitor); LOG.info("Failed to download " + url + ". Reconnecting in " + (i * backoffTime / 1000) + " seconds (HTTP " + e.getCode() + "-Error " + url + ")"); Thread.sleep(backoffTime * i); } else { LOG.warn("Failed to download " + file + " (HTTP " + e.getCode() + "-Error " + url + ")");
throw new DownloadError(e); throw new DownloadInterruptedError("stop"); if (Thread.currentThread().isInterrupted()) throw new DownloadInterruptedError("interrupted"); Thread.sleep(1000); } catch (InterruptedException ee) { throw new DownloadInterruptedError(ee); infoNew.copy(infoOld); } else { if (infoOld.targetFile != null) {
/** * @param url * @throws MalformedURLException */ public VGetVideo(String url) throws MalformedURLException { VGet v = new VGet(new URL(url)); v.extract(); this.vid = new XuggleVideo(v.getVideo().getInfo().getSource()); }
public void info(VideoInfo info, AtomicBoolean stop, Runnable notify) { try { List<VideoFileInfo> dinfo = extract(info, stop, notify); info.setInfo(dinfo); for (DownloadInfo i : dinfo) { i.setReferer(info.getWeb()); i.extract(stop, notify); } } catch (DownloadInterruptedError e) { info.setState(States.STOP, e); notify.run(); throw e; } catch (RuntimeException e) { info.setState(States.ERROR, e); notify.run(); throw e; } }
public static void main(String[] args) { ArrayList<DownloadInfo> music = new ArrayList<DownloadInfo>(); music.add(new DownloadInfo("Wasted Years")); music.add(new DownloadInfo("The Trooper")); music.add(new DownloadInfo("Can I Play with Madness")); music.add(new DownloadInfo("22 Acacia Avenue")); music.add(new DownloadInfo("Rime of the Ancient Mariner")); for (int i=0; i<music.size(); i++) { int addNum = (int) (Math.random() * 20); music.get(i).addNumDL(addNum); } System.out.println("Num 13/14"); for (int i=0; i<music.size(); i++) { System.out.println(music.get(i)); //14 } }
/** * @param url * @param iu * @throws MalformedURLException */ public VGetVideo(String url, VideoInfoUser iu) throws MalformedURLException{ VGet v = new VGet(new URL(url)); AtomicBoolean stop = new AtomicBoolean(false); v.extract(iu,stop, new Runnable() { @Override public void run() {}}); this.vid = new XuggleVideo(v.getVideo().getInfo().getSource()); }
public String getExt(DownloadInfo dinfo) { String ct = dinfo.getContentType(); if (ct == null) throw new DownloadRetry("null content type"); // for single file download keep only extension ct = ct.replaceFirst("video/", ""); ct = ct.replaceFirst("audio/", ""); return "." + ct.replaceAll("x-", "").toLowerCase(); }
/** * @param url * @throws MalformedURLException */ public VGetVideo(String url) throws MalformedURLException { VGet v = new VGet(new URL(url)); v.extract(); this.vid = new XuggleVideo(v.getVideo().getInfo().getSource()); }
/** * @param url * @param iu * @throws MalformedURLException */ public VGetVideo(String url, VideoInfoUser iu) throws MalformedURLException{ VGet v = new VGet(new URL(url)); AtomicBoolean stop = new AtomicBoolean(false); v.extract(iu,stop, new Runnable() { @Override public void run() {}}); this.vid = new XuggleVideo(v.getVideo().getInfo().getSource()); }