Beer Log into Day One

I recently started using Day One on a daily basis. I’d had it for quite a while, but never found much personal use for it. What changed that was realizing that Day One could set the time stamp and location of an entry to that of a photo’s that you add. Giving context to random photos I have in my camera roll is brilliant. I now use Day One for various things. When I first saw Brett Terpstra’s slogger, it made me realize that I wanted to put the beers I drink into Day One. Easier said than done. Someone created a script for Untappd for slogger, but it never worked for me. The only way I could do it was using slogger’s RSS script along with my unique Untappd RSS feed. It worked, but there was so much extra crap in each entry (excess wording, URL, etc.) that the entries were just too ugly to use for this purpose. So though I really wanted this functionality, I put it on the back burner until I could find a better way.

Enter Craig Eley’s Sifttter. Sifttter, like slogger, will get information into Day One, but as you might guess from the name, it works off of IFTTT and Dropbox. This gave me a new angle on my goal, partly because Sifttter uses text files in Dropbox as a sort of middleman. What this means is that if I could get my Untappd RSS feed into a text file before importing into Day One, I could clean up the entries to how I want before they showed up in Day One. And it works great.

Here’s how I do it. Your mileage may vary, especially since I’m using this for a single case; only Untappd checkins.  Plus, as a unix sysadmin, some of the tools, such as sed and crontab, make most sense to me. I do admit that some of this may seem like a Rube Goldberg way of doing things, but in the end I got what I wanted.

Tools

Untappd

IFTTT

Dropbox

sed

crontab

Sifttter

Day One

Method

First thing is to get my beers out of Untappd.  Fortunately, Untappd gives you a private RSS feed for all of your checkins.  This allows me to feed it into IFTTT and output it to a flat file in Dropbox. The Feed URL in the screenshot below is shortened; you would get your own Untappd Feed URL from your Beer History page.

Screen Shot 2014 01 10 at 15 23 22

The checkins arrive in relative real-time to the Dropbox file. At the very end of the day I have crontab run a couple of scripts to act on the file.  I know that crontab is not recommended for OS X, but since I’m very familiar with it, I much prefer to use that over something like launchd with silly XML files.

57 23 * * * /usr/local/bin/sifttter.sh

sifttter.sh is a shell script to run some sedcommands to modify the RSS output to how I want it to look in Day One, then run the actual sifttter.rb script to import into Day One.

sed -i '' -E -e 's/Ken\ W\.\ is\ drinking\ (a|an)\ //g'
 /Users/your_username/Dropbox/Apps/IFTTT/sifttter/*.txt
sed -i '' -e 's/\*//g' /Users/your_username/Dropbox/Apps/IFTTT/sifttter/*.txt
sed -i '' -e 's/PM\ \-\ /PM\ \-\ \*\*/g'
 /Users/your_username/Dropbox/Apps/IFTTT/sifttter/*.txt
sed -i '' -e 's/\ by/\*\*\ by/g'
 /Users/your_username/Dropbox/Apps/IFTTT/sifttter/*.txt
sed -i '' -e 's/\ at/\ \@/2'
 /Users/your_username/Dropbox/Apps/IFTTT/sifttter/*.txt
mv /Users/your_username/Dropbox/Apps/IFTTT/sifttter/beer.txt
 /Users/your_username/Dropbox/Apps/IFTTT/sifttter/Today\'s\ Beer.txt
sleep 10
/usr/local/bin/sifttter.rb
sleep 10
mv /Users/your_username/Dropbox/Apps/IFTTT/sifttter/Today\'s\ Beer.txt
 /Users/your_username/Dropbox/Apps/IFTTT/sifttter/beer.txt

(Any lines beginning with a space are continued from the line above it.  If I didn’t do this for this post, it would look pretty bad.)

The first bunch of commands is to add some nice formatting for Day One.  What I want is simply the beer name, brewery, and location, if any, I drank it at.  The RSS entries from Untappd will prefix these with, “Ken W. is drinking a “.  For my own personal journal, I of course don’t want this.  I know who I am.  So I strip that out.  I then just bold the beer name and change the “at” before the location  to “@“, for better readability.

The rest of the sed silliness is because Day One does not yet parse markdown in the list of entries, and the way file names get changed from IFTTT to Dropbox.  “Today’s Beer” looks nice and easy to pick out in the list view of Day One, so I went out of my way to get that working for the file name.  It would get changed to “today_s_beer” in Dropbox, which would look terrible.  So I let IFTTT and Dropbox use “beer.txt” and use sed to rename it for the Day One import, then back to beer.txt.

The changes I made to sifttter.rb were to change the ‘entrytext’ value (line 83) to ‘ “” ’ (that’s simply two double quotes), to eliminate the title line since I’m only using this for my beer(s) of the day. The other change I made was to the Tag value on line 43 to ‘Beer’, since I tag any beer-related entries in Day One with a ‘Beer’ tag.

For those familiar with the GNU version of sed, the extra ‘-e’ part is because OS X’s BSD version doesn’t allow inline editing like the GNU version does. All of this will perfectly trim every checkin line to how I want it.

Then ‘sifttter.rb’ imports those entries into Day One.

Here’s my end result.  I think it’s worth it.

Day One entry

If anyone finds this interesting enough to try and runs into any problems, please feel free to contact me in any of the ways in the Contact section at the top right and I will help as much as I can.

Advertisements

2 thoughts on “Beer Log into Day One

  1. Pingback: Updates to ‘Beer Log into Day One’ Post | Not Miller Time

  2. Pingback: Day One 2 | Not Miller Time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s