Get session cookie from ~/.config/aoc2020session so I don’t have to put it into the scheme every day
This commit is contained in:
parent
34ca4c3fc2
commit
1f9aae4f16
1 changed files with 2 additions and 4 deletions
|
@ -1,12 +1,10 @@
|
|||
import Foundation
|
||||
|
||||
func loadData(day: Int) -> String {
|
||||
guard let session = getenv("SESSION") else {
|
||||
fatalError("Missing session env var")
|
||||
}
|
||||
let session = (try! String(contentsOf: FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".config/aoc2020session"))).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
var request = URLRequest(url: URL(string: "https://adventofcode.com/2020/day/\(day)/input")!)
|
||||
request.setValue("session=\(String(cString: session))", forHTTPHeaderField: "Cookie")
|
||||
request.setValue("session=\(session)", forHTTPHeaderField: "Cookie")
|
||||
|
||||
var result: String? = nil
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue