TiVo’d tweets

OK, I realize that posts about Dr. Twoot aren’t especially useful or interesting to anyone other than me, but I need to finish off what I started two nights ago: a TiVo-like system for viewing my Twitter stream with a time delay.

My motivation is straightforward. I often record live TV shows like the Oscars or the Super Bowl and start watching them an hour or so later while the show is still recording. I fast forward through the commercials and boring parts and, if I’ve timed it right, reach the end of the recording at about the same time as the live show ends. Reading Twitter comments on the show is fun, but I don’t want to see tweets about things that are further along in the show than I am.

Enter the tweet delayer, a new feature in Dr. Twoot that filters out tweets that are more recent than a user-settable delay.

Dr. Twoot with delay

The user interface is kind of dull and ugly right now, but I wanted to get the delay working before I worried too much about how it looked.

Here’s how it works. When I launch Dr. Twoot, the delay is off. It grabs the 50 most recent tweets in my home_timeline and any mentions that came up within that span. The tweets are formatted and added to the window, but the more recent of them aren’t immediately visible because I haven’t scrolled to them. If I want to avoid seeing tweets that were, for example, sent in the last 60 minutes, I enter 60 in the delay field and refresh (⌘R). Dr. Twoot uses localStorage to keep track of the delay value across the refresh and redisplays the tweets, this time filtering out the ones posted in the last hour.

Every five minutes, Dr. Twoot updates to add tweets to the display, but these “new” tweets are always an hour old. So now I can watch the event via TiVo and read tweets about it without seeing spoilers.

And as I fast forward in TiVo to get closer to real time, I can adjust the delay value in Dr. Twoot to match. This time I don’t need to refresh—Dr. Twoot uses the new delay at the next update.

Even though it seems to be working, I’m sure the code that implements the localStorage is wrong in one or more ways; this is the first time I’ve used it, and I just jumped in. I’ve read enough about localStorage to recognize it’s usefulness, but I don’t really know its ins and outs yet. For example, I don’t understand why I can’t get the stored delay value when I first launch Dr. Twoot. Some experimentation and documentation review are in order (I promise to spare you the details of my iterative learning process).

The new code is in the GitHub repository, but because it’s still a little dicey, I have it in the tivo branch rather than the master branch. I’ll merge it in when I feel more confident about it.


4 Responses to “TiVo’d tweets”

  1. Danyal says:

    Good idea that. Maybe you could also have a mode where it searches everybody’s historical tweets, not making any assumptions about the start time. To keep you company as you’re watching a film you got from iTunes, etc.

    I humbly suggest the name TwiVo

  2. Dr. Drang says:

    TwiVo is the perfect name!

    Sadly, anything that relies on decent searching of Twitter is doomed to failure. Twitter refuses to find any tweet that’s more than a few days old..

  3. Joshua says:

    What are the advantages to using localStorage instead of a cookie? Is it just because it’s new and exciting, or something more?

  4. Dr. Drang says:

    There may be a small advantage in that localStorage has the getItem method, which makes retrieval of a particular value easier than it is with document.cookie. But frankly, Joshua, I choselocalStorage` because it was the first thing to pop into my head. I think I’d been reading an HTML5 article.

    The next time I work on Dr. Twoot, I’m going to try a document.cookie solution and see how it works.