Repository navigation
Expand file tree
/
Copy pathbackup.js
More file actions
32 lines (28 loc) · 1.46 KB
/
Copy pathbackup.js
File metadata and controls
32 lines (28 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const path = require('path');
require('dotenv').config();
const { BackupEngine } = require('./src/backup-engine');
const COOKIE = process.env.LOOM_COOKIE;
if (!COOKIE) {
console.error("Error: Please set LOOM_COOKIE in your .env file.");
process.exit(1);
}
const engine = new BackupEngine({
cookie: COOKIE,
backupDir: path.join(__dirname, 'Loom_Backup'),
});
engine.on('progress', (event) => {
switch (event.type) {
case 'fetch_page': console.log(`... fetched ${event.count} videos so far`); break;
case 'library_fetched': console.log(`Total Found: ${event.total} videos`); break;
case 'video_start': console.log(`\nProcessing Video: ${event.name} (${event.index + 1}/${event.total})`); break;
case 'video_skipped': console.log(` Skipped (already backed up)`); break;
case 'download_start': console.log(` Downloading ${event.asset}...`); break;
case 'download_complete': console.log(` Downloaded ${event.asset}`); break;
case 'download_skipped': console.log(` Skipped ${event.asset} (already exists)`); break;
case 'warning': console.log(` Warning (${event.asset}): ${event.message}`); break;
case 'error': console.error(` Error (${event.asset || 'video'}): ${event.message}`); break;
case 'complete': console.log(`\nDone! Downloaded: ${event.downloaded}, Skipped: ${event.skipped}, Errors: ${event.errors}`); break;
}
});
console.log("Fetching your complete Loom Library metadata...");
engine.runFullBackup().catch(console.error);