The Arlo security camera by Netgear is one of the few cameras that doesn’t need a power supply, so is easier to use outdoors. The cameras have motion-sensing integrated and upload a short video sequence around the motion event to the Netgear backend. Great about the Arlo ecosystem is that this is possible with the free plan as well; you can access the recordings of the last 7 days already with the free basic plan.
For my use case, I wanted to also take periodic pictures / recordings. These can then later be stitched together for a time-lapse.
Automating Arlo Recordings
Getting the cameras to periodically record a video (e.g., 10 seconds) is easy. I used the If-This-Then-That Service (IFTTT) for this, which allows creating the necessary connections from a browser and is free to use.
This is a screenshot of the applet that I’ve created. The trigger is time-based and fires every hour at :00. The action is that the Arlo camera starts recording for 10 seconds.
This applet already works perfectly fine. Every hour, your camera will create a short 10s clip that you can watch online in the Arlo web interface / app. Arlo also allows you to download the clip. However, downloading is not possible through the currently available IFTTT actions.
To fully integrate Arlo cameras into the scenario, there has to be a way to automatically download the videos. Even though IFTTT doesn’t support it, several Python scripts enable downloading videos from Arlo. One of the more powerful scripts is on GitHub (Apache license), made by Jeffrey D Walter.
As I’m setting up a new system, I wanted to go with the latest version of Python – in this case Python 3 for Windows, 64 bit.
However, the script was written for Python 2. Between these versions, there have been some breaking changes that don’t make the source compatible anymore. Fortunately, migration is rather straight-forward.
The first task is to automatically upgrade the script from Python 2 to 3. Python provides the
2to3 script for it. With the following command, most of the changes are handled automatically:
python C:\Python\Tools\scripts\2to3.py -w .\Arlo.py
Some libraries are not included in the default Python installation and need to be added. This is done through the
pip library manager, which is also part of the standard Python installation. We need to add the following two modules:
Setting Up Video Download
Next up is to get the script to actually download the videos. In the readme file of Jeff’s GitHub repository, you can find sample code that does exactly what we need: it downloads all the currently available videos as mp4 files.
Warning: the script also calls
BatchDeleteRecordings() , which deletes all the videos from the Arlo cloud after it has downloaded them. If you want to keep them online (especially for testing), comment out that line.
After entering the username and password in the script, there is still an issue that the automatic code conversion of Python didn’t fix: the
write() function is now stricter about data types and doesn’t convert between byte arrays and strings implicitly. Thanks to StackOverflow, the solution was easy to find. Line 37 has to be changed from:
Great news – the download already works and downloads all available videos! In the basic/free plan, that are all the videos from the previous 7 days.
Tweaking the Download
Right now, the downloaded file name corresponds to the Unix Timestamp in Miliseconds. That’s a bit difficult to track as a human being. I therefore changed the setup so that the script is intended to run once per day, and downloads all the videos from that day; the filename includes the date and time (plus the unique ID from the Arlo backend to prevent overlaps, in case two cameras record at the same time):
For converting the Unix timestamp to a human-readable format in Python, you need the
datetime module. The conversion function then expects the timestamp in seconds, whereas Arlo gives us the timestamp in miliseconds. Coversion is easy –
// 1000 is an integer division in Python.
videofilename = datetime.datetime.fromtimestamp(int(recording['name'])//1000).strftime('%Y-%m-%d %H-%M-%S') + ' ' + recording['uniqueId']
Changing to download only today’s files
That’s easy to do – in Line 19, change the parameters to:
library = arlo.GetLibrary(today, today)
The original script doesn’t logout from the Arlo service, even though it’d be supported by the API. Therefore, at the end of the script, I also added:
The complete script with all the changes applied (including the port from Python 2 to 3) is available from my forked GitHub repo: https://github.com/andijakl/arlo
Now the script is running perfectly fine on Windows. To keep this running automatically as a task, it’d make more sense to put it on a Raspberry Pi and to schedule execution of the script to run it once per day. That’ll be the next step!