# author: Peter Okma from alfred_utils.feedback import Feedback import urllib import json import sys query = sys.argv[1] url = "http://en.wikipedia.org/w/api.php?action=opensearch&search=%s" % query response = json.load(urllib.urlopen(url)) fb = Feedback() for title in response[1]: url = "en.wikipedia.org/wiki/%s" % title url.replace(" ", "_") fb.add_item(title, subtitle="Read wikipedia article on %s" % title, arg=title.replace(" ", "_")) print fb
from alfred_utils.feedback import Feedback import urllib import json import sys query = sys.argv[1] url = 'http://sunrinwiki.layer7.kr/api.php?action=opensearch&search=%s' % query response = json.load(urllib.urlopen(url)) fb = Feedback() for title in response[1]: url = 'sunrinwiki.layer7.kr/index.php/%s' % title url.replace(' ', '_') fb.add_item(title, subtitle="Read sunrinwiki article on %s" % title, arg=title.replace(" ", "_")) print fb
#author: Peter Okma from alfred_utils.feedback import Feedback import sys import re # import addition packages you want to access here query = " ".join(sys.argv[1:]) fb = Feedback() try: res = str(eval(query)) fb.add_item(res, arg=res) except SyntaxError as e: if ('EOF', 'EOL' in e.msg): fb.add_item('...') else: fb.add_item('SyntaxError', e.msg) except Exception as e: fb.add_item(e.__class__.__name__, subtitle=e.message) print fb
set tabIndex to 0 repeat with theTab in every tab of theWindow set tabIndex to tabIndex + 1 set end of json to "{" set end of json to {quote, "win", quote, ":", windowIndex, ","} set end of json to {quote, "tab", quote, ":", tabIndex, ","} set end of json to {quote, "url", quote, ":", quote, URL of theTab, quote, ","} set end of json to {quote, "title", quote, ":", quote, title of theTab, quote, "}" } set end of json to "," end repeat end repeat set json to items 1 thru -2 of json set end of json to "]" return json as text end tell''' pipe = subprocess.PIPE p = subprocess.Popen(['osascript', '-s', 's', '-'], stdin=pipe, stdout=pipe, stderr=pipe) stdout, stderr = p.communicate(script) stdout = stdout.decode('string_escape') tabs = json.loads(stdout[1:-2]) fb = Feedback() for tab in tabs: if query in tab['title'].lower() or query in tab['url'].lower(): fb.add_item(tab['title'], subtitle=tab['url'], arg="%s,%s" % (tab['win'], tab['tab'])) print fb
#author: Mathieu Arnold from alfred_utils.feedback import Feedback import urllib import json import sys query = sys.argv[1] url = 'http://api.urbandictionary.com/v0/autocomplete?term=%s' % query response = json.load(urllib.urlopen(url)) fb = Feedback() for title in response: url = 'www.urbandictionary.com/define.php?term=%s' % title url.replace(' ', '_') fb.add_item(title, subtitle="Read Urban Dictionary article on %s" % title, arg=title.replace(" ", "_")) print fb