Skip to content

Instantly share code, notes, and snippets.

@ynx0
Last active December 3, 2021 01:26
Show Gist options
  • Save ynx0/be93cc1c086f8538155c69614d5644e4 to your computer and use it in GitHub Desktop.
Save ynx0/be93cc1c086f8538155c69614d5644e4 to your computer and use it in GitHub Desktop.
Get your AoC inputs straight from the dojo!
/- 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 !>(~))
@ynx0
Copy link
Author

ynx0 commented Dec 2, 2021

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:
cookie view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment