Sorry, thought you were stuck on the meta tag problem, not on the actual scripting; the Applescript and the Shell script were just examples of getting the Publication date (or any metatag info) from the HTML page.
This script will look for a record with the URL you gave, and will update the comment field as you requested. Updating the date does not work; I think DT’s “date” declaration overrides the Applescript “date” routine. I’ll post when I get it going.
tell application "DEVONthink Pro"
-- Replace this with appropriate applescript to get the record you need to modify, e.g.
-- set rec_list to selection of application
set url_str to "http://news.bbc.co.uk/1/hi/uk_politics/vote_2005/england/4412281.stm"
set rec_list to lookup records with URL url_str
set rec to item 1 of rec_list
-- End 'Replace this...'. Make sure 'rec' contains record to modify.
-- Set 'html__str' to the HTML source in record
-- For URL record use something like:
-- set html_str to download markup from URL of rec
set html_str to source of rec
-- Get META tag with name 'OriginalPublicationDate' into 'meta_str'
set meta_str to texts from character (offset of "<meta name=\"OriginalPublicationDate\"" in html_str) to (length of html_str) of html_str
-- Get 'content' property of META tag
set content_str to texts from character ((offset of "content=" in meta_str) + 9) of meta_str to (length of meta_str) of meta_str
-- Get publication date from value of 'content' property
set pub_date to texts from character 1 to ((offset of "\"" in content_str) - 1) of content_str
-- Set record comment to "Publication Date: $pub_date"
set comment of rec to "Publication Date: " & pub_date
-- Set record creation date to publication date
-- Doesn't work:
-- set creation date of rec to date pub_date
end tell
Run this in ScriptEditor (should be in Applications) and it should set the comment for the first record containing the specified URL.
I’m not much of an Applescripter; it’s an awkward language to use once you’ve programmed in, well, just about anything else. If you open the Script Editor, you can use File->Open Dictionary to select DevonThink; this will give you the list of DevonThink commands.
The following commands should be useful to you:
set html_str to download markup from url_string
if exists record with URL url_string
set rec to get record at path_str
set rec_list to lookup records with comment comment_str
set rec_list to lookup records with url url_str
set rec_list to selection of application
You will probably want to start out creating a script for each META tag that you want to support, then passing the script a selection and making the changes to each record in the selection.
With Automator actions, it should be possible to extract the meta tags and present the user with a dialog box where they select the appropriate tag. I think this requires an xcode project for the Automator action; an easier alternative is to use CocoaDialog if you have it installed (and if you know shell scripting).
Looks like Applescript supports this too via StandardScriptingAdditions dialogs (‘set meta_tag_name to choose from list meta_tag_name_list with prompt “Select a META tag type:”’). Parsing the meta tags in Applescript looks painful, but once you have them it’s pretty straightforward.