1 minute read

I’ve been putting my movie reviews on Letterboxd for a while now, but haven’t felt like duplicating effort to also copy them to my personal site where I’ve been previously posting reviews for ages. Surely there’s a better way than copying and pasting for someone with the power of technology!

So I wrote a little ruby script to pull my RSS feed from Letterboxd and turn it into Jekyll posts that I can then just commit to the repo and push out to be auto-deployed.

At some point I may automate updating this with a Github Action, but for now this is good enough.

require 'net/http'
require 'rexml/document'
require 'fileutils'

url = URI("https://letterboxd.com/fehwalker/rss/")
response = Net::HTTP.get(url)

doc = REXML::Document.new(response)

output_dir = "movies/reviews/_posts"
FileUtils.mkdir_p(output_dir)

doc.elements.each("rss/channel/item") do |item|
  title = item.elements["letterboxd:filmTitle"].text
  filmyear = item.elements["letterboxd:filmYear"].text
  rating = item.elements["letterboxd:memberRating"].text
  date = item.elements['letterboxd:watchedDate'].text
  review = item.elements['description'].text.gsub(/0-600-0-900-crop/, "0-300-0-450-crop")
  link = item.elements['link'].text

  filename = "#{output_dir}/#{date}-#{title.downcase.gsub(/\s/, '-')}.md"
  File.open(filename, "w") do |file|
    file.puts "---"
    file.puts "layout: single"
    file.puts "classes: wide"
    file.puts "title: \"Movie review - #{title} (#{filmyear})\""
    file.puts "date: #{date}"
    file.puts "tags: [movies, reviews]"
    file.puts "---"
    file.puts ""
    file.puts "Automated copy of [my Letterboxd review for #{title} (#{filmyear})](#{link}){:target=\"_blank\"}\n\n"
    file.puts review
    file.puts "Rating: #{rating} out of 5."
  end
  puts "Saved #{filename}"
end
words for AI nail butler coal wreckage epidemiology spot dweller remission bounce downside singular remain research discharge crying eyeball juggle allegory sandwich placement