File Hoarding Made Easy with Evolution Mail

Hello! I’m a lover of puzzles and currently subscribe to several fellow puzzle authors to get their puzzles from Patreon and other subscription methods. Recently, I set up some automation on my desktop Fedora Linux box to more easily grab those puzzles out of my email inbox, queue them up for me to solve later on my iPad, and move them out of my inbox to leave fewer items to attend to when tackling it.

See Github Gist at https://l.puz.fun/email for the code and the filter details.

The basic setup is this:

  1. Set up your email in Evolution.
  2. Create a Bash script to use as your Evolution helper. Mine looks like this:
cd "$(dirname "$0")"
cat | perl email_parse.pl &>> crud.log
sort -u -o "./Online Puzzles.html" "./Online Puzzles.html"

It pretty simply feeds the email contents passed in by Evolution to the second script, email_parse.pl. Afterward it sorts and de-duplicates an html file – more on that later.
3. The Perl script digs through each email looking for a number of things:
a. Are there any pdf or docx documents or jpz puzzle files hosted by Patreon linked from the email body? If so, download them but use the link text as the name since they all are served as 1.(extension)
b. Are there any links that match a regex that looks for common online solving apps? If so, throw those into a file as links. Sometimes the URLs match twice, so later on the bash script will sort and de-dupe these from the output file.
c. Are there any links that look like PDF download links and are not from Patreon? If so, download them and leave the filename alone, it’s probably fine.
d. Are there any URLs for Google Drive shares? If so, grab the ID from the link and use it to hit the download URL and request the file. Use that ID as the filename since otherwise it’ll be something weird.
4. Set up the filters in Evolution! A lot of these look similar to parsing done within the Perl script, especially the online solver regex links, but that’s because I tell the filters to not only run the helper script, but also to mark those emails as read and archive them.
5. Everything is aimed to download and save into Dropbox. When I get to my iPad and am ready to solve, I can open my To-Solve folder and drag or export the PDFs into Notability to solve, or open the html file and play an online puzzle as desired.

That’s it! It’s a bit of a hodge podge, but might be useful for other Linux or Mac users or folks using Evolution mail. Theoretically it can be tweaked to match Patreon downloads for any number of other extensions as well, although I admit sometimes it’s overzealous and grabs PDFs of newsletters and stuff that aren’t really puzzles. I wrote it as a way to avoid paying for Zapier’s advanced features and learned a bit in the process and hope it’s useful to others.

I’d love feedback on ways to improve this, if folks have other ideas for enhancements, or how else this could be used.

1 Like