10.5: Set per-feed update/expire intervals in Safari RSS

Jan 15, '08 07:30:00AM

Contributed by: wjv

Compared to dedicated feed readers, one of the major disadvantages of Safari RSS has always been the lack of an ability to set update intervals or article expiry intervals/times on a per-feed basis. Setting your global update interval in Safari to 30 minutes might be appropriate for high-volume feeds, but it places an undue burden on sites like Mac OS X Hints which are only updated once a day.

In Leopard, RSS reading functionality is no longer built into the Safari application itself. There is a system-wide RSS framework called PubSub (Publication Subscription) to which various applications (Safari, Mail, even Xcode) are subscribed as clients. This has a number of advantages. An application called PubSubAgent runs in the background and updates feeds even when client reader applications are not running and (of course) feeds to which multiple applications are subscribed are updated only once. Crucially, the PubSub framework does allow per-feed configuration settings which override the more generic per-client settings.

There is an API to PubSub which is extensively documented in the ADC Reference Library. However, PubSub stores per-user settings in a SQLite database located at ~/Library/PubSub/Database/Database.sqlite3. Since SQLite is ACID-compliant, one should be able to edit this database while PubSubAgent is running without too much fear of corrupting data. (Still, it's probably wide to back up the database before starting!) To access the database, one can use the command-line sqlite3 tool which ships with OS X, or any of the available graphical SQLite interfaces. You will of course also need some basic SQL skills, which are well beyond the scope of this hint.

The configuration database contains, amongst others, the tables Feeds (a list of RSS feeds), Clients (the "client" reader applications) and Subscriptions. An entry (row) in Subscriptions represents a specific subscription of a specific reader application to a specific RSS feed. The columns in Subscriptions containing the values we'd like to change are refreshInterval, as well as expirationInterval and/or expirationDate.

An example: To set Safari's refresh interval for the Mac OS X Hints RSS feed to 12 hours (43200 seconds), execute the following command:

UPDATE Subscriptions SET refreshInterval = 43200 WHERE rowID = (
  SELECT S.rowID FROM Feeds F
    JOIN Subscriptions S ON (F.rowID = S.feed)
    JOIN Clients C ON (S.client = C.rowID)
  WHERE C.signature = 'com.apple.Safari'
    AND F.url LIKE '%macosxhints%'
);
Simple enough if SQL is part of your day job, though maybe a bit arcane for the average user. I'm sure it would be possible to come up with a graphical front-end to the PubSub configuration database in short order, if one had more GUI programming skills (and free time!) than I.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080111012811265