[Feed] Delete read articles from Pocket account

Hi, I’ve set up a feed for unread articles from my Pocket account in DEVONthink. That’s really nice. :slight_smile:

But I have to delete the articles I’ve read from the account. I’ve got this script, which worked, as long as I worked on the script… Now it gives an empty list as result, because I tested it on replicants in a normal group… took me long time to find that out :unamused:

I know replicating in a group and using “delete” is possible, but I don’t really like it, as I prefer having the record in the trash to get back to it if I missed something (therefor the label).

While writing this, something came to my mind: what about API? I have no clue what can be done with it, but as far as I understand its like a bridge. So maybe there is a way to delete content directly from a Pocket account?


tell application id "DNtp"
	
	set PocketFeed to parent id 419952 of database named "Test"
	set ReadList to {}
	set ReadListName to {}
	set PocketItems to children of PocketFeed whose type is bookmark
	
	repeat with PocketItem in PocketItems
		if unread of PocketItem is false then
			set end of ReadList to PocketItem
			set end of ReadListName to name of PocketItem
		end if
	end repeat
	
	if ReadListName is not {} then
		set deleteItem to item 1 of ReadList
		set deleteItemName to item 1 of ReadListName
		set the clipboard to deleteItemName
		
		tell application "Safari"
			if window "Pocket: Meine Liste" exists then
				activate
			else
				make new document with properties {URL:"https://getpocket.com/a/queue/list/"}
				activate
			end if
		end tell
		
		set label of deleteItem to 4
		move record deleteItem to trash group of database of deleteItem
	else
		display dialog "DEVONthink: Keine weiteren Pocket Artikel gefunden!" with title "Gelesene aus \"Mein Pocket\" löschen"
		
	end if
end tell

Why not just set the RSS preferences to delete after a certain amount of time?

Also, we don’t suggest using your Trash as a filing cabinet (any more than you should with the trashbin in your kitchen :mrgreen: )

:smiley: I use Pocket on different devices and it would be a great mess if read articles remained in the unread list. Setting DEVONthink preferences to delete is no option as I have several feeds I want to watch a long time. I’ve thought of a script for these feeds that locks the children, but am not sure if this can be done. So I think it’s easier to maintain the Pocket account

Accessing records via their ID isn’t recommended, e.g. rebuilding/optimizing might change this internal ID. Use the commands “get record with UUID” or “get record at” instead.