Last active
August 21, 2017 00:45
-
-
Save woohgit/81c145bb332beb6aa88f1078bc3cdd8d to your computer and use it in GitHub Desktop.
Earthquake feed for HipChat - card type message
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
url = "http://earthquake-report.com/feeds/recent-eq?json" | |
try: | |
entries = json.loads(urllib.urlopen(url).read()) | |
for entry in entries: | |
if "JAPAN" in entry['location'].upper(): | |
jishin = entry | |
break | |
except Exception: | |
pass | |
card1 = { | |
"id": str(uuid.uuid4()), | |
"icon": {"url": "http://icooon-mono.com/i/icon_15889/icon_158890_256.png"}, | |
"url": jishin["link"], | |
"style": "application", | |
"format": "medium", | |
"attributes": [ | |
{ | |
"value": { | |
"label": jishin["location"].lower() | |
}, | |
"label": "Location" | |
}, | |
{ | |
"value": { | |
"label": "%s %s" % (jishin["date_time"].split("T")[0], | |
jishin["date_time"].split("T")[1].split("+")[0]) | |
}, | |
"label": "Date"}, | |
{ | |
"value": { | |
"style": "lozenge-current", | |
"label": jishin["magnitude"] | |
}, | |
"label": "Magnitude"} | |
], | |
"title": jishin["title"], | |
"activity": { | |
"html": jishin["title"], | |
"icon": "http://icooon-mono.com/i/icon_15889/icon_158890_256.png" | |
}, | |
# "description": { | |
# "value": "", "format": "html" | |
# }} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment