Beispiel #1
0
def score():
        c=Cricbuzz()
        matches=c.matches()
        post_id1=request.form.get('live score')
        post_id2=request.form.get('commentary')
        post_id3=request.form.get('scorecard')
        if post_id1 is not None:
                #print(matches)
                x=[]
                cnt=0
                for match in matches:
                        x.append(json.dumps(c.livescore(match['id']),indent=4))
                        cnt+=1
                q=1
                return render_template('score.html',y=x,count=cnt,id=q)
        if post_id2 is not None:
                x=[]
                cnt=0
                for match in matches:
                        x.append(json.dumps(c.commentary(match['id']),indent=4))
                        cnt+=1
                q=2
                return render_template('score.html',y=x,count=cnt,id=q)
        if post_id3 is not None:
                x=[]
                cnt=0
                for match in matches:
                         x.append(json.dumps(c.livescore(match['id']),indent=4))
                         cnt+=1
                q=3
                return render_template('score.html',y=x,count=cnt,id=3)
Beispiel #2
0
def fun():
	#we enter our Twilio accoundSid and authToken
	accountSid 		= "SKf3e6cefcec4f940c1d64c160d88c4770"
	authToken  		= "09jT4lchanP7hKoUqc5xLX8ZDy4mxDfE"
	# connecting to TWILIO API
	twilioClient	= Client(accountSid, authToken)
	myTwilioNumber 	= ""
	destCellPhone 	= ""
	#url = "http://synd.cricbuzz.com/j2me/1.0/livematches.xml"
	#to extract the matches 
	cric       		= Cricbuzz()
	details			= cric.matches()
 
	#To filter out the None objects from details
	details=filter(None, details)
	message="No match in progress"
 
	for i in details:
		# traversing i
		if 'mchstate' in i:
			if i['mchstate']== 'inprogress':
				id= i['id']
				main=cric.livescore(id)
				ms =main['batting']['score'][0]
				bat1=main['batting']['batsman'][0]
				bat2=main['batting']['batsman'][1]
				#print(bat1['name'])
				message=i['srs']+ "      "+"Format: "+i['type'] +  "\n" + "Score: " +main['batting']['team']+" "+ms['runs'] +'/'+ms['wickets'] +" ("+ms['overs']+")"+"\n" +bat1['name']+":"+bat1['runs']+"("+bat1['balls']+")   "+ bat2['name']+":"+bat1['runs']+"("+bat2['balls']+")"
 
	#Generates the message
	notify2.init("Live Score")
	# shows notification on out desktop
	notify2.Notification("Match currently in progress:",message).show()
Beispiel #3
0
def fun():
    # url = "http://synd.cricbuzz.com/j2me/1.0/livematches.xml"
    # to extract the matches
    cric = Cricbuzz()
    details = cric.matches()
    # print(details)
    # To filter out the None objects from details
    details = filter(None, details)
    message = "No match in progress"
    for i in details:
        # traversing i
        if 'mchstate' in i:
            print('Series ==>' + i['srs'])  # List All Current Series
            # print('mchstate ==>' + i['mchstate'])  # List All Current Series
            if i['mchstate'] in ['inprogress','stump','rain'] and i['srs'] == 'Ranji Trophy 2019-20':
            # if i['mchstate'] == 'innings break':
            # if i['mchstate'] in ('inprogress','innings break'):
                id = i['id']
                main = cric.livescore(id)
                ms = main['batting']['score'][0]
                bat1 = main['batting']['batsman'][0]
                bat2 = main['batting']['batsman'][1]
                curr_bowler = main['bowling']['bowler'][0]
                # print(bat1['name'])
                # print(curr_bowler['name','overs','runs','wickets'])
                message = "\n" + i['srs'] + "      " + "\n" + "Format: " + i['type'] + "\n" + "Score: " + main['batting'][
                    'team'] + " " + ms['runs'] + '/' + ms['wickets'] + " (" + ms['overs'] + ")" + "\n" + bat1[
                              'name'] + ": " + bat1['runs'] + "(" + bat1['balls'] + ")   " + bat2['name'] + ": " + bat2[
                              'runs'] + "(" + bat2['balls'] + ")" + "\n" + curr_bowler['name'] + ": " + curr_bowler['overs'] + "-" + curr_bowler['runs'] + "-" + curr_bowler['wickets']
    # Generates the message
    print(message)
    return message
class LiveScores():
    def __init__(self):
        self.c=Cricbuzz()
        self.all_matches = self.c.matches()
    def gonoobs(self):
        print('---LIVE SCORES---')
        count=0
        for match in reversed(self.all_matches):
            try:
                batting_data=self.c.livescore(match['id'])['batting']
                bowling_data=self.c.livescore(match['id'])['bowling']
                '''
                print(batting_data)
                print(batting_data['team'],':',batting_data['score'][0]['runs'],'/',batting_data['score'][0]['wickets'],'Overs:',batting_data['score'][0]['overs'])
                print('versus ',bowling_data['team'])
                print('status:',self.c.matchinfo(match['id'])['status'])
                count+=1
                #print(self.c.scorecard(match['id']))
                '''
                count+=1
                innings='second' if batting_data['score'][0]['inning_num']=='2' else 'first'
                assistant.say('match '+batting_data['team']+' versus '+bowling_data['team'])
                assistant.say(innings+' innings '+batting_data['team']+' is batting with score '+batting_data['score'][0]['runs']+' at '+batting_data['score'][0]['wickets'])
                gui_obj.widg_obj.BotM('in '+batting_data['score'][0]['overs']+' overs')
                speak('in '+batting_data['score'][0]['overs']+' overs')                

            except:
                pass
        if count==0:
            gui_obj.widg_obj.BotM('NO LIVE MATCHES NOW')
            speak('NO LIVE MATCHES NOW')
def fun():
    #we enter our Twilio accoundSid and authToken(find it on twilio account settings)
    accountSid = "your accoundSid"
    authToken = "your authToken"
    # connecting to TWILIO API
    # twilioClient  = Client(accountSid, authToken)
    myTwilioNumber = "your twilio number"
    destCellPhone = "your mobile number"

    # url = "http://synd.cricbuzz.com/j2me/1.0/livematches.xml"
    # url = "https://www.cricbuzz.com/sitemap/index.xml"
    #to extract the matches
    cric = Cricbuzz()
    details = cric.matches()

    # print details
    # print "asdglavdlhavfhjsvlhvf.vsfksfjbsfjbsrfjbsdfjbsribfjsbfkefv"
    exit()
    #To filter out the None objects from details
    details = filter(None, details)
    message = "No match in progress"
    for i in details:
        if i["id"] == '8':
            # traversing i
            if 'mchstate' in i:
                if i['mchstate'] == 'inprogress':
                    id = i['id']
                    main = cric.livescore(id)
                    ms = main['batting']['score'][0]
                    if len(main['batting']['batsman'][0]) != 0 and len(
                            main['batting']['batsman'][1]) != 0:
                        bat1 = main['batting']['batsman'][0]
                        bat2 = main['batting']['batsman'][1]
                        bowl1 = main['bowling']['bowler'][0]
                        bowl2 = main['bowling']['bowler'][1]
                        message = i['srs'] + "      " + "Format: " + i[
                            'type'] + "\n \n" + "Score: " + main['batting'][
                                'team'] + " " + ms['runs'] + '/' + ms['wickets'] + " (" + ms[
                                    'overs'] + ")" + "\n \n" + bat1['name'] + ":" + bat1[
                                        'runs'] + "(" + bat1['balls'] + ")   " + bat2[
                                            'name'] + ":" + bat1['runs'] + "(" + bat2[
                                                'balls'] + ")" + "\n \n" + bowl1[
                                                    'name'] + ": overs-" + bowl1[
                                                        'overs'] + " wickets " + bowl1[
                                                            'wickets'] + "\n \n" + bowl2[
                                                                'name'] + ": overs- " + bowl2[
                                                                    'overs'] + " wickets " + bowl2[
                                                                        'wickets']
                    else:
                        message = "WICKET!!!!"

    #Generates the message
    notify2.init("Live Score")
    # shows notification on out desktop
    notify2.Notification("Match currently in progress:", message).show()
    # sends the notification to our mobile
    #myMessage = twilioClient.messages.create(body = "Match Currently in progress: " + message, from_=myTwilioNumber, to=destCellPhone)
    #shows notification after every 60 seconds
    time.sleep(60)
Beispiel #6
0
def live_score(mid):
    match_live_score = []
    c = Cricbuzz()
    lscore = c.livescore(mid)
    print("***********")
    print(json.dumps(lscore, indent=4, sort_keys=True))
    match_live_score.append(lscore)
    return jsonify({'Live score ': match_live_score})
def home_page():

    c = Cricbuzz()

    all_matches = c.matches()

    for match in all_matches:

        if match['mchstate'] == 'inprogress' or match[
                'mchstate'] == 'innings break':
            mongo.db.inprogress.insert(match)
            mongo.db.inprogressmatchid.insert({"matchid": match['id']})
            c.livescore(match['id'])['id'] = match['id']
            mongo.db.inprogressscore.insert(c.livescore(match['id']))
            mongo.db.inprogressscorecard.insert(c.scorecard(match['id']))

    return render_template("index.html")
Beispiel #8
0
def fun():
    # we enter our Twilio accoundSid and authToken
    # accountSid = ""
    # authToken = ""
    # connecting to TWILIO API
    # twilioClient = Client(accountSid, authToken)
    # myTwilioNumber = ""
    # destCellPhone = ""

    # url = "http://synd.cricbuzz.com/j2me/1.0/livematches.xml"
    # to extract the matches
    cric = Cricbuzz()
    details = cric.matches()
    # print(details)
    # To filter out the None objects from details
    details = filter(None, details)
    message = "No match in progress"
    for i in details:
        # traversing i
        if 'mchstate' in i:
            # print('Series ==>' + i['srs'])  # List All Current Series
            if i['mchstate'] == 'inprogress' and i[
                    'srs'] == 'India tour of New Zealand 2020':
                # if i['mchstate'] == 'innings break':
                # if i['mchstate'] in ('inprogress','innings break'):
                id = i['id']
                main = cric.livescore(id)
                ms = main['batting']['score'][0]
                bat1 = main['batting']['batsman'][0]
                bat2 = main['batting']['batsman'][1]
                curr_bowler = main['bowling']['bowler'][0]
                # print(bat1['name'])
                # print(curr_bowler['name','overs','runs','wickets'])
                message = i['srs'] + "      " + "Format: " + i[
                    'type'] + "\n" + "Score: " + main['batting']['team'] + " " + ms[
                        'runs'] + '/' + ms['wickets'] + " (" + ms[
                            'overs'] + ")" + "\n" + bat1['name'] + ":" + bat1[
                                'runs'] + "(" + bat1['balls'] + ")   " + bat2[
                                    'name'] + ":" + bat2['runs'] + "(" + bat2[
                                        'balls'] + ")" + "\n" + curr_bowler[
                                            'name'] + ": " + curr_bowler[
                                                'overs'] + "-" + curr_bowler[
                                                    'runs'] + "-" + curr_bowler[
                                                        'wickets']
    # Generates the message
    print(message)
    # notify2.init("Live Score")
    baloontip.__init__('Live Score')
    # shows notification on out desktop
    # notify2.Notification("Match currently in progress:", message).show()
    n = baloontip.balloon_tip("Match currently in progress: ", message).show()
    # sends the notification to our mobile
    # myMessage = twilioClient.messages.create(body="Match Currently in progress: " + message, from_=myTwilioNumber,
    #                                          to=destCellPhone)
    # shows notification after every 60 seconds
    time.sleep(60)
Beispiel #9
0
def alldetail(request, id):
    c = Cricbuzz()
    #print (c.scorecard(match['id']))
    alldetail = c.scorecard(id)

    matches = c.matches()
    bat1 = 0
    bowl1 = 0
    fall_wickets1 = 0
    #return JsonResponse({"alldetail":alldetail})
    try:
        bat = alldetail['scorecard'][0]['batcard']
        bowl = alldetail['scorecard'][0]['bowlcard']
        fall_wickets = alldetail['scorecard'][0]['fall_wickets']
    except:
        pass
    try:
        bat1 = alldetail['scorecard'][1]['batcard']
        bowl1 = alldetail['scorecard'][1]['bowlcard']
        fall_wickets1 = alldetail['scorecard'][1]['fall_wickets']
    except:
        pass

    lscore = c.livescore(id)
    overin2 = 0
    overin3 = 0
    overin1 = 0
    overin4 = 0
    try:
        overin1 = lscore['batting']['score'][0]['overs']
        overin3 = lscore['bowling']['score'][0]['overs']
        overin2 = lscore['batting']['score'][1]['overs']
        overin4 = lscore['bowling']['score'][1]['overs']

    except:
        pass

    #return JsonResponse({"bat1":fall_wickets1})

    return render(
        request, "cric/scorecard2.html", {
            "alldetail": alldetail,
            "bat": bat,
            "bowl": bowl,
            "fall_wickets": fall_wickets,
            "bat1": bat1,
            "bowl1": bowl1,
            "fall_wickets1": fall_wickets1,
            "lscore": lscore,
            "overin2": overin2,
            "overin3": overin3,
            "overin1": overin1,
            "overin4": overin4,
            "matches": matches,
        })
def live_score(mid):
    c = Cricbuzz()
    lscore = c.livescore(mid)
    if lscore == {}:
        pass
    else:
        print("-------------------------------------------")
        print("Innings No : " + lscore["batting"]["score"][0]["inning_num"])
        print( lscore["batting"]["team"] +   " : " + lscore["batting"]["score"][0]["runs"] + "/" + 
        lscore["batting"]["score"][0]["wickets"] + " in " + lscore["batting"]["score"][0]["overs"] + " overs" )
        message = lscore["batting"]["team"]  +   " : " + lscore["batting"]["score"][0]["runs"] + "/" + lscore["batting"]["score"][0]["wickets"] + " in " + lscore["batting"]["score"][0]["overs"] + " overs"
        n.show_toast("LIVE MATCH SCORE",message, duration = 10)
Beispiel #11
0
def index():
  c = Cricbuzz()
  match = c.matches()
  mid = (match[0]['id'])
  livescore = c.livescore(mid=mid)
  scorecard = c.scorecard(mid=mid)
  matchinfo = c.matchinfo(mid=mid)
  commentary = c.commentary(mid=mid)

  result = {"matches": match, "livescore": livescore, "scorecard": scorecard, "matchinfo": matchinfo, "commentary": commentary}
  final = jsonify(result)
  return f"{final}"
Beispiel #12
0
 def get_cricket_response(self, message: Dict[str, str],
                          bot_handler: Any) -> str:
     content = message['content']
     words = content.lower().split()
     c = Cricbuzz()
     matches = c.matches()
     val = "\n" + match + "\n"
     for match in matches:
         if (match['mchstate'] != 'nextlive'):
             val = val + c.livescore(match['id']) + "\n"
             val = val + c.commentary(match['id']) + "\n"
             val = val + c.scorecard(match['id']) + "\n"
     return val
Beispiel #13
0
def fun():
    #we enter our Twilio accoundSid and authToken
    accountSid = "###############################"
    authToken = "###############################"
    # connecting to TWILIO API
    twilioClient = Client(accountSid, authToken)
    myTwilioNumber = "#"
    destCellPhone = "#"

    #url = "http://synd.cricbuzz.com/j2me/1.0/livematches.xml"
    #to extract the matches
    cric = Cricbuzz()
    details = cric.matches()

    #To filter out the None objects from details
    details = filter(None, details)
    message = "No match in progress"

    for i in details:
        # traversing i
        if 'mchstate' in i:
            if i['mchstate'] == 'inprogress':
                id = i['id']
                main = cric.livescore(id)
                ms = main['batting']['score'][0]
                bat1 = main['batting']['batsman'][0]
                bat2 = main['batting']['batsman'][1]
                #print(bat1['name'])
                message = i['srs'] + "      " + "Format: " + i[
                    'type'] + "\n" + "Score: " + main['batting'][
                        'team'] + " " + ms['runs'] + '/' + ms[
                            'wickets'] + " (" + ms['overs'] + ")" + "\n" + bat1[
                                'name'] + ":" + bat1['runs'] + "(" + bat1[
                                    'balls'] + ")   " + bat2[
                                        'name'] + ":" + bat1[
                                            'runs'] + "(" + bat2['balls'] + ")"

    #Generates the message
    notify2.init("Live Score")
    # shows notification on out desktop
    notify2.Notification("Match currently in progress:", message).show()
    # sends the notification to our mobile
    myMessage = twilioClient.messages.create(
        body="Match Currently in progress: " + message,
        from_=myTwilioNumber,
        to=destCellPhone)
    #shows notification after every 60 seconds
    time.sleep(60)
Beispiel #14
0
def refresh():
    c = Cricbuzz()
    match = c.matches()
    mid = match[1]['id']
    matches = match[1]
    livescore = c.livescore(mid=mid)
    scorecard = c.scorecard(mid=mid)
    matchinfo = c.matchinfo(mid=mid)
    commentary = c.commentary(mid=mid)
    result = {}
    result['matches'] = matches
    result['livescore'] = livescore
    result['scorecard'] = scorecard
    result['matchinfo'] = matchinfo
    result['commentary'] = commentary
    return result
Beispiel #15
0
class Cricket(object):
    def __init__(self):
        self.c = Cricbuzz()
    def score(self):
        matches = self.c.matches()
        val = '\n'
        for match in matches:
            if match['mchstate'] != 'nextlive':
                d = (self.c.livescore(match['id'])['matchinfo'])
                val += 'Match Description: ' + d['mchdesc']+', '+d['srs']+'.\n'
                val += 'Match Type: ' + d['type'] + '\n'
                val += 'Match State: ' + d['mchstate'] + '\n'
                val += 'Match Status: ' + d['status'] + '.\n\n'
        if val == '\n':
            return "No Match Updates.. :("
        return val
def checkbut():
    matid = request.form['matchid']

    c = Cricbuzz()
    all_matches = c.matches()

    for match in all_matches:

        if match['mchstate'] == 'inprogress' or match[
                'mchstate'] == 'innings break' or match[
                    'mchstate'] == 'mom' or match['mchstate'] == 'complete':

            result = mongo.db.live.insert(c.livescore(matid))

            return render_template("score.html",
                                   result=mongo.db.live.find({"_id": result}))
Beispiel #17
0
def cricket():
    c = Cricbuzz()
    match = c.matches()
    mid = (match[0]['id'])
    livescore = c.livescore(mid=mid)
    scorecard = c.scorecard(mid=mid)
    matchinfo = c.matchinfo(mid=mid)
    commentary = c.commentary(mid=mid)

    result = [{
        "matches": match,
        "livescore": livescore,
        "scorecard": scorecard,
        "matchinfo": matchinfo,
        "commentary": commentary
    }]
    return result
Beispiel #18
0
def do_something(sc): 
	print "Doing stuff..."
	global previous_run
	global previous_wicket
	
    # do your stuff

	c = Cricbuzz()
	matches = c.matches()
	for match in matches:
		print match
		if(match['srs'] == 'Indian Premier League, 2018'):
			# print match
			score = c.livescore(match['id'])['batting']['score']
			print score
			print c.commentary(match['id'])
			runs = int(score[0]['runs'])
			wicket = int(score[0]['wickets'])
			overs = (score[0]['overs'])
			print "---------------------"
			break
	
	diff_wicket = wicket - previous_wicket
	print "Diff wicket" + str(diff_wicket)
	if(diff_wicket>0):
		print "OUTTTTTTT"
		timer_video("Out", overs)
		
	diff_runs = runs - previous_run
	print "Diff Runs " + str(diff_runs)
	if(diff_runs>=4):
		print 4
		timer_video("Boundry",overs)
		## do something
	elif(diff_runs==3):
		print 3
		## do another thing
	elif(diff_runs==2):
		print 2
		## do third thing
	elif(diff_runs==1):
		print 1
	
	previous_run = runs
	previous_wicket = wicket
	s.enter(2, 1, do_something, (sc,))
Beispiel #19
0
class CricketScores():
    def __init__(self):
        self.c=Cricbuzz()
        self.all_matches = self.c.matches()
    def todays_matches(self):
        pass
    def all_matches_nearby(self):
        for match in self.all_matches:
            print(match['team1']['name'],'vs',match['team2']['name'])
    def all_matches_nearby_with_status(self):
        for match in self.all_matches:
            print(match['team1']['name'],'vs',match['team2']['name'])
            print(match['status'])
    def upcoming_matches(self):
        print('---ALL UPCOMING MATCHES---')
        count=0
        for match in self.all_matches:
            if 'Starts' in match['status']:
                count+=1
                print(match['team1']['name'],'vs',match['team2']['name'])
                print(match['status'])
        if count==0:
            print('No matches nearby')
    def live_scores(self):
        print('---LIVE SCORES---')
        count=0
        for match in reversed(self.all_matches):
            try:
                batting_data=self.c.livescore(match['id'])['batting']
                bowling_data=self.c.livescore(match['id'])['bowling']
                print(batting_data)
                print(batting_data['team'],':',batting_data['score'][0]['runs'],'/',batting_data['score'][0]['wickets'],'Overs:',batting_data['score'][0]['overs'])
                print('versus ',bowling_data['team'])
                print('status:',self.c.matchinfo(match['id'])['status'])
                count+=1
                #print(self.c.scorecard(match['id']))

                innings='second' if batting_data['score'][0]['inning_num']=='2' else 'first'
                assistant.say('match '+batting_data['team']+' versus '+bowling_data['team'])
                assistant.say(innings+' innings '+batting_data['team']+' is batting with score '+batting_data['score'][0]['runs']+' at '+batting_data['score'][0]['wickets'])
                speak('in '+batting_data['score'][0]['overs']+' overs')

            except:
                pass
        if count==0:
            print('NO LIVE MATCHES NOW')
Beispiel #20
0
def buzz():
    c = Cricbuzz()
    matches = c.matches()
    h = c.livescore(['4'])
    print(h)
    result = []
    l = []
    l.append(h['matchinfo']['status'])
    l.append(h['batting']['team'])
    l.append(h['batting']['score'][0]['overs'] + "overs")
    l.append(h['batting']['score'][0]['runs'] + "/" +
             h['batting']['score'][0]['wickets'])

    #l.append(h['bowling']['team'])
    #l.append(h['bowling']['score'][0]['overs']+"overs")
    #l.append(h['bowling']['score'][0]['runs']+"/"+h['bowling']['score'][0]['wickets'])

    summary = " ".join(l)

    batting = []
    for i in range(len(h['batting']['batsman'])):
        batting.append(h['batting']['batsman'][i]['name'])
        batting.append(h['batting']['batsman'][i]['runs'] + "(" +
                       h['batting']['batsman'][i]['balls'] + ")")

    m = " ".join(batting)
    bowling = []
    for i in range((len(h['bowling']['bowler']))):
        bowling.append(h['bowling']['bowler'][i]['name'])
        bowling.append(h['bowling']['bowler'][i]['overs'] + "overs")
        bowling.append(h['bowling']['bowler'][i]['runs'] + "runs")
        bowling.append(h['bowling']['bowler'][i]['wickets'] + "wickets")
    bow = " ".join(bowling)

    com_list = []
    com = c.commentary(['1'])
    for i in range(2):
        com_list.append(com['commentary'][i])

    result.append(summary)
    result.append(m)
    result.append(bow)
    result.append("\n".join(com_list))
    return (result)
Beispiel #21
0
async def current_score(ctx):
    match = Cricbuzz()
    try:
        details = match.livescore(match_id())
        embed1 = discord.Embed(
            title=f"Current Batting Team : {details['batting']['team']}",
            colour=discord.Colour.red())
    except:
        await ctx.send('abe saale abhi to koi game nahi chal raha hai')
        return

    embed1.add_field(
        name=f"Batsman Name : {details['batting']['batsman'][0]['name']}",
        value=f"Runs Scored : {details['batting']['batsman'][0]['runs']}\n"
        f"Balls Faced : {details['batting']['batsman'][0]['balls']}\n"
        f"Fours Hit : {details['batting']['batsman'][0]['fours']}\n"
        f"Sixes Hit : {details['batting']['batsman'][0]['six']}\n",
        inline=False)

    embed1.add_field(
        name=f"Batsman Name : {details['batting']['batsman'][1]['name']}",
        value=f"Runs Scored : {details['batting']['batsman'][1]['runs']}\n"
        f"Balls Faced : {details['batting']['batsman'][1]['balls']}\n"
        f"Fours Hit : {details['batting']['batsman'][1]['fours']}\n"
        f"Sixes Hit : {details['batting']['batsman'][1]['six']}\n",
        inline=False)

    await ctx.send(embed=embed1)

    embed2 = discord.Embed(
        title=f"Current Bowling Team : {details['bowling']['team']}",
        colour=discord.Colour.green())

    embed2.add_field(
        name=f"Bowler Name : {details['bowling']['bowler'][0]['name']}",
        value=f"Overs Done : {details['bowling']['bowler'][0]['overs']}\n"
        f"Runs Given : {details['bowling']['bowler'][0]['runs']}\n"
        f"Wickets Taken : {details['bowling']['bowler'][0]['wickets']}",
        inline=False)

    await ctx.send(embed=embed2)
Beispiel #22
0
def cricCommentry():
    c = Cricbuzz()
    matches = c.matches()
    # for match in matches:
    match = matches[0]
    # print( match)
    if (match['mchstate'] != 'nextlive'):
        print(c.livescore(match['id']))
        print(c.commentary(match['id']))
        print(c.scorecard(match['id']))
    print('sun', c.commentary(match['id'])['commentary'][0]['comm'])
    a, b = c.commentary(match['id'])['commentary'][0]['comm'], ''
    while (1):
        if (a != b):
            # speak(a)
            d = c.scorecard(match['id'])['scorecard']
            print(a)
            print(d[0]['batteam'], 'score is ', d[0]['runs'], 'for',
                  d[0]['wickets'], 'wickets')
            b = a
        else:
            a = c.commentary(match['id'])['commentary'][0]['comm']
Beispiel #23
0
        print(
            "Looks like No match is going on right now...Check the schedule and come back when it starts..\n"
        )

    else:

        print("\nSelect Match: ")
        print("\n" + series.center(60, '-') + "\n")
        for i in range(len(matches)):
            series = matches[i]['srs']
            if series != tempSeries:
                print("\n" + series.center(60, '-') + "\n")
                tempSeries = series

            if (matches[i]['mchstate'] == 'inprogress'):
                battingTeam = c.livescore(matches[i]['id'])['batting']['team']
                bowlingTeam = c.livescore(matches[i]['id'])['bowling']['team']
                print(str(i) + ". " + (battingTeam) + "  vs  " + (bowlingTeam))

        print("\nMatch ID: ", end="  ")
        i = input()
        i = int(i)
        print("\n")

        def battingTeam():
            battingTeam = c.livescore(matches[i]['id'])['batting']['team']
            return battingTeam

        def bowlingTeam():
            bowlingTeam = c.livescore(matches[i]['id'])['bowling']['team']
            return bowlingTeam
Beispiel #24
0
class Cricket():
    """
    Enter cricket and follow the instructions
    """
    def __init__(self):
        self.c = Cricbuzz()

    def __call__(self, jarvis, s):
        self._refresh()
        self.score(jarvis)

    def _refresh(self):
        self.all_match_data = self.c.matches()
        self.matches = []
        d = {}
        for match in self.all_match_data:
            d['id'] = match['id']
            d['srs'] = match['srs']
            d['mnum'] = match['mnum']
            self.matches.append(d.copy())

    def live_score(self, index):
        if self.all_match_data[index]['mchstate'] == 'preview':
            return (Fore.RED + "MATCH YET TO BEGIN")
        selected_match = self.all_match_data[index]
        data = self.c.livescore(self.matches[index]['id'])
        score = {}
        score['matchinfo'] = "{}, {}".format(selected_match['srs'],
                                             selected_match['mnum'])
        score['status'] = "{}".format(selected_match['status'])
        score['bowling'] = data['bowling']
        score['batting'] = data['batting']

        text = ''
        text += Fore.LIGHTYELLOW_EX + score['matchinfo'] + '\n' + score[
            'status'] + '\n\n'

        text += Fore.BLUE + score['batting']['team'] + Fore.BLACK
        for scr in reversed(score['batting']['score']):
            text += " :- {}/{} in {} overs\n".format(scr['runs'],
                                                     scr['wickets'],
                                                     scr['overs'])
        for b in reversed(score['batting']['batsman']):
            text += "{} : {}({}) \n".format(b['name'].strip('*'), b['runs'],
                                            b['balls'])

        text += Fore.BLUE + '\n' + score['bowling']['team'] + Fore.BLACK
        for scr in reversed(score['bowling']['score']):
            text += " :- {}/{} in {} overs\n".format(scr['runs'],
                                                     scr['wickets'],
                                                     scr['overs'])
        for b in reversed(score['bowling']['bowler']):
            text += "{} : {}/{} \n".format(b['name'].strip('*'), b['wickets'],
                                           b['runs'])
        text += Fore.RESET

        return text

    def commentary(self, index):
        selected_match = self.all_match_data[index]
        data = self.c.commentary(self.matches[index]['id'])
        comm = {}
        comm['matchinfo'] = "{}, {}".format(selected_match['srs'],
                                            selected_match['mnum'])
        comm['status'] = "{}".format(selected_match['status'])
        comm['commentary'] = data['commentary']
        text = []
        for com in comm['commentary']:
            line = ''
            if com['over']:
                line += com['over'] + ' : '
            line += "{}\n\n".format(com['comm'])
            # doing bold breaklines and italics looks good in terminal
            text.append(
                line.replace('<b>', '\033[1m').replace(
                    '</b>', '\033[0m').replace('<br/>', '\n').replace(
                        '<i>', '\x1B[3m').replace('</i>', '\x1B[23m'))

        text.reverse()

        commentary = Fore.LIGHTYELLOW_EX + comm['matchinfo'] + '\n' + comm[
            'status'] + '\n\n' + Fore.RESET
        for line in text:
            commentary += line

        return commentary

    def scorecard(self, index):
        selected_match = self.all_match_data[index]
        data = self.c.scorecard(self.matches[index]['id'])
        card = {}
        card['matchinfo'] = "{}, {}".format(selected_match['srs'],
                                            selected_match['mnum'])
        card['status'] = "{}".format(selected_match['status'])
        card['scorecard'] = data['scorecard']
        text = ''
        text += Fore.LIGHTYELLOW_EX + card['matchinfo'] + '\n' + card[
            'status'] + '\n\n'
        text += Fore.BLACK + '*' * 35 + '\n\n'

        for scr in reversed(card['scorecard']):
            text += Fore.LIGHTYELLOW_EX + "{}\nInnings: {}\n{}/{} in {} overs\n\n".format(
                scr['batteam'], scr['inng_num'], scr['runs'], scr['wickets'],
                scr['overs'])
            text += Fore.BLUE + "Batting\n"
            text += Fore.RED + "{:<17} {:<3} {:<3} {:<3} {}\n\n".format(
                'Name', 'R', 'B', '4', '6')
            for b in scr['batcard']:
                text += Fore.BLACK + "{:<17} {:<3} {:<3} {:<3} {}\n{}\n\n".format(
                    b['name'], b['runs'], b['balls'], b['fours'], b['six'],
                    b['dismissal'])
            text += Fore.LIGHTYELLOW_EX + "-" * 35 + "\n\n"
            text += Fore.BLUE + "Bowling\n"
            text += Fore.RED + "{:<17} {:<5} {:<3} {:<3} {}\n\n".format(
                'Name', 'O', 'M', 'R', 'W')
            for b in scr['bowlcard']:
                text += Fore.BLACK + "{:<17} {:<5} {:<3} {:<3} {}\n\n".format(
                    b['name'], b['overs'], b['maidens'], b['runs'],
                    b['wickets'])
            text += Fore.BLUE + '*' * 35 + '\n\n'
        return text

    def score(self, jarvis):
        print(Fore.RED + "\nALL MATCHES\n" + Fore.LIGHTBLUE_EX)
        if self.matches == []:
            print("No Matches Being Played!\n", Fore.RED)
            return
        for i, m in enumerate(self.matches, 1):
            print("{}. {} {}".format(str(i), m['srs'], m['mnum']))
        while 1:
            try:
                choice = int(
                    input(Fore.RED + '\nEnter choice (number): ' + Fore.RESET))
                while choice < 1 or choice > len(self.matches):
                    print(Fore.BLACK + '\nWrong choice')
                    choice = int(
                        input(Fore.RED + '\nEnter choice again: ' +
                              Fore.RESET))
                break
            except ValueError:
                print("Invalid type of choice. Please enter an integer number")

        selected_match_id = choice - 1
        print('')
        res = self.live_score(selected_match_id)
        print(res)

        if (res == Fore.RED + "MATCH YET TO BEGIN"):
            return

        while True:
            print(Fore.LIGHTBLUE_EX + '1. Full Score Card')
            print('2. Commentary')
            print('3. Refresh Score')
            print('4. Quit' + Fore.RESET)

            while 1:
                try:
                    choice = int(
                        input(Fore.RED + '\nEnter choice (number): ' +
                              Fore.RESET))
                    while choice < 1 or choice > 4:
                        print(Fore.BLACK + '\nWrong choice')
                        choice = int(
                            input(Fore.RED + '\nEnter choice again: ' +
                                  Fore.RESET))
                    break
                except ValueError:
                    print(
                        "Invalid type of choice. Please enter an integer number"
                    )
            print('')

            if choice == 1:
                print(self.scorecard(selected_match_id))
                ref = input(Fore.RED + 'Do you want to refresh:(y/n) ' +
                            Fore.RESET)
                while ref == 'y':
                    print(self.scorecard(selected_match_id))
                    ref = input(Fore.RED + 'Do you want to refresh:(y/n) ' +
                                Fore.RESET)

            elif choice == 2:
                print(self.commentary(selected_match_id))
                ref = input(Fore.RED + 'Do you want to refresh:(y/n) ' +
                            Fore.RESET)
                while ref == 'y':
                    print(self.commentary(selected_match_id))
                    ref = input(Fore.RED + 'Do you want to refresh:(y/n) ' +
                                Fore.RESET)

            elif choice == 3:
                ref = 'y'
                while ref == 'y':
                    print(self.live_score(selected_match_id))
                    ref = input(Fore.RED + 'Do you want to refresh:(y/n) ' +
                                Fore.RESET)

            else:
                return
Beispiel #25
0
import time
from pycricbuzz import Cricbuzz
c=Cricbuzz()
#for match in c.matches():
 # print(match)
  

while True:
  m=dict(c.livescore(1))
  print('{} Runs {}, Overs {}, Wickets {}'.format(m['batting']['team'],m['batting']['score'][0]['runs'],m['batting']['score'][0]['overs'],m['batting']['score'][0]['wickets']))
  time.sleep(30)
Beispiel #26
0
class Cricket():
    """
    Enter cricket and follow the instructions
    """

    def __init__(self):
        self.c = Cricbuzz()

    def __call__(self, jarvis, s):
        self._refresh(jarvis)
        self.score(jarvis)

    def _refresh(self, jarvis):
        spinner = SpinnerThread('Fetching ', 0.15)
        spinner.start()
        self.all_match_data = self.c.matches()
        self.matches = []
        d = {}
        for match in self.all_match_data:
            d['id'] = match['id']
            d['srs'] = match['srs']
            d['mnum'] = match['mnum']
            self.matches.append(d.copy())
        spinner.stop()
        jarvis.say('DONE fetching match details', Fore.GREEN)

    def live_score(self, index):
        if self.all_match_data[index]['mchstate'] == 'preview':
            return(Fore.RED + "MATCH YET TO BEGIN")
        selected_match = self.all_match_data[index]
        data = self.c.livescore(self.matches[index]['id'])
        score = {}
        score['matchinfo'] = "{}, {}".format(
            selected_match['srs'], selected_match['mnum'])
        score['status'] = "{}".format(selected_match['status'])
        score['bowling'] = data['bowling']
        score['batting'] = data['batting']

        text = ''
        text += Fore.LIGHTYELLOW_EX + \
            score['matchinfo'] + '\n' + score['status'] + '\n\n'

        text += Fore.BLUE + score['batting']['team'] + Fore.BLACK
        for scr in reversed(score['batting']['score']):
            text += " :- {}/{} in {} overs\n".format(
                scr['runs'], scr['wickets'], scr['overs'])
        for b in reversed(score['batting']['batsman']):
            text += "{} : {}({}) \n".format(
                b['name'].strip('*'), b['runs'], b['balls'])

        text += Fore.BLUE + '\n' + score['bowling']['team'] + Fore.BLACK
        for scr in reversed(score['bowling']['score']):
            text += " :- {}/{} in {} overs\n".format(
                scr['runs'], scr['wickets'], scr['overs'])
        for b in reversed(score['bowling']['bowler']):
            text += "{} : {}/{} \n".format(b['name'].strip('*'),
                                           b['wickets'], b['runs'])
        text += Fore.RESET

        return text

    def commentary(self, index):
        selected_match = self.all_match_data[index]
        data = self.c.commentary(self.matches[index]['id'])
        comm = {}
        comm['matchinfo'] = "{}, {}".format(
            selected_match['srs'], selected_match['mnum'])
        comm['status'] = "{}".format(selected_match['status'])
        comm['commentary'] = data['commentary']
        text = []
        for com in comm['commentary']:
            line = ''
            if com['over']:
                line += com['over'] + ' : '
            line += "{}\n\n".format(com['comm'])
            # doing bold breaklines and italics looks good in terminal
            text.append(
                line.replace(
                    '<b>',
                    '\033[1m').replace(
                    '</b>',
                    '\033[0m') .replace(
                    '<br/>',
                    '\n').replace(
                    '<i>',
                    '\x1B[3m').replace(
                        '</i>',
                    '\x1B[23m'))

        text.reverse()

        commentary = Fore.LIGHTYELLOW_EX + \
            comm['matchinfo'] + '\n' + comm['status'] + '\n\n' + Fore.RESET
        for line in text:
            commentary += line

        return commentary

    def scorecard(self, index):
        selected_match = self.all_match_data[index]
        data = self.c.scorecard(self.matches[index]['id'])
        card = {}
        card['matchinfo'] = "{}, {}".format(
            selected_match['srs'], selected_match['mnum'])
        card['status'] = "{}".format(selected_match['status'])
        card['scorecard'] = data['scorecard']
        text = ''
        text += Fore.LIGHTYELLOW_EX + \
            card['matchinfo'] + '\n' + card['status'] + '\n\n'
        text += Fore.BLACK + '*' * 35 + '\n\n'

        for scr in reversed(card['scorecard']):
            text += Fore.LIGHTYELLOW_EX + "{}\nInnings: {}\n{}/{} in {} overs\n\n".format(
                scr['batteam'], scr['inng_num'], scr['runs'], scr['wickets'], scr['overs'])
            text += Fore.BLUE + "Batting\n"
            text += Fore.RED + \
                "{:<17} {:<3} {:<3} {:<3} {}\n\n".format('Name', 'R', 'B', '4', '6')
            for b in scr['batcard']:
                text += Fore.BLACK + "{:<17} {:<3} {:<3} {:<3} {}\n{}\n\n".format(
                    b['name'], b['runs'], b['balls'], b['fours'], b['six'], b['dismissal'])
            text += Fore.LIGHTYELLOW_EX + "-" * 35 + "\n\n"
            text += Fore.BLUE + "Bowling\n"
            text += Fore.RED + \
                "{:<17} {:<5} {:<3} {:<3} {}\n\n".format('Name', 'O', 'M', 'R', 'W')
            for b in scr['bowlcard']:
                text += Fore.BLACK + "{:<17} {:<5} {:<3} {:<3} {}\n\n".format(
                    b['name'], b['overs'], b['maidens'], b['runs'], b['wickets'])
            text += Fore.BLUE + '*' * 35 + '\n\n'
        return text

    def score(self, jarvis):
        print(Fore.RED + "\nALL MATCHES\n" + Fore.LIGHTBLUE_EX)
        if self.matches == []:
            print("No Matches Being Played!\n", Fore.RED)
            return
        for i, m in enumerate(self.matches, 1):
            print("{}. {} {}".format(str(i), m['srs'], m['mnum']))
        while True:
            try:
                choice = int(jarvis.input('\nEnter choice (number): ', Fore.RED))
                while choice < 1 or choice > len(self.matches):
                    print(Fore.BLACK + '\nWrong choice')
                    choice = int(jarvis.input('\nEnter choice again: ', Fore.RED))
                break
            except ValueError:
                print("Invalid type of choice. Please enter an integer number")

        selected_match_id = choice - 1
        print('')
        res = self.live_score(selected_match_id)
        print(res)

        if(res == Fore.RED + "MATCH YET TO BEGIN"):
            return

        while True:
            print(Fore.LIGHTBLUE_EX + '1. Full Score Card')
            print('2. Commentary')
            print('3. Refresh Score')
            print('4. Quit' + Fore.RESET)

            while True:
                try:
                    choice = int(jarvis.input('\nEnter choice (number): ', Fore.RED))
                    while choice < 1 or choice > 4:
                        print(Fore.BLACK + '\nWrong choice')
                        choice = int(jarvis.input('\nEnter choice again: ', Fore.RED))
                    break
                except ValueError:
                    print("Invalid type of choice. Please enter an integer number")
            print('')

            if choice == 1:
                print(self.scorecard(selected_match_id))
                ref = jarvis.input('Do you want to refresh:(y/n) ', Fore.RED)
                while ref == 'y':
                    print(self.scorecard(selected_match_id))
                    ref = jarvis.input('Do you want to refresh:(y/n) ', Fore.RED)

            elif choice == 2:
                print(self.commentary(selected_match_id))
                ref = jarvis.input('Do you want to refresh:(y/n) ', Fore.RED)
                while ref == 'y':
                    print(self.commentary(selected_match_id))
                    ref = jarvis.input('Do you want to refresh:(y/n) ', Fore.RED)

            elif choice == 3:
                ref = 'y'
                while ref == 'y':
                    print(self.live_score(selected_match_id))
                    ref = jarvis.input('Do you want to refresh:(y/n) ', Fore.RED)

            else:
                return
Beispiel #27
0
class Cricket(Plugin):
    """
    Enter cricket and follow the instructions
    """
    def __init__(self):
        self.c = Cricbuzz()

    def require(self):
        yield ('network', True)

    def complete(self):
        pass

    def alias(self):
        pass

    def run(self, jarvis, s):
        self.score(jarvis)

    def match_id(self, desc):
        all_matches = self.c.matches()
        for match in all_matches:
            if match['mchdesc'].title() == desc:
                return match['id']
        else:
            return None

    def all_matches(self):
        match_data = self.c.matches()
        matches = []
        for match in match_data:
            matches.append(match['mchdesc'])
        return matches

    def live_score(self, desc):
        mid = self.match_id(desc)
        res = self.c.matches()
        for value in res:
            if value['id'] == mid:
                if value['mchstate'] == 'preview':
                    text = Fore.RED + "MATCH YET TO BEGIN"
                    return text
        data = self.c.livescore(mid)
        score = {}
        score['matchinfo'] = "{}, {}".format(data['matchinfo']['mnum'],
                                             data['matchinfo']['mchdesc'])
        score['status'] = "{}, {}".format(
            data['matchinfo']['mchstate'].title(), data['matchinfo']['status'])
        score['bowling'] = data['bowling']
        score['batting'] = data['batting']

        text = ''
        text += Fore.LIGHTYELLOW_EX + score['matchinfo'] + '\n' + score[
            'status'] + '\n\n'
        text += Fore.BLUE + score['batting']['team'] + '\n' + Fore.BLACK

        for scr in reversed(score['batting']['score']):
            text += "{} :- {}/{} in {} overs\n".format(scr['desc'],
                                                       scr['runs'],
                                                       scr['wickets'],
                                                       scr['overs'])
        for b in reversed(score['batting']['batsman']):
            text += "{} : {}({}) \n".format(b['name'].strip('*'), b['runs'],
                                            b['balls'])
        text += Fore.BLUE + "\n" + score['bowling']['team'] + '\n' + Fore.BLACK
        for scr in reversed(score['bowling']['score']):
            text += "{} :- {}/{} in {} overs\n".format(scr['desc'],
                                                       scr['runs'],
                                                       scr['wickets'],
                                                       scr['overs'])
        for b in reversed(score['bowling']['bowler']):
            text += "{} : {}/{} \n".format(b['name'].strip('*'), b['wickets'],
                                           b['runs'])
        text += Fore.RESET
        return text

    def commentary(self, desc):
        mid = self.match_id(desc)
        data = self.c.commentary(mid)
        comm = {}
        comm['matchinfo'] = "{}, {}".format(data['matchinfo']['mnum'],
                                            data['matchinfo']['mchdesc'])
        comm['status'] = "{}, {}".format(data['matchinfo']['mchstate'].title(),
                                         data['matchinfo']['status'])
        comm['commentary'] = data['commentary']
        text = ''
        text += Fore.LIGHTYELLOW_EX + comm['matchinfo'] + '\n' + comm[
            'status'] + '\n\n' + Fore.RESET
        for com in comm['commentary']:
            text += "{}\n\n".format(com)

        return text

    def scorecard(self, desc):
        mid = self.match_id(desc)
        data = self.c.scorecard(mid)
        card = {}
        card['matchinfo'] = "{}, {}".format(data['matchinfo']['mnum'],
                                            data['matchinfo']['mchdesc'])
        card['status'] = "{}, {}".format(data['matchinfo']['mchstate'].title(),
                                         data['matchinfo']['status'])
        card['scorecard'] = data['scorecard']
        text = ''
        text += Fore.LIGHTYELLOW_EX + card['matchinfo'] + '\n' + card[
            'status'] + '\n\n'
        text += Fore.BLACK + '*' * 35 + '\n\n'

        for scr in reversed(card['scorecard']):
            text += Fore.LIGHTYELLOW_EX + "{} {}\n{}/{} in {} overs\n\n".format(
                scr['batteam'], scr['inngdesc'], scr['runs'], scr['wickets'],
                scr['overs'])
            text += Fore.BLUE + "Batting\n"
            text += Fore.RED + "{:<17} {:<3} {:<3} {:<3} {}\n\n".format(
                'Name', 'R', 'B', '4', '6')
            for b in scr['batcard']:
                text += Fore.BLACK + "{:<17} {:<3} {:<3} {:<3} {}\n{}\n\n".format(
                    b['name'], b['runs'], b['balls'], b['fours'], b['six'],
                    b['dismissal'])
            text += Fore.LIGHTYELLOW_EX + "-" * 35 + "\n\n"
            text += Fore.BLUE + "Bowling\n"
            text += Fore.RED + "{:<17} {:<5} {:<3} {:<3} {}\n\n".format(
                'Name', 'O', 'M', 'R', 'W')
            for b in scr['bowlcard']:
                text += Fore.BLACK + "{:<17} {:<5} {:<3} {:<3} {}\n\n".format(
                    b['name'], b['overs'], b['maidens'], b['runs'],
                    b['wickets'])
            text += Fore.BLUE + '*' * 35 + '\n\n'
        return text

    def score(self, jarvis):
        matches = self.all_matches()
        jarvis.say(Fore.RED + "\nALL MATCHES\n" + Fore.LIGHTBLUE_EX)
        if matches == []:
            jarvis.say("No Matches Being Played!\n", Fore.RED)
            return
        for i, m in enumerate(matches, 1):
            jarvis.say("{}. {}".format(str(i), m))
        choice = int(input(Fore.RED + '\nEnter choice (number): ' +
                           Fore.RESET))
        while choice < 1 or choice > len(matches):
            jarvis.say(Fore.BLACK + '\nWrong choice')
            choice = int(
                input(Fore.RED + '\nEnter choice again: ' + Fore.RESET))

        desc = matches[choice - 1].title()
        jarvis.say('')
        res = self.live_score(desc)
        jarvis.say(res)
        jarvis.say("\n")
        if (res == Fore.RED + "MATCH YET TO BEGIN"):
            return
        jarvis.say(self.live_score(desc))
        jarvis.say(Fore.LIGHTBLUE_EX + '1. Full Score Card')
        jarvis.say('2. Commentary')
        jarvis.say('3. Refresh Score')
        jarvis.say('4. Quit' + Fore.RESET)

        choice = int(input(Fore.RED + '\nEnter choice (number): ' +
                           Fore.RESET))
        while choice < 1 or choice > 4:
            jarvis.say(Fore.BLACK + '\nWrong choice')
            choice = int(
                input(Fore.RED + '\nEnter choice again: ' + Fore.RESET))
        jarvis.say('')

        if choice == 1:
            ref = 'y'
            while ref == 'y':
                jarvis.say(self.scorecard(desc))
                ref = input(Fore.RED + 'Do you want to refresh:(y/n) ' +
                            Fore.RESET)
                jarvis.say('\n')

        elif choice == 2:
            ref = 'y'
            while ref == 'y':
                jarvis.say(self.commentary(desc))
                ref = input(Fore.RED + 'Do you want to refresh:(y/n) ' +
                            Fore.RESET)
                jarvis.say('\n')

        elif choice == 3:
            ref = 'y'
            while ref == 'y':
                jarvis.say(self.live_score(desc))
                ref = input(Fore.RED + 'Do you want to refresh:(y/n) ' +
                            Fore.RESET)
                jarvis.say('\n')
Beispiel #28
0
Created on Thu Oct  1 20:00:29 2020

@author: malat
"""


from pycricbuzz import Cricbuzz

c = Cricbuzz()

import json

matches = c.matches()
print (json.dumps(matches,indent=4)) #for pretty prinitng

lscore = c.livescore("30409")
print(json.dumps(lscore, indent=4, sort_keys=True))







def mid():
    for ma in matches:
        if "Indian Premier League 2020" in ma["srs"]:
            return (ma["id"])
        
mid = mid()
lscore = c.livescore(mid)
Beispiel #29
0
#code to acquire live IPL scores and generate applaud for fours and sixes
#!/usr/bin/env python
from pycricbuzz import Cricbuzz
import os
import subprocess
import json
#the pycricbuzz library is used to acquire the live scores
c = Cricbuzz()
matches = c.matches()
for match in matches:
    diction = c.livescore(match['id'])
    if (diction['matchinfo']['id'] == '1'
        ):  #this line checks for the specific match using the appropriate id
        #sum of sixes scored by the batsmen at the crease
        prev = int(diction['batting']['batsman'][0]['six']) + int(
            diction['batting']['batsman'][1]['six'])
        #sum of fours scored by the batsman at the crease
        prev4_0 = int(diction['batting']['batsman'][0]['fours']) + int(
            diction['batting']['batsman'][1]['fours'])
        #the while loop executes until the match is over
        while (diction['matchinfo']['mchstate'] == 'inprogress'):
            try:
                #the sum of the sixes scored by  the batsmen at the crease is calculated and if the sum increases by 1 ,sound is generated
                if (int(diction['batting']['batsman'][0]['six']) +
                        int(diction['batting']['batsman'][1]['six']) == prev +
                        1):
                    {
                        #print ("Sixer")
                        subprocess.Popen([
                            'mpg123', '-q', '/home/alarm/livescore/cheer.mp3'
                        ])
def live_score(mid):
    c = Cricbuzz()
    lscore = c.livescore(mid)
    print(json.dumps(lscore["batting"], indent=4, sort_keys=True))
mail: ashraf_minhaj|@yahoo.com
"""

from pycricbuzz import Cricbuzz  # import library

cricket = Cricbuzz()  # instantiate

# get current matches
matches = cricket.matches()

# score
for match in matches:

    print('____')  # just a separator for scores
    print(match['srs'], ' ',
          match['type'])  # league name, game type (t20, ODI etc)
    print(match['team1']['name'])
    print(match['team2']['name'])
    print(match['status'])

    # get score if the game started
    try:
        data = cricket.livescore(match['id'])  # check for every matches
        print("Batting: ", data['batting']['team'])
        print("Score: ", data['batting']['score'][0]['runs'])

        print("Bowling: ", data['bowling']['team'])
        print("Score: ", data['bowling']['score'][0]['runs'])
    except:
        print("Not started")