import requests, os, sys if not "WAPIKEY" in os.environ: print("MeowNexUS requires the WAPIKEY environment variable for this command to function. get one from https://weatherapi.com/") sys.exit(1) query = requests.get("http://api.weatherapi.com/v1/current.json?key=" + os.environ["WAPIKEY"] + "&q=" + " ".join(sys.argv[3:])).json() weathers_global = { **dict.fromkeys([1063, 1150, 1153, 1180, 1183, 1186, 1189, 1192, 1195, 1198, 1201, 1204, 1207, 1240, 1243, 1246, 1249, 1252], "🌧️"), **dict.fromkeys([1066, 1069, 1072, 1114, 1210, 1213, 1216, 1219, 1222, 1225, 1255, 1258, 1237], "🌨️"), **dict.fromkeys([1030, 1135, 1147], "🌫️"), **dict.fromkeys([1087, 1273, 1276, 1279, 1282], "⛈️") } weathers = { 1: { 1000: "☀️", 1003: "⛅", 1006: "☁️", 1009: "☁️", 1063: "🌦️", **weathers_global }, 0: { 1000: "🌙", 1003: "☁️", 1006: "☁️", 1009: "☁️", **weathers_global } } if "error" in query: print("API ERROR: " + query["error"]["message"]) else: print(query["location"]["name"] + ", " + query["location"]["region"] + ", " + query["location"]["country"] + ": " + weathers[query["current"]["is_day"]][query["current"]["condition"]["code"]] + " " + query["current"]["condition"]["text"] + " " + str(query["current"]["temp_f"]) + "°F (" + str(query["current"]["temp_c"]) + "°C)")