Newseum archives the front pages of of over 500 newspapers from all around the world. If you know the ID of the papers you want to see you can use this simple Python program to download the jpg of the papers’ front page to your local system.

Edit the CITIES list to set the IDs of the papers to be grabbed.

#!/usr/bin/env python
"""
    Quick Newseum Frontpage Grabber script
    Copyright 2009 by Brian C. Lane
    Imp Software
    All Rights Reserved

    Modify CITIES list below to add the city designators (as seen in the
    URLS at http://www.newseum.org/todaysfrontpages/default.asp)
"""
import urllib2
import re
import os
import urlparse

# Add more cities here
CITIES = [ "AL_AS", "AL_MA",   ]

NEWSEUM_URL="http://www.newseum.org/todaysfrontpages/hr.asp?fpVname=%s"
NEWSEUM_IMG="http://www.newseum.org"

def fetchNewseumImage(city):
    """
    Fetch the image for a city
    """
    print "Parsing the page for %s" % (city)
    page = urllib2.urlopen(NEWSEUM_URL % city).read()

    # Quick and dirty grep for the image name
    match = re.search('<img class="tfp_lrg_img" src="(.*)" alt=', page)
    if match:
        img_url = NEWSEUM_IMG + os.path.abspath(match.group(1))
        print "Saving the image for %s" % (city)
        image = urllib2.urlopen(img_url).read()
        open(os.path.basename(match.group(1)), "wb").write(image)

def main():
    """
    Main code goes here
    """
    for city in CITIES:
        fetchNewseumImage(city)

if __name__ == '__main__':
    main()

The source is also hosted here at github.

Much to my surprise my 2 new iPhone apps were approved today. This must be a new record for the App Revew process — according to the history the American Le Mans Series (ALMS) Countdown app started review at 11:26 AM and was approved at 15:08 (3h42m), the NASCAR Countdown version took slightly longer, from 9:23 to 16:42 (7h19m).
I suppose the fact that these are dead-simple apps with only 2 views may have had something to do with the fast turn around. But with the first NASCAR race of the season only 3 days away I’m pretty happy!

NASCAR

American Le Mans Series

I have made an iPhone version of my NASCAR Countdown Widget and sumbitted it to the App Store.

The NASCAR Countdown app displays a countdown to the next race, the name of the race and the television network carrying the race. On the flip side all of the races for the 2010 season are listed, and tapping on one of them will go to the nascar.com website for that track.

27th Jan, 2010

WZON T-Shirts

I’m not sure what made me think of these today, but I did a couple of Google searches to see if I could track down any more of these shirts. The only one I could find is the Creep shirt. There seems to be a lack of info on them on the web, so I’m going to help fix that.

Stephen King owns a couple of radio stations in Maine, one is WZON and back in the mid 80’s the Stephen King newsletter had advertisements for these t-shirts. As a loyal constant reader it was my duty to buy them, and I think these were the only ones offered. I wore these in rotation with my Bloom County t-shirts all through high school. They’re a little worn, but really in much better shape than some of the shirts I have from places like Cafe Press.

WZON Creep shirt

WZON Creep T-Shirt Back

WZON Skull Front

WZON Skull Back

I have just updated my NASCAR Dashboard Widget for the 2010 season. All race time and channels should now be current.

I’m working on an application to manage my streaming media for my Roku player using sqlite3 and Python for everything. One thing I’ve learned over the years is that your SQL schema always changes. Once your code is in production you always have something you need to change about it, whether it’s adding a new column, changing a type or tables to support new features. I wanted a way to automatically update the database schema when a new version of the code is installed. I don’t want to jump into the complexity of using SQLAlchemy and migrate so I came up with this simple method. The database has a table named schema with a single row with the current schema version in it. This class checks the current version and executes any missing commands, bringing it up to the latest version.

class DbSchema(object):
    """
    Database schema creation and modification
    """

    # Schema revisions, rev[0], etc. is a list of SQL operations to run to
    # bring the database up to date.
    sql = ["""  create table users(id INTEGER PRIMARY KEY, username UNIQUE, password, email);
                create table sources(id INTEGER PRIMARY KEY, name, type, path UNIQUE);

                create table schema(version);
                insert into schema(version) values(1);
            """,
            # Add default values
            """ insert into users(username, password) values("admin","badpassword");

                update schema set version=2;
            """,
            # Add media table
            """ create table media(
                    id INTEGER PRIMARY KEY,
                    name,
                    path
                );

                update schema set version=3;
            """,
        ]

    def __init__(self, database):
        self.database = database

    def upgrade(self):
        """
        Upgrade the database to the current schema version
        """
        # Get the current schema version number
        conn = sqlite3.connect(self.database)
        conn.row_factory = sqlite3.Row
        cur = conn.cursor()
        try:
            cur.execute("select version from schema")
            version = cur.fetchone()['version']
        except:
            version = 0

        if len(self.sql) > version:
            for update in self.sql[version:]:
                cur.executescript(update)
        cur.close()
        conn.close()

Initialize it with the path to your database, and then call the upgrade() method on it.

    schema = DbSchema("./library.db")
    schema.upgrade()

Add new tables, changes to old tables, default data, etc. to new strings in the sql list. Make sure to update the schema table’s version as the last step for each revision. As long as you only make database changes via this class you will ensure that the tables are ready for your new code when each new revision is released.

This version is being used with sqlite3, but works just as well with mysql or postgresql.

27th Dec, 2009

Moved the blog home

I decided to move the blog from Wordpress hosting back to my own server. I want to be able to run my own Google Ads on the system and Wordpress doesn’t allow that.

I used the Export/Import feature of Wordpress 2.9 and found that it misses a couple of things. It doesn’t transfer the theme over, the widets or the links. I had to handle all of them manually.

Otherwise the move has gone smoothly.

Ever since I switched from Dish Network to a Roku player a few months ago I have had a couple of things I wanted my player to be able to do. The ability to categorize my Netflix queue is at the top of my list and it would be very cool to be able to play video from a local server. The SDK won’t help me modify the Netflix application, but streaming from a local source is actually not a huge problem.

On Friday Roku finally released the SDK for their handy little Roku Video player (sometimes called a Netflix box since that was originally the only content you could stream). The SDK is free, all you have to do is signup at the developer page. The zip archive contains everything you need to get started hacking together a new channel for your Roku player.

For the most part development is cross platform. You are restricted to using their language, BrightScript, so there are no compilers or IDE needed. It helps if you have the make utility available on your system, the examples come with makefiles that will zip up the application and install it into your player with a single command. If you want nice images to show up while scanning through a video you will need to capture them from the file and create a BIF file to tell the player when to show the images. The biftool is currently only available on linux and Windows.

To be able to upload software to your player you need to enable developer mode. This is accomplished with a set of remote control keypresses. For some reason it took me about 10 tries before I got it to work. I’m still not sure if it depends on where you start from, but what finally worked for me was being at the top level channel menu with something other than settings selected.

Once that is done the box now has a simple server running on port 80 and a debug port on 8085 where you can view debug output from your app or from the system if the upload failed, or if parsing the script files failed. That’s all there is to it. No cumbersome app signing needed at this point. It makes it very easy to edit, upload, try, debug, repeat. If you want to actually publish your application as a new channel for the world to use the process is more involved and requires Roku to approve your application.

The SDK includes, among other things, a couple of video examples. One simply points to a URL and plays it (the URL is hard-coded into the application). The other is more fully featured and uses TED talk videos. It allows you to setup a hierarchy of categories using a couple of XML files. This is a good place to start for streaming local content.

The first thing I did was setup an Apache 2.2.13 server on my son’s Fedora11 system. I simply aliased the directory of mp4 videos and it was up and running. As a side note, Chrome (at least on OSX) can stream mp4 videos over http without installing anything else.

I then played around with the simple stream example to make sure I could actually watch the videos. They were encoded using Handbrake on either a OSX or Fedora system. Most are 1G in size or less, and I left most of the encode settings alone. I found that about the first hour streams fine, but after that point the player starts to rebuffer every minute or so. It appears to depend on the location in the file, so it may have something to do with how it was encoded.

The documentation included appears to be fairly complete. The have extensive documentation on BrightScript, and on the Roku extensions that you use to access to features of the player. I did find a couple of things that weren’t described in detail, but at this point that hasn’t hindered progress at all. BrightScript is a fairly simple language and anyone with programming experience should have no trouble catching on quickly.

The example video app uses a hard-coded URL for the source of the XML driving it. I added a keyboard page that prompts the user to enter the host or IP address of their video server. It saves this to the registry (persistent storage) so it only needs to be entered once. For the moment, this is really the only change I needed to make to the example application. Everything else happens on the server side.

I slapped together a Python script to take the names of my mp4 videos and generate the feed XML to drive the player. I used mp4info to pull the video’s bitrate and format from the file and insert into the movie’s description page. I don’t have cover art for them, so that got hard-coded to a default image. The script generates a static XML file for the Roku to load when my custom application is run.

At this point I can browse the movies and play them. Mostly. I’ve run into a couple of glitches, and am not sure exactly what the solution for them is yet. One is that it seems that at about the 1 hour point in the video playback it starts to rebuffer every minute or two. If I stop playback, restart and skip to the 1 hour marks it still happens, so it appears to depend on the point in the file, not the time spent playing.

The other is that the aspect ratio of many of the videos isn’t quite right. All of them seem to be squished to some degree or another. This is probably due to the Handbrake parameters I used when encoding them from the original DVDs. They look fine when played back on a PC but the Roku either isn’t properly sizing them, or I’m doing something wrong (more than likely).

Overall I am very happy with the Roku and the SDK. They have done an excellent job of documenting the system, providing example code and especially keeping it from turning into a brick. Several times I have managed to get it to lock up and reset itself. It has always come right back up with no problems. I am looking forward to seeing what other channels people come up with. On the top of the list for me is Hulu streaming, but I’ll leave that up to someone else to implement.

You can look at my code, for what its worth, at my bitbucket homevideo repository.

After many hoursminutes of redesign the new look of SharePics was ready to go. I re-packaged the app, captured new screenshots, and re-submitted it to the AppStore. 9 days later I received an email notifying me that my app was now available for sale in the App Store!

Thanks to everyone who offered advice and design ideas after the crushing rejection last month. I couldn’t have done it without you! Now you can easily share your pictures with your friends (note, you need an iPhone or iPod Touch with Bluetooth support and iPhone OS v3.0 or later).

So I got my first rejection from the App Store today. According to their email it was rejected because -

we cannot post your application because it  appears to include features that resemble Polariod photographs. Polaroid has previously objected to other applications that include features that resemble Polaroid photographs, and believes that such features infringe its rights.

Say what? Now, I’m the first to admit that my icon is a bit simple. But it seems like a reach for Polaroid to be able to claim that all black squares on white rectangles are infringing on their rights. And Apple did suggest that you use distinctive colors and a strong outline to promote user recognition.

Here are some other screenshots from the app:

Categories