As part of my move to simplify my hosting setup, I started experimenting with using Blot as a replacement for Tumblr to host my micro blog Slipstream. This is an amazing service which allows you to connect up a Dropbox folder, and then just throw files in that folder (Markdown, Plain text, images, and so on), and they will — apparently by magic — be turned into a nice looking website. It’s really fantastic. Since Dropbox folders are accessible to so many apps (both on the desktop and on iOS), this makes it really easy to post from anywhere, and also to automate cross posting. This is where Zapier comes in.
I signed up for Zapier quite a long time ago, but never really used it much and stayed on the free plan. When I went back recently to have a poke around, I found that they had improved a lot, and some very sophisticated processing pipelines are now possible. In fact, I could do everything I had been doing with Huginn, and more, because you can use it upload files to Dropbox and create new Dropbox files — perfect for Blot. The free plan limits you to two-step ‘Zaps’ (a Zap is a chain of processing commands), and my usage requires more than two-step Zaps, so I signed up for the lowest level paid plan. I’ve got so much use out of Zapier that I’m happy to do that, and also to support their development of the service going (unlike IFTTT, which has no visible means of support, so I worry about how long it might be around).
I’ve set up Zapier to monitor activity on a number of different services: my Letterboxd film reviews, my Goodreads reviews, Flickr photos, Instagram photos, and public Pinboard bookmarks. The Zap for each service then fetches the new content, does a bit of processing to pull out the information I need, and then creates a Markdown file in Dropbox with the format needed to create a Blot post.
The details for each service is a little different, but follows the same basic steps, so I’ll illustrate what is needed with the Letterboxd zap, which involves the most complexity.
The steps needed are as follows:
- Monitor the Letterboxd RSS file for my profile for new reviews.
- Format the filename I’ll use for the Blot Markdown file, based on the date of posting the review.
- Use a snippet of Python to extract the URL for the poster image from the review.
- Use this URL to download the poster image file to Dropbox, so I can serve it locally.
- Finally, create the Blot Markdown file using the information from previous steps.
Here’s an what this string of steps looks like in Zapier.
Step 1 is very simple — you just need to add the URL for the RSS feed, and that’s it. What’s useful about Zapier is that as you set up each step, it tests it by fetching the feed, and showing you the result of the latest post, so you know what fields you are dealing with.
This is an optional step, but I wanted an organised way of creating filenames based on the date of posting of the original file. So I used the Zapier Formatter step to format the publication date of the review in the feed (Step 1) and format it using a custom date format. Any of the fields found or created in previous steps are available to you in subsequent steps, and the formatted date created here will also be available in subsequent steps.
Since the RSS feed for Letterboxd contains the poster image for the film in the body of the review text, rather than as a separate field, I wanted to extract that URL. This would allow me to download the image to Dropbox to serve it locally, and would also give me more flexibility in formatting the Blot post.
What happens here is that I use a ‘Code’ step to save the ‘raw description’ field from the RSS (which contains my review text and the poster image) to a
body_text field of the
input dictionary. The Python snippet then searches this dictionary using a regular expression to find the image URL, and saves this as the
film_image_url variable, which will be available in subsequent steps1.
Now I upload that file to Dropbox, using a Dropbox file step. I fetch the file from the URL I’ve just extracted, and save the file to my
_images/ folder inside my Blot folder, and use the
ID field (which I think is unique) to save the filename. We’re nearly there!
Finally I use the information I’ve gathered together to put the Blot file together, including the frontmatter I’ve decided to use. The filename is up to you, but I decided to use the publication date of the review, with
file prepended so I can easily distinguish the actual files in my Dropbox (book reviews get
book prepended, and so on). At the moment, I’m not using the
Type: metadata, but they are available to be used in Blot layouts, and I decided that I would future-proof the files so that I could always migrate them to another service (or even host them using Hugo), with a bit of munging of the front matter.
And that’s it: the Zap watches for new items in the feed, and then automatically saves both the image file and the Blot post file in the right folders, where Blot magic happens, and the post appears on Slipstream. I could even add another step to inform me that this had happened, but it’s so quick, there’s really no need.
- Also, look at me, using ‘advanced triggers’! ↩