Skip to content

PHP-based utility to download all Advent of Code puzzles and inputs

License

Notifications You must be signed in to change notification settings

colinodell/aoc-downloader

Repository files navigation

Advent of Code Downloader

License Supported PHP Versions Packagist Version GitHub Workflow Status (branch) Sponsor this project

Simple PHP-based utility to download all Advent of Code puzzles and inputs locally.

Requirements

This project requires PHP 7.4 or higher.

Installation

There are three ways to download and use this utility:

Composer Dependency

Using PHP for your AoC puzzles? You can include this as a dev dependency in your repository:

composer require --dev colinodell/aoc-downloader

Standalone PHAR

Don't want to mix dependencies or prefer a single executable file? A pre-compiled PHAR is also available via the Releases tab. Simply download the .phar file, make it executable, and run it.

From Source

git clone https://github.com/colinodell/aoc-downloader.git
cd aoc-downloader
composer update -o --no-dev

Usage

You'll need to log into adventofcode.com and grab your session cookie using your browser's dev tools:

You can then pass that as an argument to this utility:

Usage:
  ./bin/aoc-downloader [options] [--] <session_id>

Arguments:
  session_id            Session ID (from the adventofcode.com `session` cookie

Options:
  -o, --output=OUTPUT   The directory to save the downloaded files [default: "./puzzles"]
  -y, --year=YEAR       The year to download puzzles for (default is all years)
  -h, --help            Display help for the given command. When no command is given display help for the ./bin/download.php command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

It will save both the puzzle test and input data locally:

puzzles/2020
├── day01
│   ├── input.txt
│   └── README.md
├── day02
│   ├── input.txt
│   └── README.md
├── day03
│   ├── input.txt
│   └── README.md
├── day04
│   ├── input.txt
│   └── README.md
├── day05
│   ├── input.txt
│   └── README.md
├── day06
│   ├── input.txt
│   └── README.md
├── day07
│   ├── input.txt
│   └── README.md
├── day08
│   ├── input.txt
│   └── README.md
├── day09
│   ├── input.txt
│   └── README.md
├── day10
│   ├── input.txt
│   └── README.md
...