Skip to content

Commit

Permalink
Load all images from Telegram post
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Borsuk <[email protected]>
  • Loading branch information
biodranik committed Dec 23, 2022
1 parent 45fff90 commit dd22d02
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions update_news.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,16 @@ function parseHtml(html) {
// Handle special cases when image is published as a separate message immediately after
// the main text message (Telegram has 1024 chars limit for image caption).
if (!text && prevDate && (new Date(date) - new Date(prevDate)) <= kPostsDiffInMs) {
// Do not download jpg if manual png already exists.
if (!fs.existsSync(`${prevDir}/${i}.png`)) {
// Do not download jpg if images already exist.
if (!fs.existsSync(`${prevDir}/${i}.png`)
&& !fs.existsSync(`${prevDir}/${i}.jpg`)
&& !fs.existsSync(`${prevDir}/${i}.jpeg`)) {
downloads.push(downloadAsync(photo, `${prevDir}/${fileName}`));
fs.rmSync(dir, { recursive: true, force: true });
}
return;
} else {
downloads.push(downloadAsync(photo, `${dir}/${fileName}`));
}
downloads.push(downloadAsync(photo, `${dir}/${fileName}`));
}

const markdown = toMarkdown(text, date);
Expand Down

0 comments on commit dd22d02

Please sign in to comment.