Jump to content

Recommended Posts

Hi guys,

 

this workflow lets you manage your Pocket list with Alfred.

 

screenshot.gif

 

Features

  • Actions to copy, visit and archive, archive and delete links from your Pocket list (fnctrlalt and cmd)
  • Hotkey to add new links from Chrome, Safari or your clipboard (ctrl + L)
  • Action to deauthorize the workflow (shift)
  • Background cache refresh
  • Supports notifications
  • Uses OAuth 2.0 to authorize the workflow
  • Saves your access_token securely in OS X's keychain

 

Github: https://github.com/fniephaus/alfred-pocket

Download: https://github.com/fniephaus/alfred-pocket/releases/latest/

 

Feel free to give some feedback!

 

Cheers,

Fabio

Edited by fniephaus
Link to comment

Hey Katie,

thanks for the bug report.

And no, the application doesn't need to be installed.

 

Would you be so kind and open up the workflow's debug window (click on the little bug icon) in order to get more details about the problem?

It'd be great if you could send me the error log.

 

Thanks,

Fabio

 

*EDIT*: I've just updated the workflow. Could you try out the new version? Thanks!

Edited by fniephaus
Link to comment

Great stuff. Just one comment — it would seem the default action is to visit the link and archive it in Pocket and you have to hold "Ctrl" to visit without archiving. Personally, I'd prefer it if this was the other way round and it didn't archive by default.

 

I realise I can probably just tweak the workflow to change this around, but thought I'd let you know anyway.

 

Oh, and one more little thing — it would be good to get a notification when archiving links.

 

But well done. I'll find this really handy, I think.

Edited by CarlosNZ
Link to comment

That is something I still need to figure out.

The links should be ordered by date but Alfred seems to mix them up, even though I haven't set a uid.

 

*EDIT*: okay, it wasn't Alfred but the API wrapper. Should be fixed now!

Edited by fniephaus
Link to comment

Ed3KO9p.png

 

Fabio-- I'm getting this error after installing your workflow and the first attempt at running. The debug info from Alfred is below. I just edited out my username. I have a valid Pocket account and can login to it with no problem in Safari. Any suggestions?

 

Thanks

Starting debug for 'Pocket for Alfred'

[ERROR: alfred.workflow.input.scriptfilter] Code 1: 08:53:53 workflow.py:967 DEBUG    get_password : com.fniephaus.pocket:pocket_access_token
08:53:53 workflow.py:967 DEBUG    get_password : com.fniephaus.pocket:pocket_access_token
08:53:53 workflow.py:967 DEBUG    get_password : com.fniephaus.pocket:pocket_access_token
08:53:53 connectionpool.py:635 INFO     Starting new HTTPS connection (1): getpocket.com
08:53:53 connectionpool.py:344 DEBUG    "POST /v3/get HTTP/1.1" 401 16
08:53:53 workflow.py:843 ERROR    Problem authenticating the user. A valid access token is required to access the requested API endpoint.
Traceback (most recent call last):
  File "/Users/edit/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.9AFC12F4-2304-40BB-9DBC-427C3585C487/workflow/workflow.py", line 841, in run
    func(self)
  File "pocket_alfred.py", line 20, in main
    'pocket_list', data_func=get_list, max_age=1)
  File "/Users/edit/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.9AFC12F4-2304-40BB-9DBC-427C3585C487/workflow/workflow.py", line 602, in cached_data
    data = data_func()
  File "pocket_alfred.py", line 42, in get_list
    get = pocket_instance.get()
  File "/Users/edit/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.9AFC12F4-2304-40BB-9DBC-427C3585C487/pocket.py", line 57, in wrapped
    return self.make_request(url, payload)
  File "/Users/edit/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.9AFC12F4-2304-40BB-9DBC-427C3585C487/pocket.py", line 154, in make_request
    return cls._make_request(url, payload, headers)
  File "/Users/edit/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.9AFC12F4-2304-40BB-9DBC-427C3585C487/pocket.py", line 147, in _make_request
    '%s. %s' % (error_msg, extra_info)
AuthException: Problem authenticating the user. A valid access token is required to access the requested API endpoint.
Link to comment

Hey Weaselboy, thanks for the debug info. That helped a lot!

I've updated the workflow and improved the authentication process.

 

Could you give it another try? And could you open your keychain and check if there is an entry 'com.fniephaus.pocket'.

 

Thanks!

Link to comment

Hey Weaselboy, thanks for the debug info. That helped a lot!

I've updated the workflow and improved the authentication process.

 

Could you give it another try? And could you open your keychain and check if there is an entry 'com.fniephaus.pocket'.

 

Thanks!

 

That fixed it!   :)

 

I deleted the Keychain entry and installed the updated workflow and it works perfectly. Nice work on this and thanks.

Link to comment

I deleted the keychain access item, revoked Pocket access, an re-installed the workflow. Now it seems that Pocket is having trouble re-authenticating. The authorization page comes up but when it's clicked, it leads to a blank page and doesn't do anything/doesn't authorize the workflow. 

 

Here's the bug text that came up:

Starting debug for 'Pocket for Alfred'

[ERROR: alfred.workflow.input.scriptfilter] Code 0: 16:55:15 workflow.py:619 DEBUG    Cached data saved at : /Users/katie/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.fniephaus.pocket/pocket_request_token.cache
Link to comment

Hey Katie,

my Pocket app is "waiting for App Directory approval" which is probably why you get to see a blank page.

Nevertheless, the workflow should authenticate itself right after you have visited the authentication link.

 

Can you try again, please? The debug log looks just fine!

Link to comment

I'm sorry! I'm not sure what I'm doing wrong. Here's the next error I get:

Starting debug for 'Pocket for Alfred'

[ERROR: alfred.workflow.input.scriptfilter] Code 1: 20:46:31 workflow.py:967 DEBUG    get_password : com.fniephaus.pocket:pocket_access_token
20:46:31 workflow.py:967 DEBUG    get_password : com.fniephaus.pocket:pocket_access_token
20:46:31 workflow.py:598 DEBUG    Loading cached data from : /Users/katie/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.fniephaus.pocket/pocket_list.cache
20:46:32 workflow.py:843 ERROR    'resolved_title'
Traceback (most recent call last):
  File "/Users/katie/Dropbox/Apps/Alfred.alfredpreferences/workflows/user.workflow.81B5681C-9EC8-441B-A027-DC3F79CCF7E7/workflow/workflow.py", line 841, in run
    func(self)
  File "pocket_alfred.py", line 31, in main
    'resolved_title'] != '' else item['given_title']
KeyError: 'resolved_title'

Thanks for your help!

Link to comment

That's weird. There seems to be something wrong with Pocket's response.

 

I've prepared another workflow version that is more verbose:

https://github.com/fniephaus/alfred-pocket/raw/debug/Pocket-for-Alfred.alfredworkflow

 

Can you use this to generate another debug log?

This time there should be a lot more to copy.

And feel free to replace things you don't want anyone else to see with whatever you like ;)

 

Thanks!

Edited by fniephaus
Link to comment

Haha, that's okay. I don't mind posting some random information about items in my Pocket  :)

 

Here it is:

Starting debug for 'Pocket for Alfred'

[ERROR: alfred.workflow.input.scriptfilter] Code 1: 21:37:37 workflow.py:967 DEBUG    get_password : com.fniephaus.pocket:pocket_access_token
21:37:37 workflow.py:967 DEBUG    get_password : com.fniephaus.pocket:pocket_access_token
21:37:37 workflow.py:967 DEBUG    get_password : com.fniephaus.pocket:pocket_access_token
21:37:38 connectionpool.py:635 INFO     Starting new HTTPS connection (1): getpocket.com
21:37:42 connectionpool.py:344 DEBUG    "POST /v3/get HTTP/1.1" 200 None
21:37:50 workflow.py:619 DEBUG    Cached data saved at : /Users/katie/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.fniephaus.pocket/pocket_list.cache
21:37:50 pocket_alfred.py:30 DEBUG    {u'status': u'0', u'is_index': u'0', u'sort_id': 383, u'time_updated': u'1367606203', u'time_favorited': u'0', u'time_read': u'0', u'excerpt': u'Jason Shafer is currently a PhD Candidate in English at UC Boulder, he maintains a personal blog over at http://www.jasonshafer.net that is currently chronicling his battles towards perfecting a strategy for digital workflow in academia.', u'has_image': u'1', u'favorite': u'0', u'has_video': u'0', u'word_count': u'1062', u'given_title': u'Going Paperless from Day One: Digital Academic Workflow for Grads | GradHac', u'resolved_url': u'http://www.gradhacker.org/2011/08/12/going-paperless-from-day-one-digital-academic-workflow-for-grads/', u'is_article': u'1', u'item_id': u'97378175', u'time_added': u'1367606203', u'resolved_id': u'97378175', u'given_url': u'http://www.gradhacker.org/2011/08/12/going-paperless-from-day-one-digital-academic-workflow-for-grads/', u'resolved_title': u'Going Paperless from Day One: Digital Academic Workflow for Grads'}
21:37:50 pocket_alfred.py:30 DEBUG    {u'status': u'0', u'is_index': u'0', u'sort_id': 11, u'time_updated': u'1394571855', u'time_favorited': u'0', u'time_read': u'0', u'excerpt': u'Whatever country we live in, we\u2019re probably all familiar with the well-known photography magazines available in our newsagents and bookstores. The UK has Practical Photography, France has Photo, the Italians have Zoom and the Americans have American Photo.', u'has_image': u'1', u'favorite': u'0', u'has_video': u'0', u'word_count': u'983', u'given_title': u'40 Amazing Online Photography Magazines | Smashing Magazine', u'resolved_url': u'http://www.smashingmagazine.com/2009/04/17/40-amazing-online-photography-magazines/', u'is_article': u'1', u'item_id': u'9633419', u'time_added': u'1394571855', u'resolved_id': u'9633419', u'given_url': u'http://www.smashingmagazine.com/2009/04/17/40-amazing-online-photography-magazines/', u'resolved_title': u'40 Amazing Online Photography Magazines'}
21:37:50 pocket_alfred.py:30 DEBUG    {u'status': u'0', u'is_index': u'0', u'sort_id': 678, u'time_updated': u'1360009974', u'time_favorited': u'0', u'time_read': u'0', u'excerpt': u'I\u2019ve been through my share of organizational and productivity kicks, but I\u2019ve tried to start seeing those for what they are \u2014 a form of \u201cstructured procrastination\u201d. And while entertaining, and perhaps even inspiring, that\u2019s not always very productive.', u'has_image': u'0', u'favorite': u'0', u'has_video': u'0', u'word_count': u'560', u'given_title': u'I might be a convert to "tags"', u'resolved_url': u'http://fletcherpenney.net/2011/06/i_might_be_a_convert_to_tags', u'is_article': u'1', u'item_id': u'94643293', u'time_added': u'1360009974', u'resolved_id': u'94643293', u'given_url': u'http://fletcherpenney.net/2011/06/i_might_be_a_convert_to_tags', u'resolved_title': u'I might be a convert to "tags"'}
21:37:50 pocket_alfred.py:30 DEBUG    {u'status': u'0', u'is_index': u'0', u'sort_id': 37, u'time_updated': u'1392322799', u'time_favorited': u'0', u'time_read': u'0', u'excerpt': u'Share your videos with friends, family, and the world', u'has_image': u'1', u'favorite': u'0', u'has_video': u'2', u'word_count': u'0', u'given_title': u'Kim Peek - The Real Rain Man [1/5] - YouTube', u'resolved_url': u'https://www.youtube.com/watch?v=k2T45r5G3kA', u'is_article': u'0', u'item_id': u'944588', u'time_added': u'1392322799', u'resolved_id': u'944588'
Link to comment

Thanks, katie.

Unfortunately, everything looks fine to me.

I assume this was not everything that was printed in the debug window?

The first three items contain a resolved_title and I guess, so does the forth one.

Can you PM me the full debug log?

 

At least we can rule out that there is an authentication issue!

 

Nevertheless, I've updated the workflow, so it should work now even if no 'resolved_title' is present.

Please do the debug log once more with the old workflow but you might give the new workflow a go once you have everything I need ;)

 

*EDIT*: I was able to figure out why it didn't work for katie. The latest version should work just fine!

Edited by fniephaus
Link to comment

I have a tweak request Fabio.

 

I often use your extension with Pocket to copy a URL for later posting in news forums. I have figured out I can copy by hitting command-c, but for some reason that appends a string of numbers after the link.

http://support.apple.com/kb/HT1379 137984712

Here is an example of an Apple support link and note the 137984712 appended when I copy the link. This happens with every URL I try.

 

Is there a KB combo I am  missing to copy a link maybe?

Link to comment

When pressing command-c you are copying the item's argument which is passed to the pocket_launcher.py.

The weird number is the item's ID.

 

I'm not sure what you are asking? I just bring up the workflow then in this example type L O C which highlights the URL I want... then command-c to copy the link. That gets me the link with the numbers appended in the clipboard.

 

(Sorry if I am being dense)

 

q3Mnj26.png

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...