I’ve grown to loath IFTTT. What started out as a cool way to plug internet things together has being an opaque an uncommunicative company with no real interest in customer service. That’s not surprising, I suppose, its paying customers are the companies who can’t be bothered to develop a proper API and so just shove some integrations up there.
But it is annoying for those of us who want something simple – like debug logs or notifications when scripts fail. Or something complex like conditional processing. Or even just a human to talk to when things break.
So, sod the lot of them. I’m slowing replacing my IFTTT “applets” with my own home-brew. Starting with…
RSS & Tumblr
I have a IFTTT recipe which
- Reads an RSS feed
- If there is a new item, queue it to Tumblr
Simple! And yet IFTTT randomly fails. It either can’t read the RSS, or it doesn’t spot new items, or it duplicates all my posts. Oh, and there’s no way to set queued posts to automatically Tweet. It basically seems that IFTTT’s MVP is certainly minimal, but sadly unviable.
This is a Python script which can be run as often as you like. It reads RSS, checks for new items, queues them, and sets Tweet text. NB – no Python 3 support yet because Tumblr can’t be bothered to update their libraries.
import pytumblr import feedparser import sys id_file = "id_file" # Authenticate via OAuth tumblr = pytumblr.TumblrRestClient( 'AAAAA', 'BBBBB', 'CCCCC', 'DDDDD' ) feed = feedparser.parse('https://EXAMPLE.COM/FEED.RSS') # Read the last id with open(id_file,'r') as file_: last_id = file_.read().strip() most_recent_id = feed['entries']['id'] if (last_id == most_recent_id): # Do nothing sys.exit() else: # Save the new ID for later with open(id_file, 'w') as file_: file_.write(most_recent_id) # Loop through the posts for post in feed['entries']: # If the post has been encountered before, time to end things. if (last_id == post["id"]): sys.exit() else: # Queue it on Tumblr tumblr.create_text( "YOUR-TUMBLR-NAME", state="queue", title=post["title"].encode("utf-8"), format="html", body=post["summary"].encode("utf-8") )
I have a crontab set up to run this a few times per day. By default, IFTTT seems to check every hour.
- You will need a file called
id_fileto store the latest ID of the RSS feed.
- If your RSS feed doesn’t have unique IDs, this may not work.
- This isn’t exactly a robust, error-proof solution – but then, neither is IFTTT.