Better properties handling.

This commit is contained in:
Chris Hodges 2023-12-09 11:47:09 +01:00
parent fb3a5ce5d2
commit 56fcbfe165

View File

@ -12,19 +12,15 @@ import java.nio.file.Paths
import java.time.LocalDate
import java.time.Month
import java.time.ZoneId
import java.util.*
fun main() {
var cookie = "<insert your session cookie here or store in gradle.properties>"
if (Files.exists(Paths.get("gradle.properties"))) {
val cookieFromProps = Files.readAllLines(Paths.get("gradle.properties"))
.map { it.split("=") }
.filter { it.size == 2 }
.filter { it[0] == "cookie" }
.map { it[1] }.firstOrNull()
if (cookieFromProps != null) {
cookie = cookieFromProps
}
val props = Properties()
props.load(Files.newBufferedReader(Paths.get("gradle.properties")))
cookie = props.getProperty("cookie", cookie)
}
val downloader = Downloader(2023, "aoc2023", cookie)