Skip to content

Instantly share code, notes, and snippets.

@christianhaller3000
Last active January 7, 2020 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianhaller3000/9612c94d37472854491ddb64c94427d0 to your computer and use it in GitHub Desktop.
Save christianhaller3000/9612c94d37472854491ddb64c94427d0 to your computer and use it in GitHub Desktop.
const fetch = require("node-fetch");
const fn = async () => {
const token = "11e01fc60358e3d96947ab6d4afaee66";
const today = new Date().toDateString();
const iconMap = {
"10": "Ⓥ",
"11": "🌱",
"12": "🌾",
"13": "🚫🥛",
"16": "🐟",
"17": "🐓"
};
const res = await fetch(
`https://kochwerk-web.webspeiseplan.de/index.php?token=${token}&model=menu&location=1800&languagetype=1&_=1578318310364`,
{
headers: {
referer: "https://kochwerk-web.webspeiseplan.de/Menu"
}
}
);
const { content } = await res.json();
content
.sort((a, b) => {
if (a.speiseplanGerichtData.length < b.speiseplanGerichtData.length) {
return 1;
}
if (a.speiseplanGerichtData.length > b.speiseplanGerichtData.length) {
return -1;
}
return 0;
})
.forEach((outlet) => {
const { anzeigename } = outlet.speiseplanAdvanced;
const mealsToday = outlet.speiseplanGerichtData.filter((gericht) => {
return (
new Date(
Date.parse(gericht.speiseplanAdvancedGericht.datum)
).toDateString() === today
);
});
if (mealsToday.length > 2) {
console.log(`\n 🏢️ ${anzeigename} (${today})\n`);
mealsToday.forEach(
({ gerichtmerkmaleIds, speiseplanAdvancedGericht }) => {
let icons = " ";
if (gerichtmerkmaleIds) {
icons = gerichtmerkmaleIds
.split(",")
.map((id) => {
return iconMap[id] || id;
})
.join(" ");
}
const gerichtName = speiseplanAdvancedGericht.gerichtname
.replace(/(\r\n|\n|\r)/gm, " ")
.replace(/ +/g, " ")
.replace("Kleine Portion 1,50 €", "")
.replace("kleine Portion 1,50€", "")
.replace("Kleine Portion 1,50€", "");
console.log(`• ${gerichtName} ${icons}`);
}
);
}
});
};
fn();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment