-
Notifications
You must be signed in to change notification settings - Fork 0
/
CricScore.py~
executable file
·45 lines (38 loc) · 1.3 KB
/
CricScore.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
39
40
41
42
43
44
import requests
from bs4 import BeautifulSoup
from time import sleep
import pynotify
def popUpMessage(title, message):
pynotify.init("Cricket Score")
pynotify.Notification(title, message, "dialog-information").show()
Url = "http:https://static.cricinfo.com/rss/livescores.xml"
matchChoice = 0
score = ""
didInterrupt = False
while True:
try:
r = requests.get(Url)
while r.status_code is not 200:
r = requests.get(liveUrl)
data = BeautifulSoup(r.text).find_all("description")
if not matchChoice:
print("Matches available:")
for index, game in enumerate(data[1:], 1):
print(index, str(game.text))
matchChoice = int(input("Enter your choice: "))
while True:
if matchChoice in range(1, index):
break
matchChoice = int(input("Invalid Choice. Enter your choice: "))
didInterrupt=False
score = data[matchChoice].text
popUpMessage("Score", score)
sleep(15)
except KeyboardInterrupt:
if didInterrupt:
logging.info("keyboard interrupted, once")
print("Bye bye")
break
else:
print("Press Ctrl+C again to quit")
matchChoice, didInterrupt = 0, True