removed deprecation warning and cleaned up code
This commit is contained in:
parent
f9266ee695
commit
d790531583
5 changed files with 18 additions and 25 deletions
|
|
@ -7,12 +7,10 @@ If you want a command that just downloads, compiles and runs everything, run thi
|
|||
```sh
|
||||
git clone https://github.com/KoenDR06/KamerZoeken
|
||||
cd KamerZoeken
|
||||
|
||||
```
|
||||
|
||||
Then, set your preferences in [config.toml](config.toml). After you have done this, run the following script:
|
||||
Then, set your preferences in `[config.toml](config.toml)` and set your credentials in `.env` (you can find what secrets are needed in `[sample.env](sample.env)`). After you have done this, you are ready to run the script using:
|
||||
|
||||
```sh
|
||||
./gradlew build
|
||||
java -jar build/libs/KamerZoeken-1.0.0.jar
|
||||
java -jar KamerZoeken-1.0.0.jar
|
||||
```
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[general]
|
||||
unitType = "Kamer" # Kamer of Woning
|
||||
allowZeist = true # Of je ook in Zeist wil zoeken
|
||||
cities = ["ZEIST", "UTRECHT"] # Steden om in te zoeken
|
||||
|
||||
smoking = -1 # 0: geen voorkeur, -1: ik wil dat er niet gerookt mag worden, 1: Ik wil dat er gerookt mag worden
|
||||
pets = 0 # 0: geen voorkeur, -1: ik wil dat er geen huisdieren mogen, 1: Ik wil dat huisdieren mogen
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
AUTH=
|
||||
EMAIL=test@example.com
|
||||
PASSWORD="123456789"
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ data class ReactableOffer(
|
|||
)
|
||||
|
||||
fun main() {
|
||||
print("Authenticating")
|
||||
val sessionToken = auth()
|
||||
|
||||
print("Getting rooms")
|
||||
print("\rGetting rooms ")
|
||||
val rooms = getRooms().filter { room ->
|
||||
room.unitType == config.general.unitType
|
||||
}
|
||||
|
|
@ -28,12 +29,9 @@ fun main() {
|
|||
}
|
||||
|
||||
val offers = getOffers(rooms.map { it.wocasId }).offers.filter { offer ->
|
||||
offer.adres[0].plaats in listOf(
|
||||
"UTRECHT",
|
||||
) + if (config.general.allowZeist) "ZEIST" else ""
|
||||
offer.adres[0].plaats in config.general.cities
|
||||
}
|
||||
|
||||
print("\rFiltering on personal filters")
|
||||
var index = 0
|
||||
val coupled = rooms.mapNotNull { room ->
|
||||
val offer: Offer? = offers.find { room.wocasId.toInt() == it.eenheidNummer.toInt() }
|
||||
|
|
@ -43,11 +41,6 @@ fun main() {
|
|||
}.filter {
|
||||
val gender = it.floor.floorInfo.genderPreference
|
||||
|
||||
val date = it.room.expireBy.take(10)
|
||||
val date1 = LocalDate.now()
|
||||
val date2 = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
|
||||
val daysLeft = ChronoUnit.DAYS.between(date1, date2)
|
||||
|
||||
val smoking = it.floor.floorInfo.smokingAllowed ?: true
|
||||
val pets = it.floor.floorInfo.petsAllowed ?: false
|
||||
|
||||
|
|
@ -57,9 +50,13 @@ fun main() {
|
|||
|
||||
((config.general.smoking == -1 && !smoking) || (config.general.smoking == 1 && smoking) || config.general.smoking == 0) &&
|
||||
|
||||
((config.general.pets == -1 && !pets) || (config.general.pets == 1 && pets) || config.general.pets == 0) &&
|
||||
((config.general.pets == -1 && !pets) || (config.general.pets == 1 && pets) || config.general.pets == 0)
|
||||
}.sortedBy {
|
||||
val date = it.room.expireBy.take(10)
|
||||
val date1 = LocalDate.now()
|
||||
val date2 = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
|
||||
|
||||
daysLeft == 0L
|
||||
ChronoUnit.DAYS.between(date1, date2)
|
||||
}
|
||||
|
||||
val fileName = "offers.md"
|
||||
|
|
@ -71,7 +68,7 @@ fun main() {
|
|||
coupled.forEach {
|
||||
val address = it.offer.adres[0]
|
||||
|
||||
str.append("## [${address.straatnaam} ${address.nummer}, ${address.plaats.lowercase().capitalize()}](https://sshxl.nl/nl/aanbod/${it.room.flowId}-${address.straatnaam.lowercase().replace(" ", "-")})\n")
|
||||
str.append("## [${address.straatnaam} ${address.nummer}, ${address.plaats.lowercase().replaceFirstChar { if (it.isLowerCase()) it - 32 else it }}](https://sshxl.nl/nl/aanbod/${it.room.flowId}-${address.straatnaam.lowercase().replace(" ", "-")})\n")
|
||||
|
||||
str.append("\n| Categorie | Waarde |\n")
|
||||
str.append("|-------------|--------------------|\n")
|
||||
|
|
@ -99,9 +96,6 @@ fun main() {
|
|||
|
||||
str.append("\n")
|
||||
|
||||
val etage = getEtage(it.offer.assSubjectPersk.first { it.pkHeeftAsp == 52.0 }.waarde!!)
|
||||
|
||||
if (etage != null) str.append("\n\n")
|
||||
str.append("### Message: \n\n${it.floor.floorInfo.description ?: "Deze pannekoeken hebben geen bericht achtergelaten"}\n")
|
||||
|
||||
str.append("\n\n")
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import java.io.File
|
|||
|
||||
data class GeneralConfig(
|
||||
val unitType: String,
|
||||
val allowZeist: Boolean,
|
||||
val cities: List<String>,
|
||||
val smoking: Int,
|
||||
val pets: Int
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue