Skip to content

Commit

Permalink
Update aria2.js
Browse files Browse the repository at this point in the history
  • Loading branch information
besoeasy authored Nov 3, 2024
1 parent 9dcff5d commit 8500194
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions func/aria2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const axios = require("axios");

const path = require("path");

const { saveDirectory } = require("./utils.js");

const axiosPost = async (method, params = []) => {
Expand All @@ -11,7 +9,6 @@ const axiosPost = async (method, params = []) => {
id: 1,
params,
});

return data;
};

Expand All @@ -24,10 +21,17 @@ const getGlobalStats = async () => {
};

const downloadAria = async (id, url) => {
// Get current date in YYYYMMDD format
const currentDate = new Date().toISOString().slice(0, 10).replace(/-/g, "");

// Construct directory path with saveDirectory/id/currentDate
const downloadDir = path.join(saveDirectory, id, currentDate);

// Call aria2.addUri with the constructed directory path
return await axiosPost("aria2.addUri", [
[url],
{
dir: path.join(saveDirectory, id),
dir: downloadDir,
enableDHT: true,
enablePeerExchange: true,
},
Expand Down

0 comments on commit 8500194

Please sign in to comment.