inteagrate old script
This commit is contained in:
1 parent
c649eea28b
commit
765fca4764
1 file changed
+8
-15
+8
-15
@@ -18,17 +18,12 @@ let queueCol, doneCol, failedCol;
|
||||
// RUN A JOB
|
||||
// ========================
|
||||
async function runJob(job) {
|
||||
const url = job.url;
|
||||
const filename = job.filename;
|
||||
const token = job.token;
|
||||
|
||||
const cleanName = filename.replace(".mp4", "");
|
||||
|
||||
const scriptPath = path.join(__dirname, "proxer-dl-video.py");
|
||||
const venvPython = "/home/pm2/Proxer-Downloader/.venv/bin/python";
|
||||
|
||||
// Construct command string
|
||||
const command = `${venvPython} ${scriptPath} -u "${url}" -f "${cleanName}" -t "${token}" -o "${OUTPUT_DIR}"`;
|
||||
const cleanName = job.filename.replace(".mp4", "");
|
||||
|
||||
const command = `${venvPython} scripts/proxer-dl-video.py \
|
||||
-u "${job.url}" -f "${cleanName}" -t ${job.token} -o "${OUTPUT_DIR}"`;
|
||||
|
||||
console.log("Running:", command);
|
||||
|
||||
@@ -38,20 +33,19 @@ async function runJob(job) {
|
||||
if (error) {
|
||||
console.error(`FAILED: ${cleanName}`);
|
||||
await failedCol.insertOne({
|
||||
filename,
|
||||
url,
|
||||
filename: job.filename,
|
||||
url: job.url,
|
||||
failed_at: new Date(),
|
||||
output_log: outputLog,
|
||||
return_code: error.code,
|
||||
});
|
||||
|
||||
// Remove from queue
|
||||
await queueCol.deleteOne({ _id: job._id });
|
||||
} else {
|
||||
console.log(`SUCCESS: ${cleanName}`);
|
||||
await doneCol.insertOne({
|
||||
filename,
|
||||
url,
|
||||
filename: job.filename,
|
||||
url: job.url,
|
||||
finished_at: new Date(),
|
||||
output_log: outputLog,
|
||||
result: "success",
|
||||
@@ -76,7 +70,6 @@ async function main() {
|
||||
doneCol = db.collection("done");
|
||||
failedCol = db.collection("failed");
|
||||
|
||||
// Polling loop
|
||||
while (true) {
|
||||
const job = await queueCol.findOneAndUpdate(
|
||||
{},
|
||||
|
||||
Reference in new issue
Block a user