Archive articles from Pocket Feed via API

If you like Pocket you probably know that you can set up a RSS Feed in DEVONthink Pro (help.getpocket.com/article/1074 … st-via-rss).

But how to sync articles you’ve read in DEVONthink with your Pocket account?

The good news: With github.com/rakanalh/pocket-cli it can be done! I came across this some time ago, but as I’m a totally Terminal newbie… and honestly I did not try enough. Yesterday after several hours I managed to get my Pocket account and my DEVONthink Pocket Feed to sync, hey :slight_smile:

The bad news: I can’t tell you how. I really have no idea what I was doing with “Terminal”, “python”, “pip install”, “easy_install”, “–ignoring-installed”, “six”, “site-packages”, “–upgrade”, the wrong “six” (you need “six==1.10.0”) and the excursion to Homebrew.

However people who are familiar with that kind of stuff could probably tell how to set this up in a few minutes (and I’m pretty sure they will :slight_smile: )

Anyway I tried myself on an AppleScript - but it sometimes works (especially in the beginning); the longer I try the more often it fails. Script Debugger demo didn’t help, maybe sleep will

tell application id "DNtp"
	
	set fetchPocket to do shell script "PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin; pocket-cli fetch"
	
	delay 5
	
	set theSelection to the selection
	
	repeat with theRecord in theSelection
		
		if unread of theRecord is false then
			set RecordName to name of theRecord
			
			set searchPocket to do shell script "PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin; pocket-cli search " & quoted form of RecordName
			
			set i to (count paragraphs of searchPocket) / 4
			set thisLine to 2
			set searchTheResults to {}
			
			repeat until i = 0
				set end of searchTheResults to item thisLine of (paragraphs of searchPocket)
				set thisLine to thisLine + 4
				set i to i - 1
			end repeat
			
			repeat with thisItem in searchTheResults
				set theName to (characters 14 thru -1 in thisItem) as string
				if theName = name of theRecord then
					set PocketID to (characters 1 thru 10 of thisItem) as string
				end if
			end repeat
			
			set archivePocket to do shell script "PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin; pocket-cli archive " & quoted form of PocketID
			
			move record theRecord to trash group of database of theRecord
			
		end if
		
	end repeat
	
end tell