Closed kigy1 closed 3 months ago
thanks for your work
this how to fix it edit this code
for (const child of data.data.children) { const post = child.data; // Check if the post contains a gallery if (post.is_gallery && post.media_metadata) { Object.entries(post.mediametadata).forEach(async ([id, media]) => { if (media && media.s && media.s.u) { const imageUrl = media.s.u.replace(/&/g, '&'); const fileType = imageUrl.split('.').pop().split('?')[0]; const fileName = `${sanitizeFileName(post.title)}${id}.${fileType}; const filePath =${downloadDirectory}/${fileName}`;
; const filePath =
try { await downloadMediaFile(imageUrl, filePath); console.log(`Downloaded image: ${filePath}`); } catch (error) { console.error(`Failed to download image: ${error}`); } } }); } else { // Code for handling other types of posts await sleep(); try { await downloadPost(post); } catch (e) { log(e, true); } }
} } catch (error) { // throw the error throw error; } }
but after that this Error: EMFILE: too many open files, open also it is loops and download the file again and again
Should be closed with #94
thanks for your work
this how to fix it edit this code
for (const child of data.data.children) { const post = child.data; // Check if the post contains a gallery if (post.is_gallery && post.media_metadata) { Object.entries(post.mediametadata).forEach(async ([id, media]) => { if (media && media.s && media.s.u) { const imageUrl = media.s.u.replace(/&/g, '&'); const fileType = imageUrl.split('.').pop().split('?')[0]; const fileName = `${sanitizeFileName(post.title)}${id}.${fileType}
; const filePath =
${downloadDirectory}/${fileName}`;} } catch (error) { // throw the error throw error; } }
but after that this Error: EMFILE: too many open files, open also it is loops and download the file again and again