Exemple #1
0
def weather(query):
	import engine, config
	if query == "":
		loc = engine.location()
		if not loc:
			return None
		location = "where you are now"
		query = "%s,%s" % (loc[0], loc[1])
	else:
		location = query
	
	j = engine.getJson("http://api.wunderground.com/api/%s/forecast/q/%s.json" % (config.weatherunderground_key, query))
	if 'forecast' in j:
		s = []
		for day in j['forecast']['txt_forecast']['forecastday'][:5]:
			s.append( "<img src='%s' /><br/><strong>%s</strong><br/>%s" % ( day['icon_url'], day['title'], day['fcttext'] ) )
		s = engine.grid(s)	
	
		return {
			"snippet" : s,
			"style" : "goodies",
			"url" : "http://www.wunderground.com/",
			"display_url" : "Powered by WeatherUnderground",
			"title" : "Weather for %s" % location
		}
Exemple #2
0
def where(query):
	if query.lower().startswith("am i") or query.lower().startswith("me"):
		from engine import location
		loc = location()
		if loc != None:
			return {
				"style" : "goodies",
				"title" : "You are here:",
				"snippet" : "<img src='http://maps.googleapis.com/maps/api/staticmap?center=%s&sensor=false&size=512x250&zoom=14' />" % "%s,%s" % (loc[0], loc[1])
			}