-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlunchMenu.js
33 lines (29 loc) · 1.14 KB
/
lunchMenu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//all processing for the lunch menu is done here
//change the code to match your schools lunch menu
const { DownloaderHelper } = require('node-downloader-helper');
const pdfparse = require("pdf-parse")
const fs = require("fs")
function lunchMenu() {
return new Promise((resolve, reject) => {
const dl = new DownloaderHelper("https://fwparker.myschoolapp.com/ftpimages/1048/download/download_6209679.pdf", __dirname)
dl.on("end", function() {
let dataBuffer = fs.readFileSync(dl.getDownloadPath())
pdfparse(dataBuffer).then(function(data) {
var text = data.text.split("Monday:")[1]
var l = {}
var week = text.split("Tuesday:")
l["Monday"] = week[0].split("\n").slice(1)
week = week[1].split("Wednesday:")
l["Tuesday"] = week[0].split("\n").slice(1)
week = week[1].split("Thursday:")
l["Wednesday"] = week[0].split("\n").slice(1)
week = week[1].split("Friday:")
l["Thursday"] = week[0].split("\n").slice(1)
l["Friday"] = week[1].split("\n").slice(1)
resolve(l)
})
})
dl.start()
})
}
module.exports = {lunchMenu:lunchMenu};