|
| 1 | +import requests |
| 2 | +from bs4 import BeautifulSoup |
| 3 | +import time |
| 4 | +import notify2 |
| 5 | +notify2.init("CricBuzz") |
| 6 | +n=notify2.Notification(None,icon="/home/rohith-gilla/icon.png") |
| 7 | +n.set_urgency(notify2.URGENCY_NORMAL) |
| 8 | +n.set_timeout(1000) |
| 9 | +url="http://synd.cricbuzz.com/j2me/1.0/livematches.xml" |
| 10 | +r=requests.get(url) |
| 11 | +soup=BeautifulSoup(r.content,'html.parser') |
| 12 | +temp=soup.find_all('match') |
| 13 | +series_names=[] |
| 14 | +datapath=[] |
| 15 | +for i in temp: |
| 16 | + i=str(i) |
| 17 | + i=i.split('datapath')[1] |
| 18 | + i=i.split('"') |
| 19 | + datapath.append(i[1]) |
| 20 | + series_names.append(i[13]) |
| 21 | +for i in range(len(datapath)): |
| 22 | + print str(i+1)+")"+series_names[i] |
| 23 | +ip=input("Enter the match number: ") |
| 24 | +datapath=datapath[ip-1] |
| 25 | +series_names=series_names[ip-1] |
| 26 | +com_url=datapath+"commentary.xml" |
| 27 | +old_overs="0" |
| 28 | +counter=0; |
| 29 | +loop_v=0 |
| 30 | +while(loop_v==0): |
| 31 | + r=requests.get(com_url) |
| 32 | + soup=BeautifulSoup(r.content,'html.parser') |
| 33 | + try: |
| 34 | + temp=soup.find('c') |
| 35 | + comm=str(temp) |
| 36 | + comm=comm.replace('<c><![CDATA[',"") |
| 37 | + comm=comm.replace("]]></c>","") |
| 38 | + test=comm |
| 39 | + except: |
| 40 | + counter+=1 |
| 41 | + pass |
| 42 | + temp=str(soup.find_all('mscr')) |
| 43 | + bat_tem=temp.split('sname="')[1].split('"')[0] |
| 44 | + runs=temp.split('r="')[3] |
| 45 | + runs=runs.split('"')[0] |
| 46 | + wickets=temp.split('wkts="')[1] |
| 47 | + wickets=wickets.split('"')[0] |
| 48 | + overs=temp.split('ovrs') |
| 49 | + overs=overs[1] |
| 50 | + overs=overs.split('"')[1] |
| 51 | + batsman=temp.split('btsmn') |
| 52 | + try: |
| 53 | + bat1=batsman[1].split('sname="')[1].split('"')[0] |
| 54 | + r1=batsman[1].split('r="')[1].split('"')[0] |
| 55 | + except: |
| 56 | + counter+=1 |
| 57 | + pass |
| 58 | + try: |
| 59 | + bat2=batsman[3].split('sname="')[1].split('"')[0] |
| 60 | + r2=batsman[3].split('r="')[1].split('"')[0] |
| 61 | + except: |
| 62 | + counter+=1 |
| 63 | + pass |
| 64 | + # print "____"*20 |
| 65 | + n.update(bat_tem+":"+runs + "/"+wickets + " Overs : "+str(overs)) |
| 66 | + if(old_overs ==overs): |
| 67 | + pass |
| 68 | + else: |
| 69 | + print "____"*20 |
| 70 | + print comm |
| 71 | + print "Score :"+runs + "/"+wickets |
| 72 | + print "Overs :"+str(overs) |
| 73 | + try: |
| 74 | + print bat1+" :"+r1," "+bat2+" :"+r2 |
| 75 | + n.update(bat_tem+" :"+runs + "/"+wickets + "Overs : "+str(overs),bat1+" :"+r1+" "+bat2+" :"+r2) |
| 76 | + except: |
| 77 | + pass |
| 78 | + old_overs=overs |
| 79 | + n.show() |
| 80 | + if(int(wickets)==10): |
| 81 | + loop_v=1 |
| 82 | + time.sleep(15) |
| 83 | +# print datapath,series_names |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +# print datapath |
| 93 | +# print series_names |
0 commit comments