mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-20 14:23:19 +03:00
Added ability to pause and resume all downloads
Removed backend dependency on queue library
This commit is contained in:
@@ -1719,9 +1719,9 @@ app.get('/api/stream', optionalJwt, async (req, res) => {
|
||||
if (!fs.existsSync(file_path)) {
|
||||
logger.error(`File ${file_path} could not be found! UID: ${uid}, ID: ${file_obj.id}`);
|
||||
}
|
||||
const stat = fs.statSync(file_path)
|
||||
const fileSize = stat.size
|
||||
const range = req.headers.range
|
||||
const stat = fs.statSync(file_path);
|
||||
const fileSize = stat.size;
|
||||
const range = req.headers.range;
|
||||
if (range) {
|
||||
const parts = range.replace(/bytes=/, "").split("-")
|
||||
const start = parseInt(parts[0], 10)
|
||||
@@ -1761,7 +1761,7 @@ app.get('/api/thumbnail/:path', optionalJwt, async (req, res) => {
|
||||
else res.sendStatus(404);
|
||||
});
|
||||
|
||||
// Downloads management
|
||||
// Downloads management
|
||||
|
||||
app.get('/api/downloads', optionalJwt, async (req, res) => {
|
||||
const user_uid = req.isAuthenticated() ? req.user.uid : null;
|
||||
@@ -1799,12 +1799,32 @@ app.post('/api/pauseDownload', optionalJwt, async (req, res) => {
|
||||
res.send({success: success});
|
||||
});
|
||||
|
||||
app.post('/api/pauseAllDownloads', optionalJwt, async (req, res) => {
|
||||
const user_uid = req.isAuthenticated() ? req.user.uid : null;
|
||||
let success = true;
|
||||
const all_running_downloads = await db_api.getRecords('download_queue', {paused: false, finished: false, user_uid: user_uid});
|
||||
for (let i = 0; i < all_running_downloads.length; i++) {
|
||||
success &= await downloader_api.pauseDownload(all_running_downloads[i]['uid']);
|
||||
}
|
||||
res.send({success: success});
|
||||
});
|
||||
|
||||
app.post('/api/resumeDownload', optionalJwt, async (req, res) => {
|
||||
const download_uid = req.body.download_uid;
|
||||
const success = await downloader_api.resumeDownload(download_uid);
|
||||
res.send({success: success});
|
||||
});
|
||||
|
||||
app.post('/api/resumeAllDownloads', optionalJwt, async (req, res) => {
|
||||
const user_uid = req.isAuthenticated() ? req.user.uid : null;
|
||||
let success = true;
|
||||
const all_paused_downloads = await db_api.getRecords('download_queue', {paused: true, user_uid: user_uid, error: null});
|
||||
for (let i = 0; i < all_paused_downloads.length; i++) {
|
||||
success &= await downloader_api.resumeDownload(all_paused_downloads[i]['uid']);
|
||||
}
|
||||
res.send({success: success});
|
||||
});
|
||||
|
||||
app.post('/api/restartDownload', optionalJwt, async (req, res) => {
|
||||
const download_uid = req.body.download_uid;
|
||||
const success = await downloader_api.restartDownload(download_uid);
|
||||
|
||||
8
backend/package-lock.json
generated
8
backend/package-lock.json
generated
@@ -2727,14 +2727,6 @@
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
|
||||
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
|
||||
},
|
||||
"queue": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz",
|
||||
"integrity": "sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==",
|
||||
"requires": {
|
||||
"inherits": "~2.0.3"
|
||||
}
|
||||
},
|
||||
"randombytes": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
"passport-local": "^1.0.0",
|
||||
"progress": "^2.0.3",
|
||||
"ps-node": "^0.1.6",
|
||||
"queue": "^6.0.2",
|
||||
"read-last-lines": "^1.7.2",
|
||||
"shortid": "^2.2.15",
|
||||
"unzipper": "^0.10.10",
|
||||
|
||||
Reference in New Issue
Block a user