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
|
// RUN A JOB
|
||||||
// ========================
|
// ========================
|
||||||
async function runJob(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";
|
const venvPython = "/home/pm2/Proxer-Downloader/.venv/bin/python";
|
||||||
|
|
||||||
// Construct command string
|
const cleanName = job.filename.replace(".mp4", "");
|
||||||
const command = `${venvPython} ${scriptPath} -u "${url}" -f "${cleanName}" -t "${token}" -o "${OUTPUT_DIR}"`;
|
|
||||||
|
const command = `${venvPython} scripts/proxer-dl-video.py \
|
||||||
|
-u "${job.url}" -f "${cleanName}" -t ${job.token} -o "${OUTPUT_DIR}"`;
|
||||||
|
|
||||||
console.log("Running:", command);
|
console.log("Running:", command);
|
||||||
|
|
||||||
@@ -38,20 +33,19 @@ async function runJob(job) {
|
|||||||
if (error) {
|
if (error) {
|
||||||
console.error(`FAILED: ${cleanName}`);
|
console.error(`FAILED: ${cleanName}`);
|
||||||
await failedCol.insertOne({
|
await failedCol.insertOne({
|
||||||
filename,
|
filename: job.filename,
|
||||||
url,
|
url: job.url,
|
||||||
failed_at: new Date(),
|
failed_at: new Date(),
|
||||||
output_log: outputLog,
|
output_log: outputLog,
|
||||||
return_code: error.code,
|
return_code: error.code,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove from queue
|
|
||||||
await queueCol.deleteOne({ _id: job._id });
|
await queueCol.deleteOne({ _id: job._id });
|
||||||
} else {
|
} else {
|
||||||
console.log(`SUCCESS: ${cleanName}`);
|
console.log(`SUCCESS: ${cleanName}`);
|
||||||
await doneCol.insertOne({
|
await doneCol.insertOne({
|
||||||
filename,
|
filename: job.filename,
|
||||||
url,
|
url: job.url,
|
||||||
finished_at: new Date(),
|
finished_at: new Date(),
|
||||||
output_log: outputLog,
|
output_log: outputLog,
|
||||||
result: "success",
|
result: "success",
|
||||||
@@ -76,7 +70,6 @@ async function main() {
|
|||||||
doneCol = db.collection("done");
|
doneCol = db.collection("done");
|
||||||
failedCol = db.collection("failed");
|
failedCol = db.collection("failed");
|
||||||
|
|
||||||
// Polling loop
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const job = await queueCol.findOneAndUpdate(
|
const job = await queueCol.findOneAndUpdate(
|
||||||
{},
|
{},
|
||||||
|
|||||||
Reference in new issue
Block a user