Skip to content

jackcheng/print-xword

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Update 6/4/24: Something changed with the way NYT handles cookies and this method doesn't seem to work anymore. Will investigate further ...

Print XWord

This script downloads the latest daily New York Times crossword and sends it to your printer.

Requirements

  • An active NYTimes Games subscription
  • A computer and printer that are awake/on standby when the script runs

Setup

While logged into your account at https://www.nytimes.com/crosswords, open your browser's developer console and enter document.cookie. Copy the full cookie text into NYT_COOKIE=""

Testing the script

To manually run the script:

./print-xword.sh

It should print, to your default printer, tomorrow's crossword if available (ie. it's after 10pm local time). Otherwise, it'll print the current day's crossword.

Automate with cron

Set up a cron job by running:

crontab -e

And adding the following line, replacing your-path with the path to your script:

01 22 * * * /your-path/print-xword.sh > /dev/null 2>&1

The first two numbers represent the minute (0–59) and hour (0–23) the job runs. As configured above, the script runs every day at 22:01 (10:01PM) local time. > /dev/null 2>&1 suppresses logging. More on cron expressions can be found in this guide.

Verify that it's saved with:

crontab -l

Give it executable permissions so it will run in cron:

chmod +x /your-path/print-xword.sh

Printing to a non-default printer

If you have more than one printer, you can choose which to print to via the -P option in lpr:

lpr -P your-printer-name -o media=Letter -o fit-to-page

lpstat -p -d will show a list printer names. See the CUPS manual for additional print options.

Further notes

The NYT cookie expires after some time (often months or longer). You'll have to update NYT_COOKIE with the new cookie when it does. For a more elegant approach that just uses your username/password, Bert Wagner has a neat tutorial.

Releases

No releases published

Packages

No packages published

Languages