This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from webbrowser import open | |
from urllib import quote | |
query = sys.argv[1] | |
#Web Services | |
stackoverflow = '!s ' | |
wikipedia = '!w ' | |
macupdate = '!mac ' | |
appshopper = '!app ' | |
imdb = '!imdb ' | |
amazon = '!amaz ' | |
wolframalpha = '!wolf ' | |
reddit = '!red ' | |
alternativeto = '!to ' | |
hackernews = '!hack ' | |
merriamwebster = '!def ' | |
#Apps | |
onepassword = '!op ' | |
wikipanion = '!wiki ' | |
tweetbot = '!tb ' | |
terminology = '!te ' | |
imdbapp = '!movie ' | |
articles = '!art ' | |
twitterrific = '!twi ' | |
rdio = '!rd ' | |
fantastical = '!day ' | |
due = '!due ' | |
wolframapp = '!wol ' | |
appstore = '!store ' | |
if stackoverflow in query: | |
open('safari-http://stackoverflow.com/search?q=' + quote(query.replace(stackoverflow,''))) #Stack Overflow | |
elif wikipedia in query: | |
open('safari-https://en.wikipedia.org/w/index.php?search=' + quote(query.replace(wikipedia,'')) + '&title=Special%3ASearch') #Wikipedia | |
elif macupdate in query: | |
open('safari-https://www.macupdate.com/find/mac/' + quote(query.replace(macupdate,''))) #MacUpdate | |
elif appshopper in query: | |
open('safari-http://appshopper.com/search/?search=' + quote(query.replace(appshopper,''))) #AppShopper | |
elif imdb in query: | |
open('safari-http://www.imdb.com/find?q=' + quote(query.replace(imdb,'')) + '&s=all') #IMDB | |
elif amazon in query: | |
open('safari-http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=' + quote(query.replace(amazon,''))) #Amazon | |
elif wolframalpha in query: | |
open('safari-http://www.wolframalpha.com/input/?i=' + quote(query.replace(wolframalpha,''))) #Wolfram|Alpha | |
elif reddit in query: | |
open('safari-http://www.reddit.com/r/search/search?q=' + quote(query.replace(reddit,''))) #Reddit | |
elif alternativeto in query: | |
open('safari-http://alternativeto.net/SearchResult.aspx?search=' + quote(query.replace(alternativeto,''))) #AlternativeTo | |
elif hackernews in query: | |
open('safari-https://www.hnsearch.com/search#request/all&q=' + quote(query.replace(hackernews,'')) + '&start=0') #Hacker News | |
elif merriamwebster in query: | |
open('safari-http://www.merriam-webster.com/dictionary/' + quote(query.replace(merriamwebster,''))) #Merriam-Webster | |
elif onepassword in query: | |
open('onepassword://search/' + quote(query.replace(onepassword,''))) #1Password | |
elif wikipanion in query: | |
open('wikipanion:///' + quote(query.replace(wikipanion,''))) #Wikipanion | |
elif tweetbot in query: | |
open('tweetbot:///search?query=' + quote(query.replace(tweetbot,''))) #Tweetbot | |
elif terminology in query: | |
open('terminology://x-callback-url/lookup?text=' + quote(query.replace(terminology,''))) #Terminology | |
elif imdbapp in query: | |
open('imdb:///find?q=' + quote(query.replace(imdbapp,''))) #IMDB app | |
elif articles in query: | |
open('x-articles://?search=' + quote(query.replace(articles,''))) #Articles | |
elif twitterrific in query: | |
open('twitterrific:///search?q=' + quote(query.replace(twitterrific,''))) #Twitterrific | |
elif rdio in query: | |
open('rdio://search/' + quote(query.replace(rdio,''))) #Rdio | |
elif fantastical in query: | |
open('fantastical://search?query=' + quote(query.replace(fantastical,''))) #Fantastical | |
elif due in query: | |
open('due://x-callback-url/search?query=' + quote(query.replace(due,''))) #Due | |
elif wolframapp in query: | |
open('wolframalpha:///?i=' + quote(query.replace(wolframapp,''))) #Wolfram|Alpha app | |
elif appstore in query: | |
open('http://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&term=' + quote(query.replace(appstore,''))) #AppStore | |
else: | |
open('safari-https://duckduckgo.com/?q=' + quote(query)) #Falls back on DuckDuckGo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment