Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: Set per-feed update/expire intervals in Safari RSS Web Browsers
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.
    •    
  • Currently 1.67 / 5
  You rated: 2 / 5 (9 votes cast)
 
[10,961 views]  

10.5: Set per-feed update/expire intervals in Safari RSS | 3 comments | Create New Account
Click here to return to the '10.5: Set per-feed update/expire intervals in Safari RSS' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Set per-feed update/expire intervals in Safari RSS
Authored by: asmeurer on Jan 15, '08 02:09:34PM

PubSub, huh? That would explain why Safari "knows" when I read my RSS feeds in Mail.



[ Reply to This | # ]
10.5: Set per-feed update/expire intervals in Safari RSS
Authored by: fungus on Jan 17, '08 12:51:03PM

Your SQL query need not be that complicated, unless you want a different refresh rate per Feed and per Client. Most people would be fine with a per Feed refresh interval.

Update Subscriptions SET refreshInterval = 43200 WHERE feed = ( SELECT rowID FROM Feeds WHERE url LIKE '%macosxhints%' );

[ Reply to This | # ]
10.5: Set per-feed update/expire intervals in Safari RSS
Authored by: t0fukrunch on Mar 02, '08 11:17:20PM
I was looking for a way to set Mail.app's default refresh interval. It appears this information is also stored in the Subscriptions table. Here is an excerpt from mine:

rowID|client|feed|refreshInterval|expirationInterval|expirationDate|refreshesInBackground|downloadsEnclosures|maxEnclosureSize|enclosureTypesString|unreadCount
...
82|1|81|-1.0|0.0|224917200.0|1|0|0.0||0
299|2|0|1800.0|1209600.0|224917200.0|0|0|8388608.0||0
301|3|0|604800.0|-1.0|214027200.0|1|0|8388608.0||0
...

which was produced by the command: select * from subscriptions;. Note the entries with rowID=299,301, which have feed=0. I believe these entries store the default settings for the corresponding client. So since row 299 has client=2, it corresponds to Mail.app. I verified this by changing the refresh interval in Mail.app, which changed the refreshInterval for row 299 from 1800.0 (i.e. 30 minutes) to the modified value. I wanted a refresh interval of 10 minutes, so I executed:

update subscriptions set refreshInterval=600 where client=2 and feed=0;

As the original poster mentioned, the proper way to do this is through the API. It's actually pretty easy to get and set the refreshInterval for a client with a few lines of code, but this is useful for those of us that want a quick hack.



[ Reply to This | # ]