Last active
December 3, 2021 01:26
-
-
Save ynx0/be93cc1c086f8538155c69614d5644e4 to your computer and use it in GitHub Desktop.
Get your AoC inputs straight from the dojo!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/- spider | |
/+ strandio | |
=, strand=strand:spider | |
^- thread:spider | |
|= arg=vase | |
:: adapted from https://urbit.org/docs/arvo/iris/example (thanks ~tinnus-napbus!) | |
=/ m (strand ,vase) | |
^- form:m | |
=/ day (need !<([(unit @ud)] arg)) | |
;< =bowl:spider bind:m get-bowl:strandio | |
=/ year (crip (en-json:html (numb:enjs:format y:(yore now.bowl)))) :: there's probably a better way | |
=/ url=@t (crip "https://adventofcode.com/{(trip year)}/day/{<day>}/input") | |
=/ headers | |
:~ | |
:- 'Cookie' | |
'session=YOUR_SESSION_TOKEN' | |
== | |
=/ =request:http [%'GET' url headers ~] | |
=/ =task:iris [%request request *outbound-config:iris] | |
=/ =card:agent:gall [%pass /http-req %arvo %i task] | |
;< ~ bind:m (send-raw-card:strandio card) | |
;< res=(pair wire sign-arvo) bind:m take-sign-arvo:strandio | |
?. ?=([%iris %http-response %finished *] q.res) | |
(strand-fail:strand %bad-sign ~) | |
:: ~& +.q.res | |
?~ full-file.client-response.q.res | |
(strand-fail:strand %no-body ~) | |
=/ input-text `@t`q.data.u.full-file.client-response.q.res | |
=/ clay-task `task:clay`[%info %base %& [/lib/advent/day/(scot %ud day)/txt %ins txt+!>((to-wain:format input-text))]~] | |
;< ~ bind:m (send-raw-card:strandio [%pass /write-file %arvo %c clay-task]) | |
(pure:m !>(~)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just replace
YOUR_SESSION_TOKEN
with your session token, plop the file in/ted
, run-advent-get 1
, and get input delivered at/lib/advent/day/1/txt
To get the session token, you'll need to navigate to https://adventofcode.com and use the web console to get the value from your cookies: