mirror of
https://github.com/Tusko/vimeo-private-downloader.git
synced 2025-08-19 21:04:03 -07:00
fix cb
This commit is contained in:
parent
3f3e69b102
commit
e6901e7294
2 changed files with 16 additions and 15 deletions
23
index.js
23
index.js
|
@ -12,7 +12,7 @@ function loadVideo(num, cb) {
|
||||||
|
|
||||||
getJson(masterUrl, num, (err, json) => {
|
getJson(masterUrl, num, (err, json) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const videoData = json.video
|
const videoData = json.video
|
||||||
|
@ -62,13 +62,14 @@ 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 file = filename.replace(/[^\w.]/gi, '-');
|
||||||
const downloadingFlag = `./parts/.${filename}~`;
|
const filePath = `./parts/${file}`;
|
||||||
|
const downloadingFlag = `./parts/.${file}~`;
|
||||||
|
|
||||||
if (fs.existsSync(downloadingFlag)) {
|
if (fs.existsSync(downloadingFlag)) {
|
||||||
log("⚠️", ` ${filename} - ${type} is incomplete, restarting the download`);
|
log("⚠️", ` ${file} - ${type} is incomplete, restarting the download`);
|
||||||
} else if (fs.existsSync(filePath)) {
|
} else if (fs.existsSync(filePath)) {
|
||||||
log("⚠️", ` ${filename} - ${type} already exists`);
|
log("⚠️", ` ${file} - ${type} already exists`);
|
||||||
cb();
|
cb();
|
||||||
} else {
|
} else {
|
||||||
fs.writeFileSync(downloadingFlag, '');
|
fs.writeFileSync(downloadingFlag, '');
|
||||||
|
@ -95,9 +96,11 @@ function processFile(type, baseUrl, initData, segments, filename, cb) {
|
||||||
|
|
||||||
function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag, cb) {
|
function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag, cb) {
|
||||||
if (i >= segmentsUrl.length) {
|
if (i >= segmentsUrl.length) {
|
||||||
fs.unlinkSync(downloadingFlag);
|
if (fs.existsSync(downloadingFlag)) {
|
||||||
|
fs.unlinkSync(downloadingFlag);
|
||||||
|
}
|
||||||
log("🏁", ` ${filename} - ${type} done`);
|
log("🏁", ` ${filename} - ${type} done`);
|
||||||
cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
log(
|
log(
|
||||||
|
@ -129,15 +132,15 @@ function getJson(url, n, cb) {
|
||||||
|
|
||||||
https
|
https
|
||||||
.get(url, res => {
|
.get(url, res => {
|
||||||
if (res.statusCode === 200) {
|
if (res.statusMessage.toLowerCase() !== 'gone') {
|
||||||
res.on("data", d => (data += d));
|
res.on("data", d => (data += d));
|
||||||
res.on("end", () => cb(null, JSON.parse(data)));
|
res.on("end", () => cb(null, JSON.parse(data)));
|
||||||
} else {
|
} else {
|
||||||
log("⏱️", ` The master.json file is expired or crushed. Please update or remove it from the sequence (broken on ` + n + ` position)`);
|
return cb(`The master.json file is expired or crushed. Please update or remove it from the sequence (broken on ` + n + ` position)`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on("error", e => {
|
.on("error", e => {
|
||||||
cb(e);
|
return cb(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const list = [
|
module.exports = [
|
||||||
{
|
{
|
||||||
name: "Beluga test",
|
name: "Beluga test",
|
||||||
url:
|
url:
|
||||||
"https://33vod-adaptive.akamaized.net/exp=1612606615~acl=%2F84112832%2F%2A~hmac=e59eb3562ab8f318d99ffa8b9047fc13471414ae6a2fbb91d31963e640f8a7ff/84112832/sep/video/219068532,219068533/master.json?base64_init=1"
|
"https://33vod-adaptive.akamaized.net/exp=1613990546~acl=%2F84112832%2F%2A~hmac=89fbc453a492d1b13bf076b234673b590a103c049fea16801ad9fa537fb5d9b9/84112832/sep/video/219068532,219068533/master.json?base64_init=1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "1. Introduction",
|
name: "1. Introduction",
|
||||||
|
@ -273,6 +273,4 @@ const list = [
|
||||||
name: "",
|
name: "",
|
||||||
url: ""
|
url: ""
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = list;
|
|
Loading…
Add table
Add a link
Reference in a new issue