From af92d9f12534021ccb35e0328daec8fdc72c0ba2 Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Fri, 28 Jun 2024 09:25:00 +0530 Subject: removed the date and fixed content not loading issue --- server.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index c8dd2e4..5727d34 100644 --- a/server.js +++ b/server.js @@ -23,8 +23,6 @@ const escapedUsername = escapePythonString(credentials.username); const escapedPassword = escapePythonString(credentials.password); const baseDir = path.join(__dirname, 'downloads'); -const dateStr = new Date().toISOString().split('T')[0]; -const dateDir = path.join(baseDir, dateStr); function downloadContent() { const influencers = JSON.parse(fs.readFileSync(path.join(__dirname, 'influencers.json'), 'utf8')).profiles; @@ -36,7 +34,7 @@ import os L = instaloader.Instaloader() L.login('${escapedUsername}', '${escapedPassword}') PROFILES = ${JSON.stringify(influencers)} -BASE_DIR = "${dateDir.replace(/\\/g, '/')}" +BASE_DIR = "${baseDir.replace(/\\/g, '/')}" os.makedirs(BASE_DIR, exist_ok=True) @@ -53,7 +51,7 @@ def download_posts(profile): for profile in PROFILES: download_posts(profile) -`; + `; const scriptPath = path.join(__dirname, 'download_script.py'); fs.writeFileSync(scriptPath, script); @@ -77,13 +75,13 @@ downloadContent(); // Endpoint to list downloaded files app.get('/downloads', (req, res) => { - fs.readdir(dateDir, (err, profiles) => { + fs.readdir(baseDir, (err, profiles) => { if (err) { return res.status(500).json({ error: err.message }); } const allowedExtensions = ['.mp4', '.jpg', '.jpeg']; const fileList = profiles.flatMap(profileDir => { - const profilePath = path.join(dateDir, profileDir); + const profilePath = path.join(baseDir, profileDir); return fs.readdirSync(profilePath) .filter(file => allowedExtensions.includes(path.extname(file).toLowerCase())) .map(file => { -- cgit v1.2.3-59-g8ed1b