diff --git a/generate.mjs b/downloader.mjs similarity index 90% rename from generate.mjs rename to downloader.mjs index e359a92..d9a00f8 100644 --- a/generate.mjs +++ b/downloader.mjs @@ -20,20 +20,20 @@ function downloadImage(time_string, filepath) { port: 443, path: `/docs/default-source/rain-area/dpsri_70km_${time_string}0000dBR.dpsri.png`, headers: { - "Host": "www.nea.gov.sg", + "Host":"www.nea.gov.sg", "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8", + "Accept": "image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate, br, zstd", "DNT": "1", "Connection": "keep-alive", - "Upgrade-Insecure-Requests": "1", - "Sec-Fetch-Dest": "document", - "Sec-Fetch-Mode": "navigate", - "Sec-Fetch-Site": "cross-site", - "Priority": "u=0, i", + "Sec-Fetch-Dest": "image", + "Sec-Fetch-Mode": "no-cors", + "Sec-Fetch-Site": "same-origin", + "Priority": "u=5, i", "Pragma": "no-cache", "Cache-Control": "no-cache", + "TE": "trailers", } } client.get(options, (res) => { diff --git a/index.mjs b/index.mjs index a19f75f..d9838d5 100644 --- a/index.mjs +++ b/index.mjs @@ -1,4 +1,4 @@ -import { initImages, updateImages } from './generate.mjs'; +import { initImages, updateImages } from './downloader.mjs'; initImages(10).then(() => { console.log('Downloaded initial images successfully'); diff --git a/package.json b/package.json index b5f2e16..bf367a8 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,9 @@ "test": "echo \"Error: no test specified\" && exit 1", "start": "node index.mjs" }, + "dependencies": { + "canvas": "^2.11.2" + }, "author": "", "license": "ISC" } diff --git a/video.js b/video.js new file mode 100644 index 0000000..e69de29