Posting logged movies from Letterboxd to Mastodon

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.ServiceFreeReview FilterPipeline
1IFTTTYesNoRSS -> Webhook -> Mastodon
2IFTTTNoYesRSS -> Filter code -> Webhook -> Mastodon
3ZapierNoYesRSS -> Webhook -> Mastodon
4Zapier + MoaNo (in the future)YesRSS -> Twitter -> Mastodon
5PipedreamYesYesRSS -> Code -> Webhook -> Mastodon
  1. 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.
  2. A paid feature Filter code can run JavaScript code and select the review.
  3. 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.
  4. 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.
  5. 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.)

  1. Navigate to Preferences > Development and create a new application.
  2. Give it a name. For example, IFTTT.
  3. Provide the URL. For example, https://ifttt.com.
  4. Uncheck all scopes except for write:statuses.
  5. Copy your access token at the top.
  6. Save.

Create a Pipedream workflow to post to Mastodon

  1. Create a new workflow.
  2. Select New Item in Feed as the trigger.
  3. Set the feed URL as your RSS feed, e.g., https://letterboxd.com/USERNAME/rss/.
  4. Add a new block, and select Python.
  5. 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())
  1. Add another block, and select Send POST request.
  2. In the configure section, set the POST URL to https://YOUR_MASTODON_INSTANCE/api/v1/statuses?access_token=YOUR_ACCESS_TOKEN.
  3. In the body tab, set the Content-Type to multipart/form-data.
  4. 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}}
  1. (Optional) Add other parameters, like visibility: public. Check the Mastodon doc for more choices.
  2. Test the workflow. If it works as expected, deploy the workflow.


Leave a comment

Design a site like this with WordPress.com
Get started