Script Question Re:RSS Entries

I have a couple of questions regarding using scrips on the RSS items.

  1. If I add a script to an RSS feed via the info menu, when does it fire - as things come in, or after they do?
  2. Can the script be python?

I basically want to make a “reader view” of the pages as they come in. I can do this using the Mercury web parser API and a python script. I can take an article in, parse it, and send an html file out with the cleaned html. I essentially want to use this script on the RSS articles as they are loaded into DTPO. I haven’t finished my python script (playing with the html template for output) but realized that I am not sure it would even work like I want it to.

Or, even better…does anyone have a solution for this? I have a similar type of script that I’m using for Keyboard Maestro (for reference at https://forum.keyboardmaestro.com/t/use-mercury-parser-to-simplify-webpage-macro/6259).

I assume you are referring to so-called “triggered scripts” – those that are assigned to a document or group. Here’s what Help says:

You can have a small AppleScript that’s a wrapper for a do shell script command to execute your Python script.

The AppleScript should use this structure:

on triggered()
	try
		[do stuff]
	end try
end triggered

It’s a good idea – but not essential – to have error handling included so that a dialog message pops when the script fails or encounters an error. Otherwise it could fail silently and you wouldn’t be able to know why.

Thanks for your help…it’s moving me in the right direction. I have another question. How do I get the URL from the item? I’ve tried something like:

tell application "DEVONthink Pro"
	try
		set theitem to the selection
		set link to the URL of theitem
		print link
	on error error_message number error_number
		if error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

But this returns an error message: Can’t get URL of {content id 51078 of database id 5 of application “DEVONthink Pro”}.

I can launch the python script no problem in AppleScript and get the responding file, but I’m lacking the knowledge/ability to send the link from the item to the script to be parsed and then have the corresponding html loaded into the viewer.

  1. Use…

tell application id "DNtp"

  1. A selection is a list. You can’t get the URL of a list, as it has no URL. You need item n of selection (typically item 1).

You are awesome! I’m making progress toward the solution I’m looking for. This is what worked:

tell application id "DNtp"
		try
			set sel to the selection
			set theitem to item 1 of sel
			set thelink to the URL of theitem
                        print thelink
                end try
           end tell

I’m having two other issues: the code you gave me ```

on triggered()…


Basically, after I get the link, I send it to python and run it through the Mercury Feed Parser API in order to get a reader version of the page. I save that into a temporary html file, which I want to load into the article viewer window.

Edit: I'm thinking I can do this by the "Update Captured Page" somehow. If I can update the page from the gear that way, maybe I can update the page with my temp.html file.

Is the script only attached to the feed? Then it’s executed after selecting/opening the feed but not after selecting/opening one of the feed’s items.

I tried attaching it and nothing seemed to happen. When I run the script separately (via Script editor) and have a selected feed item, the script runs as planned (though without loading the temp.html into the viewer).

Would this then, need a two phase kind of deployment:

  1. Script attached to feed which would add this script to all feed items on the triggered event (as they come in).
  2. This script attached to the feed items would trigger when they get selected.

Sorry, I’m very new to AppleScript and DTP so I’m trying to work this out. I’d love for this “reader” mode to work on the RSS feeds so that I can make DTP my permanent feed reader.

You’d still need to interact with the parent feed to trigger the event. You’d also need to make sure you’re clearing out or removing already processed feed items to avoid reprocessing them. Also, what about feed items you don’t want converted? This would just increase the noise if it was processing every file without curation.