Subscribe to
Posts
Comments
NSLog(); Header Image

NNW ASS?

Is NetNewsWire AppleScript Stupid? Rather, am I? I'm trying to do something very simple: compile a list of blogs that have not been updated in the past x days (so that I can delete them from my subscriptions list).

set oldies to {}
set cutoffDate to ( (current date) - (15 * days) )

So far so good. Then all hell breaks loose.

tell application "NetNewsWire"
    repeat with thisSub in every subscription
        tell thisSub
            set subModDate to last update time
            log subModDate
        end tell
    end repeat
end tell

What am I told? The variable subModDate is not defined. The subModDate after "log" is selected. The same happens with:

tell application "NetNewsWire"
    repeat with thisSub in every subscription
        set subModDate to thisSub's last update time
        log subModDate
    end repeat
end tell

Don't worry, it gets worse. You see, even if I could get the "last update time" it is somehow not actually the last update time. Or it may be, but given that every one of my subscriptions "last updated" today or yesterday, I'm not buying it - some haven't been touched in weeks. Instead, I seem to be given a time that's suspiciously close to the "last check time." From NNW's dictionary:

last update time date [r/o] -- The last time the source had new headlines
last check time date [r/o] -- The last time the subscription was checked for new headlines.

Hogwash, I think. Of course, the documentation also lists this:

lastModified header anything [r/o] -- The last last-modified header returned by the server.

There might be hope there, but very very few of my subscriptions seem to include this lastModified header, making it useless.

Next I attempt this:

tell application "NetNewsWire"
    set counter to count of every subscription
    repeat with i from 1 to counter
        get date published of (item i of every subscription)'s first headline
    end repeat
end tell

This seems to work most of the time, though some of my subscriptions don't have any:

get date published of headline 1 of item 52 of every subscription
get date published of headline 1 of item 53 of every subscription
get date published of headline 1 of item 54 of every subscription
get date published of headline 1 of item 55 of every subscription
    date "Friday, March 28, 2003 8:41:24am"
get date published of headline 1 of item 56 of every subscription
    date "Tuesday, March 25, 2003 3:32:22pm"

Moving past the fact that I can't get a proper date, I can't seem to compare it when I do get a date (any date):

set oldies to {}
set cutoffDate to ( (current date) - (30 * days) )
tell application "NetNewsWire"
    repeat with thisSub in every subscription
        tell thisSub
            if last update time < cutoffDate then
                set oldies to oldies & thisSub
            end if
        end tell
    end repeat
end tell

That gives me "No result was returned from some part of this expression." with "cutoffDate" after < selected. The same comparison works fine here:

property logsFolder : "(snip - too long)"
set cutoffDate to ( (current date) - (90 * days) )
tell application "Finder"
    set folderList to (folders of folder logsFolder)
    repeat with i from 1 to count of folderList
        set AliasPath to item i of folderList as alias
        set folderMod to modification date of (info for AliasPath)
        if folderMod < cutoffDate then
            delete AliasPath
        end if
    end repeat
end tell

(The above deletes old the log folders of people I haven't spoken to in less than 90 days.) So, what exactly am I doing wrong here? I was all set to write about how AppleScript is so awesome, allowing you to do so much, and yet I can't get it to realize that a variable exists one line after I set it.

I'm giving up for now.

3 Responses to "NNW ASS?"

  1. I'll look into it. Thanks for the report!

  2. This works, sorta

    set oldies to {}

    set cutoffDate to ((current date) - (15 * days))

    tell application "NetNewsWire"

    set counter to count of every subscription

    repeat with i from 1 to counter

    if is group of subscription i is false then

    set oldies to display name of subscription i & oldies

    set oldies to last update time of subscription i & oldies

    end if

    end repeat

    end tell

    This was run right after I launched the latest alpha release and the times rturned appear as the times that NNW populated the feeds with cached data.

    get display name of subscription 30

    "The Shifted Librarian"

    get last update time of subscription 30

    date "Friday, March 28, 2003 9:43:56 PM"

    get is group of subscription 31

    false

    get display name of subscription 31

    "Way.Nu"

    get last update time of subscription 31

    date "Friday, March 28, 2003 9:43:57 PM"

    and etc

    But returns a time listing for every subscription, regardless of last update time.

  3. I think the wording is nicely vague to be confusing.

    last update time and last check time should always be the same in regards to NNW's meaning. Each check should produce an "update" regardless if that feed has any new entries or not.

    However if the download times out the update and check time would be different.

    So NNW needs a way to track when a subscription actually had a new entry posted to it, outside of the last modified header and entry dates, since those aren't supported by a lot of feeds.