The Frontpage is a Python script to download front pages of newspapers from Newseum. Fortunately, the pages follow an easy URL pattern: https://cdn.newseum.org/dfp/pdf{dom}/{newspaper}.pdf
where {dom}
is the day of the month (no leading zero), and {newspaper}
is the key of the newspaper you want to retrieve. For example, to receive the Washington Post frontpage from the most recent 20th day of the month use https://cdn.newseum.org/dfp/pdf20/DC_WP.pdf.
This setup is designed for the Raspberry Pi. Everything should work in a similar fashion for other *nix systems. (No guarantees for Windows users. Good luck.)
- Install CUPS to manage printers:
sudo apt-get install cups
thensudo usermod -a -G lpadmin pi
(make sure to use the correct username if it isn'tpi
) - Use
lpinfo -v
to find your printer URI - Setup the printer with
lpadmin -p home_printer -E -v <URI> -m everywhere
. Here I'm calling the printerhome_printer
. Remember this name! - Install
mutool
to split large front pages into two pages:sudo apt-get install mupdf-tool
- Install
cpdf
to remove images before printing$ sudo apt-get install opam $ opam init $ eval $(opam env) $ opam install camlpdf $ opam install cpdf # you may also need to `add eval $(opam env)` to your ~/.bashrc file, # although `opam init` should be able to handle this automatically
- Create a
frontpage.json
file with configuration details (you can actually name this file whatever you want):The{ "sources": [ "DC_WP", "NY_NYT", "KY_LHL", "WSJ" ], "print": "$RANDOM", "printer": "home_printer" }
sources
list contains the list of newspaper keys. To find these, search for papers at https://www.newseum.org/todaysfrontpages/, and click the "PDF" link on the detail page. Check the URL for the key. Add one of the keys to theprint
property to pick which one to print out, or use$RANDOM
to randomly select a paper to print. - Initialize the Python virtual environment
$ python3 -m venv .venv $ .venv/bin/python -m pip install -r requirements.txt
- Run the script!
$ .venv/bin/python -m frontpage frontpage.json
. Add the--no-print
switch to prevent any printing.
- Go to https://www.dropbox.com/developers and create a new app
- Configure the settings so you app has access to a scoped app folder (instead of your whole Dropbox)
- In the "Permissions" tab of the new app, check the
files.content.write
box so you will be able to upload files - Back in the main "Settings" tab, change the access token type to "No expiration" and click "Generate" to get an access token. Save this token!
- Create a
token.json
file that includes this generated token:{ "dropbox": "API_TOKEN" }
- Run using
$ .venv/bin/python -m frontpage frontpage.json --token token.json
We can use cron
to schedule the script on weekday mornings.
- Run
$ crontab -e
to edit the table of jobs. Picknano
as the editor if prompted. - Add this line to the editor (assuming you cloned this repo into your home directory):
0 6 * * 1-5 . /home/pi/.profile && cd /home/pi/frontpage && .venv/bin/python -m frontpage frontpage.json --token token.json
This will schedule the job to run Mon-Fri at 6 AM. Check on the Wikipedia page on cron
for more info about the table entries. We need to add . /home/pi/.profile
as the first command to make sure we have access to the environment variables we need.
Make sure your system time is correct! You can check/edit it with
timedatectl
. You may need to restart after changing the time in order to reset system logging andcron
.