mirror of
https://github.com/Tusko/vimeo-private-downloader.git
synced 2025-08-21 13:54:24 -07:00
Feature identify, after a restart, if last downloaded file is complete, if it's not the download is restarted
This commit is contained in:
parent
7c821b8495
commit
c5b0599301
1 changed files with 10 additions and 3 deletions
|
@ -64,9 +64,15 @@ function loadVideo(num, cb) {
|
||||||
|
|
||||||
function processFile(type, baseUrl, initData, segments, filename, cb) {
|
function processFile(type, baseUrl, initData, segments, filename, cb) {
|
||||||
const filePath = `./parts/${filename}`;
|
const filePath = `./parts/${filename}`;
|
||||||
if (fs.existsSync(filePath)) {
|
const downloadingFlag = `./parts/.${filename}~`
|
||||||
|
|
||||||
|
if(fs.existsSync(downloadingFlag)) {
|
||||||
|
log("⚠️", ` ${filename} - ${type} is incomplete, restarting the download`);
|
||||||
|
} else if (fs.existsSync(filePath)) {
|
||||||
log("⚠️", ` ${filename} - ${type} already exists`);
|
log("⚠️", ` ${filename} - ${type} already exists`);
|
||||||
return cb();
|
return cb();
|
||||||
|
} else {
|
||||||
|
fs.writeFileSync(downloadingFlag, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
const segmentsUrl = segments.map(seg => baseUrl + seg.url);
|
const segmentsUrl = segments.map(seg => baseUrl + seg.url);
|
||||||
|
@ -78,7 +84,7 @@ function processFile(type, baseUrl, initData, segments, filename, cb) {
|
||||||
flags: "a"
|
flags: "a"
|
||||||
});
|
});
|
||||||
|
|
||||||
combineSegments(type, 0, segmentsUrl, output, filePath, err => {
|
combineSegments(type, 0, segmentsUrl, output, filePath, downloadingFlag, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log("⚠️", ` ${err}`);
|
log("⚠️", ` ${err}`);
|
||||||
}
|
}
|
||||||
|
@ -88,8 +94,9 @@ function processFile(type, baseUrl, initData, segments, filename, cb) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function combineSegments(type, i, segmentsUrl, output, filename, cb) {
|
function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag, cb) {
|
||||||
if (i >= segmentsUrl.length) {
|
if (i >= segmentsUrl.length) {
|
||||||
|
fs.unlinkSync(downloadingFlag);
|
||||||
log("🏁", ` ${filename} - ${type} done`);
|
log("🏁", ` ${filename} - ${type} done`);
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue