Better properties handling.
This commit is contained in:
parent
fb3a5ce5d2
commit
56fcbfe165
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user