Brian C. Lane
Brian C. Lane
Saving the state for Home Media Server

Home Media Server is a Roku application for streaming video from a http server. I started the project in 2009 after Roku released the SDK for their devices. Originally it was a server and a client, but I rewrote it in 2010 as just a client so that the only external dependency was a http server that could handle partial file requests.

In 2013 I rewrote the client to use the gridScreen layout which lets you display more content at the same time and makes it easier to split things into categories. Currently it only supports video streaming, I never have gotten around to adding audio support or photo albums like I had originally planned.


One thing that has been missing has been the ability to save the state between reboots of the app. When you exit from the app the contents of the tmp:/ filesystem are recycled so it would only save the last played position until you left the app. This results in feedback from family members, and since I’m the one who wrote it the usual response of "well I didn’t write it" doesn’t fly. Roku’s Netflix app is where this response is often used — its ability to anticipate the selection of a movie and then to totally refresh the interface is uncanny.

Instead of going back to a client/server model I decided to add an optional service to use for storing arbitrary key/value pairs. I called it clortho and wrote about deploying it in this blog post. HMS will still run without it, but with clortho installed it will now remember the last played selection in each of the categories and the last played position for each video.

Your webserver will need to proxy requests for the /keystore/ path to the clortho service. I’m using lighttpd myself, so my configuration file now looks like this:

    $HTTP["host"] =~ "^movies\.home$" {
        server.document-root = "/Movies/"
        dir-listing.activate = "enable"

        $HTTP["url"] =~ "(^/keystore/)" {
            proxy.debug = 1
            proxy.balance = "fair"
            proxy.server = ( "" =>
                               (( "host" => "", "port" => 9001))

This points requests to the directory /Movies, generating a listing for them so that HMS can interpret it. And requests for /keystore/ go to the clortho service running on localhost.

At startup HMS will try to request /keystore/version to see if the service is active. If it gets a status code of 200 it will use the keystore, if not it will only save things to the tmp:/ filesystem as before.

With all of that in place HMS is easier to use. Not having to scroll through all the episodes trying to remember the last one you watched is really nice. I also made HMS auto-advance to the next episode when the current one has been played in full — which means we now have to un-learn the habit of advancing to the next one.

Setup oath ssh login on Fedora

There are occasions where I’d like to be able to ssh to a system without using the password or having to setup a ssh key. Another alternative for authentication is the pam_oath module which allows you to use OATH applications like FreeOTP or Google Authenticator for 2-factor logins. Start …

Read More
Deploying clortho with ansible and venv

I have started using Ansible to manage the few services that I still have running around here. I want to deploy clortho to a user on the system I use for serving up movies to my Roku players. I need to copy the source, setup a venv with the dependencies …

Read More
clortho - A simple key/value server

clortho is a very simple key/value server written using python 3.4 and aiohttp key namespace is per-client IP address, and there is no authentication. It supports direct connections from clients, and the X-Forwarded-For header for use with proxies. I shouldn’t have to mention that running this on …

Read More
https is now the default protocol

On June 5th the EFF called for people to Reset the Net and do something to enhance their privacy on the net. I have put off switching to https for my sites because I host them using S3 and CloudFront, and up until recently it was extremely expensive to use …

Read More
Automatic Backup of Files to S3 and Glacier

Automatic backups are important, especially when it comes to irreplaceable data like family photos. I have used s3cmd to maintain my website’s static files for a while now, and it was simple to use it to push my 100GB+ archive of photos over to S3. But I needed an …

Read More
Chat with Tor and socat

It is easy to setup a simple chat over Tor using the socat utility. To receive incoming messages you first need to setup a Tor hidden service. Add this to the end of your /etc/tor/torrc file: HiddenServiceDir /var/lib/tor/hidden-chat/ HiddenServicePort 2330 …

Read More

Receive Updates