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