summaryrefslogtreecommitdiffstats
path: root/server.js
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-06-28 09:25:00 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-06-28 09:25:00 +0530
commitaf92d9f12534021ccb35e0328daec8fdc72c0ba2 (patch)
tree5eeb6ee3a8277664f94885de7b35c9d2ce1b09e7 /server.js
parentb06cf01e232e797abceabba08aec2c0752db95ad (diff)
downloadinsta-local-af92d9f12534021ccb35e0328daec8fdc72c0ba2.tar.gz
insta-local-af92d9f12534021ccb35e0328daec8fdc72c0ba2.tar.bz2
insta-local-af92d9f12534021ccb35e0328daec8fdc72c0ba2.zip
removed the date and fixed content not loading issue
Diffstat (limited to 'server.js')
-rw-r--r--server.js10
1 files changed, 4 insertions, 6 deletions
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 => {