diff --git a/src/downloader/Downloader.kt b/src/downloader/Downloader.kt index 8dd1188..63efa38 100644 --- a/src/downloader/Downloader.kt +++ b/src/downloader/Downloader.kt @@ -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 = "" 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)