In the past, I've created a lot of bots. For example, I've already made a bot that gives people fines when they make grammatical errors. And another one that recommends a cheese when someone says say cheese.

Because it's almost Christmas, and I'm a fan of how horrible Home Alone is, I decided to build a bot honoring it.

It's not you. It's the API.

At the start of the 2000s, API's were very popular, and every site offered an easy way to extend its functionality. But times have changed. Twitter restricts it's API use nowadays. They don't allow posting tweets without approval from them. Instagram's API no longer exists and has been replaced by something aimed at smooth marketers and other scumbags. And Facebook? Well, no one likes to build stuff for boomers.

I chose Instagram as a platform for my Home Alone bot. Luckily, a Javascript package exists that does everything their now-defunct API did, and more: instagram-private-api.

Planing

My original idea was to post one frame of Home Alone every hour on Instagram. The film lasts 102 minutes. Times 24 frames would take 146880 hours or roughly 16 years.

Visually this would have looked beautiful on the account's profile page, but it felt too much. Besides, I already have trouble maintaining a project of one month. Maintaining something for 16 years would never succeed.

One post a day seemed like a good compromise, and each day I jump 5 seconds in time. Thus, the end should be reached by 2022.

Next up: How do people discover this account? The logical way on Instagram is to use tags. But which one?

Enter The Machine

Using the same tags every day (#homealone #daily #still) would be lazy. We live in a time where computers can flawlessly see what's in the picture. So that's what I did. Amazon offers an API that makes 1000 recognitions for only $1.

What Amazon recognizes in the photo is converted into hashtags and added to the caption.

The caption itself is determined by what the actors say in the subtitles at that timestamp. This way, you can follow along with the correct captions.

Ex-schoolmate Youri suggested on Linkedin to automatically tag the actors. Unfortunately, everyone from Home Alone has ended up either dead or in the gutter. But when Kevin or one of the other three actors with an Instagram account appear, they are automatically tagged. Once again, thanks to Amazon, this was no more than 10 minutes of work.

Keep on running

As I said, I have a hard time keeping these small projects up & running. The TheSoundOfGifs bot was running on a Raspberry Pi, and all went well until our cleaning lady pulled the plug, and the Pi crashed it's SD card.

A cheap server could've been the solution. But it's also a hassle, you have to remember to pay the bills, and servers can crash or be hacked. And even at a paltry EUR 3.5 a month, it would cost me 140 euros in the long run.

Time for a buzzword: serverless. The code of my bot does not run on a server that is on 24/24. It is booted once a day, does its thing for about ten seconds, and then shuts down again. No Linux stuff to worry about. It just keeps on running.

So, what does this cost? Exactly 0 euro per month for computing power (because Amazon gives half a million seconds per month free), 1 euro cent for storing all images, and 15 euro cents for machine learning. A total of 16 cents per month, or 6 euros throughout the project. Cheap!

Nerd business


The source code is on Github:

TimBroddin/dailyhomealone
Source code for the IG account @dailyhomealone. Serverless + machine learning magic. - TimBroddin/dailyhomealone

You generate the images like this (burn subtitles and one frame per 5 seconds):

ffmpeg -i HomeAlone.mkv -qscale:v 2 -filter:v "subtitles=Home\ Alone.mkv, fps=0.2" images/image%05d.jpg

Oh, by the way, welcome to my new site. I can't promise anything, but I'm going to try to put something like this regularly.

You can find the bot here: https://www.instagram.com/dailyhomealone.