-
Notifications
You must be signed in to change notification settings - Fork 0
/
scores.py
38 lines (31 loc) · 926 Bytes
/
scores.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import urllib2
import ast
import os
#from gi.repository import Notify
#Notify.init("CricScore")
def main():
try:
content = urllib2.urlopen("http://cricscore-api.appspot.com/csa").read()
list=ast.literal_eval(content)
scores={}
for x in list:
try:
score = urllib2.urlopen("http://cricscore-api.appspot.com/csa?id="+str(x['id'])).read()
except:
print "Make sure you are connected to a working Internet connection."
scorelist=ast.literal_eval(score)[0]
x1=scorelist["si"]
x2=scorelist["de"]
scores[x1]=x2
final=""
for key in scores:
final = final + key + " : \n" + str(scores[key]) + '\n\n\n'
print final
try:
os.system('notify-send -t 10000 "CricScores" "' + final + '" ')
except:
print "Currently desktop notifications aren't available on your OS"
except:
print "Make sure you are connected to a working Internet connection."
if __name__ == '__main__':
main()