Last active
July 28, 2024 19:40
-
-
Save jsit/f25112885a4badcd6dacef6917b42f1b to your computer and use it in GitHub Desktop.
Import Pinboard to EagleFilter (AppleScript)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set pinboardUrl to "https://api.pinboard.in/v1/posts/recent?auth_token=" & pinboardAuth | |
set sourceXml to do shell script "curl " & pinboardUrl | |
set theUrls to {} | |
tell application "System Events" | |
set _xmlData to make new XML data with properties {text:sourceXml} | |
tell XML element "posts" of _xmlData | |
repeat with _post in XML elements | |
tell _post | |
copy {href:value of XML attribute "href", theTags:value of XML attribute "tag"} to end of theUrls | |
end tell | |
end repeat | |
end tell | |
end tell | |
tell application "EagleFiler" | |
tell current library document | |
set _existingUrls to source URL of every library record | |
repeat with _theUrl in theUrls | |
if _existingUrls does not contain href of _theUrl then | |
try | |
set {_record} to import URLs {href of _theUrl} | |
set _newTags to {} | |
repeat with _theTag in words of theTags of _theUrl | |
copy tag _theTag to end of _newTags | |
end repeat | |
set _record's assigned tags to _newTags | |
end try | |
end if | |
end repeat | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment