It’s wonderful to share movie hot takes with others, better automatically. This is a walk-through for setting up a Pipedream workflow to automatically post newly logged movies from Letterboxd to Mastodon. Letterboxd is a nice social network for sharing movie reviews and keeping track of what you’ve watched.
The best part is that Letterboxd provides an RSS feed of a user’s logged movies.
This means we can follow a user easily without a Letterboxd account, or connect it to social networks like Mastodon with the help of automation tools.
With Mastodon’s powerful APIs, including the ability to post statuses via webhook, you can seamlessly connect Letterboxd and Mastodon accounts and keep friends on Mastodon up to date with your movie musings.
Motivation
There are several automation online services, with different feature sets, prices, and customization levels.
No. | Service | Free | Review Filter | Pipeline |
---|---|---|---|---|
1 | IFTTT | Yes | No | RSS -> Webhook -> Mastodon |
2 | IFTTT | No | Yes | RSS -> Filter code -> Webhook -> Mastodon |
3 | Zapier | No | Yes | RSS -> Webhook -> Mastodon |
4 | Zapier + Moa | No (in the future) | Yes | RSS -> Twitter -> Mastodon |
5 | Pipedream | Yes | Yes | RSS -> Code -> Webhook -> Mastodon |
- IFTTT is a simple tool to achieve the basic function: posting the movie title (including the rating out of 5 stars) and the link to the user’s review page. But for a Letterboxd review, my goal is to directly post the review content in a Mastodon toot. The review is in the
description
section of the RSS entry, but the raw content of this entry is an HTML snippet with multiple<p>
and<img>
tags which would mess up a toot. - A paid feature Filter code can run JavaScript code and select the review.
- Zapier provides a built-in selection of texts from the raw HTML content, but the webhook integration is a premium feature behind a $20/m subscription plan.
- My workaround was using Zapier to post the review to Twitter which is free, then using another Twitter <-> Mastodon sync service Moa to cross-post the tweet to Mastodon. Due to the recent changes in Twitter API, Zapier would change the Twitter integration to a premium feature.
- Pipedream is a Zapier-like automation service that provides webhook integration and code execution in the free plan. I just switched to this setup and found it easy to use and powerful.
Pipedream Deployment
Create a Mastodon application
(By the courtesy of Jesse Squires’s blog post Publishing an RSS feed to Mastodon.)
- Navigate to Preferences > Development and create a new application.
- Give it a name. For example, IFTTT.
- Provide the URL. For example, https://ifttt.com.
- Uncheck all scopes except for
write:statuses
. - Copy your access token at the top.
- Save.
Create a Pipedream workflow to post to Mastodon
- Create a new workflow.
- Select
New Item in Feed
as the trigger. - Set the feed URL as your RSS feed, e.g.,
https://letterboxd.com/USERNAME/rss/
. - Add a new block, and select
Python
. - Use the following code in the
code
section to filter the review.
from bs4 import BeautifulSoup
from pipedream.script_helpers import (steps, export)
# Parse the description with BeautifulSoup
soup = BeautifulSoup(steps["trigger"]["event"]["description"], 'html.parser')
# Find all img tags and remove them
for img in soup.find_all('img'):
img.extract()
export('review', soup.get_text().strip())
- Add another block, and select
Send POST request
. - In the
configure
section, set the POST URL tohttps://YOUR_MASTODON_INSTANCE/api/v1/statuses?access_token=YOUR_ACCESS_TOKEN
. - In the
body
tab, set the Content-Type tomultipart/form-data
. - Add a new entry with the name as
status
and the value as the formatted post you like, e.g.,
Watched {{steps.trigger.event.title}} on {{steps.trigger.event["letterboxd:watcheddate"]["#"]}}.
{{steps.code.review}}
{{steps.trigger.event.link}}
- (Optional) Add other parameters, like
visibility: public
. Check the Mastodon doc for more choices. - Test the workflow. If it works as expected, deploy the workflow.
Leave a comment