Jump to content

LkeMitchll

Member
  • Posts

    3
  • Joined

  • Last visited

Everything posted by LkeMitchll

  1. Thanks for this! I'm using the fuzzy search from your module.
  2. Thanks for the reply, cache returnS simple JSON. I might try importing the fuzzy search from alp! how would you use it to manipulate JSON? e.g. [ { u'archived':False, u'description':u'Wordpress site for the church project', u'url': u'https://basecamp.com/1818846/api/v1/projects/285717-xxxxxxx.json', u'created_at': u'2012-04-11T08:25:59.000 Z', u'last_event_at': u'2013-05-02T11:12:27.000 Z', u'updated_at': u'2013-05-02T11:12:27.000 Z', u'starred':False, u'id':285717, u'name':u'xxxxxxxxxxxxxxx' }, { u'archived':False, u'description':u'Lemonstand site', u'url': u'https://basecamp.com/1818846/api/v1/projects/xxxxxxxxxxxx.json', u'created_at': u'2012-07-26T08:51:14.000 Z', u'last_event_at': u'2013-05-14T15:18:06.000 Z', u'updated_at': u'2013-05-14T15:18:06.000 Z', u'starred':False, u'id':834090, u'name':u'xxxxxxxxxxxxx' } ]
  3. Hi all, I've been working on a Alfred workflow to display Basecamp projects. So far so good! i've got all the results being pulled and displayed by feedback. My problem is how do I use {query} to filter the results? for example if I type 'bc' it lists all the projects, I want to be able to type for example 'bc arg' and for it to filter the results based on query, so i'd get results beginning with 'arg' (pretty basic I know!). I don't have much experience with Python of Alfred so any help would be appreciated! See below the python code and the full workflow also: #!/usr/bin/env python import requests import alfred import os.path request = requests.get('https://basecamp.com/XXXXXXX/api/v1/projects.json', auth=("USERNAME", PASSWORD')) query = alfred.argv(1) alfred.log(str('QUERY: '+query)) try: set_cache = alfred.cache.set('cache', request.json()) cache = alfred.cache.get('cache') except IOError: alfred.log('IOError!') feedback = alfred.Feedback() def projects(): """Function to receive json and output Alfred feedback""" i = 0 for list in cache: # define attribute locations as variables name = cache[i]['name'] id = cache[i]['id'] url = cache[i]['url'] starred = cache[i]['starred'] desc = cache[i]['description'] # manipulating the string to remove 'api', 'v1' and '.json' url = url.split('/') del url[4] del url[4] url = '/'.join(url) url = os.path.splitext(url)[0] feedback.addItem(title=name, subtitle=desc, uid=('bc' + str(id)), valid=True, icon="basecamp.png", arg=url) alfred.log('FEEDBACK: ' + name) i += 1 feedback.output() projects() alfred.exit('EXIT') alfred.log('EXIT') As you can see I'm using the rather wonderful Alfred-Python library! http://cl.ly/Ovrf Thanks in advance!
×
×
  • Create New...