Last active
February 20, 2016 21:49
-
-
Save Sunil02324/fa1c9c852e1a8c9a0a1c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import requests | |
import pynotify | |
import re | |
from time import sleep | |
import json | |
#Fuction to show notification using pynotify in Ubuntu | |
def popup(title, message): | |
pynotify.init("Test") | |
pop = pynotify.Notification(title, message) | |
pop.show() | |
return | |
def getscore(): | |
#change the below url according to the match | |
url = "http://www.espncricinfo.com/india-v-sri-lanka-2015-16/engine/match/963701.json" | |
r = requests.get(url) | |
while r.status_code is not 200: | |
r = requests.get(url) | |
data = json.loads(r.text) | |
desc = data['description'].strip() | |
player_status = data['match']['current_summary'].strip() | |
team1_name = data['other_scores']['international'][2]['team1_name'].strip() | |
team1_score = data['innings'][0]['runs'].strip() | |
team1_wick = data['innings'][0]['wickets'].strip() | |
team1_ove = data['innings'][0]['overs'].strip() | |
team2_name = data['other_scores']['international'][2]['team2_name'].strip() | |
team2_score = data['innings'][1]['runs'].strip() | |
team2_wick = data['innings'][1]['wickets'].strip() | |
team2_ove = data['innings'][1]['overs'].strip() | |
recent_runs = '' | |
for recent_over in data['live']['recent_overs']: | |
for run in recent_over: | |
if run['ball'] == '•': | |
run['ball'] = 0 | |
recent_runs = recent_runs + str(run['ball']) + ' ' | |
recent_runs = recent_runs + ' | ' | |
score = str(desc) + '\n\n' + str(team1_name) + ' : ' + str(team1_score) + '/' + str(team1_wick) + ' ' + str(team1_ove) + '' + '\n\n' + str(team2_name) + ' : ' + str(team2_score) + '/' + str(team2_wick) + ' ' + str(team2_ove) | |
player_status = re.sub(r'.*ov,','', str(player_status)) | |
score = score + '\n\nPlayer status: ' + player_status | |
score = score + '\n\nRecent Overs: ' + recent_runs | |
popup("Score Board:-", score) | |
print score | |
#Fetch the score every 30 secs | |
sleep(30) | |
if __name__ == "__main__": | |
while True: | |
getscore() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment