Compare commits
3 Commits
e6f09c11ba
...
2515e90bea
Author | SHA1 | Date | |
---|---|---|---|
2515e90bea | |||
d457627e00 | |||
795ddc516d |
@ -16,7 +16,7 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1'
|
||||
implementation 'org.jsoup:jsoup:1.14.3'
|
||||
implementation 'org.jsoup:jsoup:1.15.3'
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
|
||||
|
@ -44,7 +44,7 @@ class StartupController {
|
||||
var cachetAPIKey = "0"
|
||||
var cachetBaseURL = "https://status.mosad.xyz"
|
||||
var courseListURL = "https://www.hs-offenburg.de/studium/vorlesungsplaene/"
|
||||
var mensaMenuURL = "https://www.swfr.de/essen-trinken/speiseplaene/mensa-offenburg/"
|
||||
var mensaMenuURL = "https://www.swfr.de/essen/mensen-cafes-speiseplaene/mensa-offenburg"
|
||||
var mensaName = "Offenburg"
|
||||
}
|
||||
|
||||
@ -77,29 +77,21 @@ class StartupController {
|
||||
val properties = Properties()
|
||||
properties.loadFromXML(FileInputStream(fileConfig))
|
||||
|
||||
cachetAPIKey = try {
|
||||
properties.getProperty("cachetAPIKey")
|
||||
} catch (ex: Exception) {
|
||||
"0"
|
||||
}
|
||||
try {
|
||||
cachetAPIKey = properties.getProperty("cachetAPIKey")
|
||||
} catch (_: Exception) {}
|
||||
|
||||
cachetBaseURL = try {
|
||||
properties.getProperty("cachetBaseURL")
|
||||
} catch (ex: Exception) {
|
||||
"https://status.mosad.xyz"
|
||||
}
|
||||
try {
|
||||
cachetBaseURL = properties.getProperty("cachetBaseURL")
|
||||
} catch (_: Exception) {}
|
||||
|
||||
mensaMenuURL = try {
|
||||
properties.getProperty("mensaMenuURL")
|
||||
} catch (ex: Exception) {
|
||||
"https://www.swfr.de/essen-trinken/speiseplaene/mensa-offenburg/"
|
||||
}
|
||||
try {
|
||||
mensaMenuURL = properties.getProperty("mensaMenuURL")
|
||||
} catch (_: Exception) {}
|
||||
|
||||
mensaName = try {
|
||||
properties.getProperty("mensaName")
|
||||
} catch (ex: Exception) {
|
||||
"Offenburg"
|
||||
}
|
||||
try {
|
||||
mensaName = properties.getProperty("mensaName")
|
||||
} catch (_: Exception) {}
|
||||
|
||||
} catch (ex: Exception) {
|
||||
logger.error("error while loading config", ex)
|
||||
@ -111,10 +103,10 @@ class StartupController {
|
||||
private fun createConfig() = try {
|
||||
val properties = Properties()
|
||||
|
||||
properties.setProperty("cachetAPIKey", "0")
|
||||
properties.setProperty("cachetBaseURL", "https://status.mosad.xyz")
|
||||
properties.setProperty("mensaMenuURL", "https://www.swfr.de/essen-trinken/speiseplaene/mensa-offenburg/")
|
||||
properties.setProperty("mensaName", "Offenburg")
|
||||
properties.setProperty("cachetAPIKey", cachetAPIKey)
|
||||
properties.setProperty("cachetBaseURL", cachetBaseURL)
|
||||
properties.setProperty("mensaMenuURL", mensaMenuURL)
|
||||
properties.setProperty("mensaName", mensaName)
|
||||
|
||||
val outputStream = FileOutputStream(fileConfig)
|
||||
properties.storeToXML(outputStream, "tcor configuration")
|
||||
|
@ -59,14 +59,14 @@ class MensaParser {
|
||||
val mealWeekList = MensaWeek()
|
||||
|
||||
try {
|
||||
htmlDoc.select("#speiseplan-tabs").select("div.tab-content").select("div.menu-tagesplan")
|
||||
htmlDoc.select("#tabsWeekdaysMenu").select("div.menu-tagesplan")
|
||||
.forEachIndexed { dayIndex, day ->
|
||||
val strDay = day.select("h3").text()
|
||||
|
||||
day.select("div.row").forEachIndexed { _, meal ->
|
||||
val heading = meal.select("h4.menu-header").text()
|
||||
val parts = ArrayList(meal.select("div.menu-info").html().substringBefore("<br><span").replace("\n", "").split("<br>"))
|
||||
val additives = meal.select("span.show-with-allergenes").text()
|
||||
day.select("div.menu-tagesplan > div.grid").first()?.select("div.flex-col")?.forEachIndexed { _, meal ->
|
||||
val heading = meal.select("h5").text()
|
||||
val parts = ArrayList(meal.select("small.extra-text").html().split("<br>").map { it.trim() })
|
||||
val additives = meal.select("small.zusatzsstoffe[x-show=showAllergenes]").text()
|
||||
parts.removeIf { x -> x.isEmpty() || x.isBlank() }
|
||||
|
||||
mealWeekList.days[dayIndex].meals.add(Meal(strDay, heading, parts, additives))
|
||||
@ -87,8 +87,7 @@ class MensaParser {
|
||||
*/
|
||||
fun getMenuLinkNextWeek(mensaMenuURL: String): String {
|
||||
val menuHTML = Jsoup.connect(mensaMenuURL).get()
|
||||
|
||||
return "https://www.swfr.de" + menuHTML.select("#speiseplan-tabs").select("a.next-week").attr("href")
|
||||
return "https://www.swfr.de" + menuHTML.select("div.section-mensa").select("a.next-week").attr("href")
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user