Example #1
0
class TestMatchMethods(unittest.TestCase):

    def setUp(self):
        id=857713
        self.match = Match(id)

    def test_match_description(self):
        self.assertEqual(self.match.description(), 'Caribbean Premier League, 6th Match: St Lucia Zouks v Guyana Amazon Warriors at Gros Islet, Jun 26, 2015')

    def test_match_match_class(self):
        self.assertEqual(self.match.match_class(), 'Twenty20')

    def test_toss_winner(self):
        self.assertEqual(self.match.toss_winner(), 'AmWar')
Example #2
0
class TestMatchMethods(unittest.TestCase):
    def setUp(self):
        id = 857713
        self.match = Match(id)

    def test_match_description(self):
        self.assertEqual(
            self.match.description(),
            'Caribbean Premier League, 6th Match: St Lucia Zouks v Guyana Amazon Warriors at Gros Islet, Jun 26, 2015'
        )

    def test_match_match_class(self):
        self.assertEqual(self.match.match_class(), 'Twenty20')

    def test_toss_winner(self):
        self.assertEqual(self.match.toss_winner(), 'AmWar')
    def get_match_summary_info(self, match_num):
        """
        Get summary of match including batsmen, bowlers and totals
        for each innnings
        """
        match = Match(match_num)

        innings1 = match.innings[0]
        innings2 = match.innings[1]

        (html_bat_inn1, html_bat_inn2, html_bowl_inn1,
         html_bowl_inn2) = self._get_bat_bowl_htmls(match)

        return {
            'innings1': {
                'batsmen': self._get_player_val_dict(html_bat_inn1),
                'bowlers': self._get_player_val_dict(html_bowl_inn1),
                'total_runs': innings1['runs'],
                'total_wickets': innings1['wickets']
            },
            'innings2': {
                'batsmen': self._get_player_val_dict(html_bat_inn2),
                'bowlers': self._get_player_val_dict(html_bowl_inn2),
                'total_runs': innings2['runs'],
                'total_wickets': innings2['wickets']
            }
        }
Example #4
0
 def batting_for_match(self, match_id):
     batting_stats = []
     m = Match(match_id)
     for innings in list(m.full_scorecard['innings'].keys()):
         stats = next((x for x in m.full_scorecard['innings'][innings]['batsmen'] if x['href'] == self.url), None)
         if stats:
             batting_stats.append({ 'innings': innings, 'balls_faced': next((x['value'] for x in stats['stats'] if x['name'] == 'ballsFaced'), None), 'minutes': next((x['value'] for x in stats['stats'] if x['name'] == 'minutes'), None), 'runs': next((x['value'] for x in stats['stats'] if x['name'] == 'runs'), None), 'fours': next((x['value'] for x in stats['stats'] if x['name'] == 'fours'), None), 'sixes': next((x['value'] for x in stats['stats'] if x['name'] == 'sixes'), None), 'strike_rate': next((x['value'] for x in stats['stats'] if x['name'] == 'strikeRate'), None) })
     return batting_stats
Example #5
0
 def bowling_for_match(self, match_id):
     bowling_stats = []
     m = Match(match_id)
     for innings in list(m.full_scorecard['innings'].keys()):
         stats = next((x for x in m.full_scorecard['innings'][innings]['bowlers'] if x['href'] == self.url), None)
         if stats:
             bowling_stats.append({ 'innings': innings, 'overs': next((x['value'] for x in stats['stats'] if x['name'] == 'overs')), 'maidens': next((x['value'] for x in stats['stats'] if x['name'] == 'maidens')), 'conceded': next((x['value'] for x in stats['stats'] if x['name'] == 'conceded')), 'wickets': next((x['value'] for x in stats['stats'] if x['name'] == 'wickets')), 'economy_rate': next((x['value'] for x in stats['stats'] if x['name'] == 'economyRate')), 'dots': next((x['value'] for x in stats['stats'] if x['name'] == 'dots'), None), 'fours_conceded': next((x['value'] for x in stats['stats'] if x['name'] == 'foursConceded'), None), 'sixes_conceded': next((x['value'] for x in stats['stats'] if x['name'] == 'sixesConceded'), None), 'wides': next((x['value'] for x in stats['stats'] if x['name'] == 'wides'), None), 'no_balls': next((x['value'] for x in stats['stats'] if x['name'] == 'noballs'), None)})
     return bowling_stats
Example #6
0
 def in_team_for_match(self, match_id):
     m = Match(match_id)
     if next(
         (p
          for p in m.team_1_players if p['object_id'] == self.cricinfo_id),
             None) or next((p for p in m.team_2_players
                            if p['object_id'] == self.cricinfo_id), None):
         return True
     else:
         return False
Example #7
0
def get_match_format(team1, team2):
    matchformat = ""
    soup = data_request()
    teamlist1 = get_teamlist1(soup)
    teamlist2 = get_teamlist2(soup)
    match_id = get_match_id(soup)
    if team1 != "" and team2 != "" and team1 in teamlist1:
        ind = teamlist1.index(team1)
        if teamlist2[ind] == team2:
            match = match_id[ind]
            matchformat = "The format of the match is " + Match(
                match).match_class + " match"

    elif team1 != "" and team2 != "" and team1 in teamlist2:
        ind = teamlist2.index(team1)
        if teamlist1[ind] == team2:
            match = match_id[ind]
            matchformat = "The format of the match is " + Match(
                match).match_class + " match"

    elif team1 != "" and team2 == "":
        if team1 in teamlist1:
            ind = teamlist1.index(team1)
            match = match_id[ind]
            matchformat = "The format of the match is " + Match(
                match).match_class + " match"

        elif team1 in teamlist2:
            ind = teamlist2.index(team1)
            match = match_id[ind]
            matchformat = "The format of the match is " + Match(
                match).match_class + " match"

        else:
            matchformat = "there is no match going on for " + team1

    elif team1 == "" and team2 != "":
        if team2 in teamlist1:
            ind = teamlist1.index(team2)
            match = match_id[ind]
            matchformat = "The format of the match is " + Match(
                match).match_class + " match"

        elif team2 in teamlist2:
            ind = teamlist2.index(team2)
            match = match_id[ind]
            matchformat = "The format of the match is " + Match(
                match).match_class + " match"

        else:
            matchformat = "there is no match going on for " + team2

    elif team1 == "" and team2 == "":
        matchformat = "Please tell me the team name, whose format you want to know"
    return matchformat
Example #8
0
def get_runrate(team1, team2):
    runrate = ""
    soup = data_request()
    teamlist1 = get_teamlist1(soup)
    teamlist2 = get_teamlist2(soup)
    match_id = get_match_id(soup)
    if team1 != "" and team2 != "" and team1 in teamlist1:
        ind = teamlist1.index(team1)
        if teamlist2[ind] == team2:
            match = match_id[ind]
            runrate = "The current run rate is " + str(
                Match(match).team_1_run_rate)

    elif team1 != "" and team2 != "" and team1 in teamlist2:
        ind = teamlist2.index(team1)
        if teamlist1[ind] == team2:
            match = match_id[ind]
            runrate = "The current run rate is " + str(
                Match(match).team_1_run_rate)
    elif team1 != "" and team2 == "":
        if team1 in teamlist1:
            ind = teamlist1.index(team1)
            match = match_id[ind]
            runrate = "The current run rate is " + str(
                Match(match).team_1_run_rate)

        elif team1 in teamlist2:
            ind = teamlist2.index(team1)
            match = match_id[ind]
            runrate = "The current run rate is " + str(
                Match(match).team_1_run_rate)

        else:
            runrate = "there is no match going on for " + team1
    elif team1 == "" and team2 != "":
        if team2 in teamlist1:
            ind = teamlist1.index(team2)
            match = match_id[ind]
            runrate = "The current run rate is " + str(
                Match(match).team_1_run_rate)

        elif team2 in teamlist2:
            ind = teamlist2.index(team2)
            match = match_id[ind]
            runrate = "The current run rate is " + str(
                Match(match).team_1_run_rate)

        else:
            runrate = "there is no match going on for " + team2

    elif team1 == "" and team2 == "":
        runrate = "Please tell me the team name, whose run rate you want to know"

    return runrate
Example #9
0
def get_status(team1, team2):

    status = ""
    soup = data_request()
    teamlist1 = get_teamlist1(soup)
    teamlist2 = get_teamlist2(soup)
    match_id = get_match_id(soup)
    if team1 != "" and team2 != "" and team1 in teamlist1:
        ind = teamlist1.index(team1)
        if teamlist2[ind] == team2:
            match = match_id[ind]
            status = "The status of the match is " + Match(match).status
    elif team1 != "" and team2 != "" and team1 in teamlist2:
        ind = teamlist2.index(team1)
        if teamlist1[ind] == team2:
            match = match_id[ind]
            status = "The status of the match is " + Match(match).status
    elif team1 != "" and team2 == "":
        if team1 in teamlist1:
            ind = teamlist1.index(team1)
            match = match_id[ind]
            status = "The status of the match is " + Match(match).status

        elif team1 in teamlist2:
            ind = teamlist2.index(team1)
            match = match_id[ind]
            status = "The status of the match is " + Match(match).status

        else:
            status = "there is no match going on for " + team1
    elif team1 == "" and team2 != "":
        if team2 in teamlist1:
            ind = teamlist1.index(team2)
            match = match_id[ind]
            status = "The status of the match is " + Match(match).status

        elif team2 in teamlist2:
            ind = teamlist2.index(team2)
            match = match_id[ind]
            status = "The status of the match is " + Match(match).status

        else:
            status = "The status of the match is " + Match(match).status

    elif team1 == "" and team2 == "":
        status = "Please tell me the team name, whose status you want to know"

    return status
Example #10
0
def get_teamlist1(soup):
    teamlist1 = []

    match_id = get_match_id(soup)

    country_list = [
        "AFGHANISTAN", "AUSTRALIA", "BANGLADESH", "ENGLAND", "INDIA",
        "IRELAND", "NEW ZEALAND", "PAKISTAN", "SOUTH AFRICA", "SRI LANKA",
        "WEST INDIES", "ZIMBABWE", "KENYA", "SCOTLAND", "UAE"
    ]

    for j in match_id:
        t1 = Match(j).team_1_abbreviation

        if t1 == 'AFG':
            teamlist1.append("AFGHANISTAN")
        elif t1 == 'AUS':
            teamlist1.append("AUSTRALIA")
        elif t1 == 'BAN':
            teamlist1.append("BANGLADESH")
        elif t1 == 'ENG':
            teamlist1.append("ENGLAND")
        elif t1 == 'IND':
            teamlist1.append("INDIA")
        elif t1 == 'IRE' or t1 == 'IRL':
            teamlist1.append("IRELAND")
        elif t1 == 'NZ':
            teamlist1.append("NEW ZEALAND")
        elif t1 == 'PAK':
            teamlist1.append("PAKISTAN")
        elif t1 == 'SA' or t1 == 'RSA':
            teamlist1.append("SOUTH AFRICA")
        elif t1 == 'SL':
            teamlist1.append("SRI LANKA")
        elif t1 == 'WI':
            teamlist1.append("WEST INDIES")
        elif t1 == 'ZIM':
            teamlist1.append("ZIMBABWE")
        elif t1 == 'KEN':
            teamlist1.append("KENYA")
        elif t1 == 'SCO':
            teamlist1.append("SCOTLAND")
        elif t1 == 'UAE':
            teamlist1.append("UNITED ARAB EMIRTES")
    return teamlist1
Example #11
0
def get_result(team1, team2):
    result = ""
    soup = data_request()
    teamlist1 = get_teamlist1(soup)
    teamlist2 = get_teamlist2(soup)
    match_id = get_match_id(soup)
    if team1 != "" and team2 != "" and team1 in teamlist1:
        ind = teamlist1.index(team1)
        if teamlist2[ind] == team2:
            match = match_id[ind]
            result = Match(match).result
    elif team1 != "" and team2 != "" and team1 in teamlist2:
        ind = teamlist2.index(team1)
        if teamlist1[ind] == team2:
            match = match_id[ind]
            result = Match(match).result
    elif team1 != "" and team2 == "":
        if team1 in teamlist1:
            ind = teamlist1.index(team1)
            match = match_id[ind]
            result = Match(match).result

        elif team1 in teamlist2:
            ind = teamlist2.index(team1)
            match = match_id[ind]
            result = Match(match).result

        else:
            result = "there is no match going on for " + team1
    elif team1 == "" and team2 != "":
        if team2 in teamlist1:
            ind = teamlist1.index(team2)
            match = match_id[ind]
            result = Match(match).result

        elif team2 in teamlist2:
            ind = teamlist2.index(team2)
            match = match_id[ind]
            result = Match(match).result

        else:
            result = Match(match).result

    elif team1 == "" and team2 == "":
        result = "Please tell me the team name, whose result you want to know"

    return result
Example #12
0
def get_groundname(team1, team2):
    ground = ""
    soup = data_request()
    teamlist1 = get_teamlist1(soup)
    teamlist2 = get_teamlist2(soup)
    match_id = get_match_id(soup)
    if team1 != "" and team2 != "" and team1 in teamlist1:
        ind = teamlist1.index(team1)
        if teamlist2[ind] == team2:
            match = match_id[ind]
            ground = "The match is being played at " + Match(match).ground_name

    elif team1 != "" and team2 != "" and team1 in teamlist2:
        ind = teamlist2.index(team1)
        if teamlist1[ind] == team2:
            match = match_id[ind]
            ground = "The match is being played at " + Match(match).ground_name
    elif team1 != "" and team2 == "":
        if team1 in teamlist1:
            ind = teamlist1.index(team1)
            match = match_id[ind]
            ground = "The match is being played at " + Match(match).ground_name

        elif team1 in teamlist2:
            ind = teamlist2.index(team1)
            match = match_id[ind]
            ground = "The match is being played at " + Match(match).ground_name

        else:
            ground = "there is no match going on for " + team1
    elif team1 == "" and team2 != "":
        if team2 in teamlist1:
            ind = teamlist1.index(team2)
            match = match_id[ind]
            ground = "The match is being played at " + Match(match).ground_name

        elif team2 in teamlist2:
            ind = teamlist2.index(team2)
            match = match_id[ind]
            ground = "The match is being played at " + Match(match).ground_name

        else:
            ground = "there is no match going on for " + team1

    elif team1 == "" and team2 == "":
        ground = "Please tell me the team name, whose venue you want to know"

    return ground
Example #13
0
def voice_processing(vstr):
    soup = data_request()
    wordlist = []
    vstr = vstr.upper()

    wordlist = vstr.split()
    returnstr = ""
    match_id = get_match_id(soup)
    get_cache1(wordlist)
    get_cache2(wordlist)

    team1 = get_team1(wordlist)
    team2 = get_team2(wordlist)

    if "HELLO" in wordlist or "HI" in wordlist or (
            "GOOD" in wordlist and
        ("DAY" in wordlist or "MORNING" in wordlist or "EVENING" in wordlist)):
        returnstr = "Hello. This is Meera. What do you want to know?"
    elif ("HOW" in wordlist and "ARE" in wordlist
          and "YOU" in wordlist) or ("HOW" in wordlist
                                     and "DOING" in wordlist):
        returnstr = "I am doing good"
    elif "MATCH" in wordlist or "MATCHES" in wordlist or (
            "CURRENT" in wordlist or "LIVE" in wordlist
            or "ONGOING" in wordlist or "ALL" in wordlist):
        if match_id == []:
            returnstr = "there are no live matches going on right now."
        else:
            print(match_id)
            returnstr = "Here is the list of all ongoing matches. "
            for i in match_id:
                print(i)
                print(Match(i).description)

                returnstr = returnstr + " " + Match(i).description
                returnstr = returnstr.replace(" v ", " versus ")
                returnstr = returnstr + ". "

            returnstr = returnstr

    elif (team1 != "" or team2 != "" or
          (team1 != "" and team2 != "")) and "SCORE" in wordlist:
        returnstr = get_score(team1, team2)

    elif team1 == "" and team2 == "" and "SCORE" in wordlist:
        returnstr = get_score(cache1, cache2)

    elif (team1 != "" or team2 != "" or
          (team1 != "" and team2 != "")) and ("RUNRATE" in wordlist or
                                              ("RUN" in wordlist
                                               and "RATE" in wordlist)):
        returnstr = get_runrate(team1, team2)

    elif team1 == "" and team2 == "" and ("RUNRATE" in wordlist or
                                          ("RUN" in wordlist
                                           and "RATE" in wordlist)):
        returnstr = get_runrate(team1, team2)

    elif (team1 != "" or team2 != "" or
          (team1 != "" and team2 != "")) and "FORMAT" in wordlist:
        returnstr = get_match_format(team1, team2)

    elif team1 == "" and team2 == "" and "FORMAT" in wordlist:
        returnstr = get_match_format(cache1, cache2)

    elif (team1 != "" or team2 != "" or
          (team1 != "" and team2 != "")) and ("VENUE" in wordlist
                                              or "PLACE" in wordlist):
        returnstr = get_groundname(team1, team2)

    elif team1 == "" and team2 == "" and ("VENUE" in wordlist
                                          or "PLACE" in wordlist):
        returnstr = get_groundname(cache1, cache2)

    elif (team1 != "" or team2 != "" or (team1 != "" and team2 != "")) and (
            "RESULT" in wordlist or "WON" in wordlist or "WIN" in wordlist):
        returnstr = get_result(team1, team2)

    elif team1 == "" and team2 == "" and ("RESULT" in wordlist or "WON"
                                          in wordlist or "WIN" in wordlist):
        returnstr = get_result(cache1, cache2)

    elif (team1 != "" or team2 != "" or
          (team1 != "" and team2 != "")) and ("STATUS" in wordlist):
        returnstr = get_status(team1, team2)

    elif team1 == "" and team2 == "" and ("STATUS" in wordlist):
        returnstr = get_status(cache1, cache2)

    elif "YOUR" in wordlist and "NAME" in wordlist:
        returnstr = "My name is Meera"

    elif "LAZY" in wordlist or "SLOW" in wordlist:
        returnstr = "No, Its your internet which is slow"

    elif (team1 != "" or team2 != "" or (team1 != "" and team2 != "")):
        if team1 != "" and team2 == "":
            returnstr = "what do you want to know about " + team1
        elif team2 != "" and team1 == "":
            returnstr = "what do you want to know about " + team1
        elif team1 != "" and team2 != "":
            returnstr = "what do you want to know about " + team1 + " and " + team2
        returnstr = get_score(team1, team2)
    elif "BYE" in wordlist:
        returnstr = "BYE BYE HAVE A NICE DAY"
    elif ("GET" in wordlist and "LOST" in wordlist) or "LOST" in wordlist:
        returnstr = "You too"
    elif team1 == "" and team2 == "" and "SCORE" in wordlist:
        returnstr = get_score(cache1, cache2)

    else:
        returnstr = "I did not understand what you said "

    print(returnstr)
    return returnstr
from espncricinfo.summary import Summary
from espncricinfo.match import Match
from espncricinfo.match import Match

m = Match('1226866')
print(m.description)
Example #15
0
    "umpire_2_id", "umpire_2_name", "umpire_2_country", "tv_umpire_id",
    "tv_umpire_name", "tv_umpire_country", "referree_id", "referee_name",
    "referee_country", "url"
]

matches = simplejson.loads(open('all_matches.json').read())
matches = list(set(matches))  # dedupe

##################################START PROCESSING DATA#########################################
with open("final_output.csv", "wb") as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow(headers)
    for match in matches:
        time.sleep(1)
        try:
            m = Match(int(match))
            if m.match_json()['match_status'] == 'forthcoming':
                continue
            if m.result() == '':
                continue
            if m.rain_rule() == 'D/L method':
                duckworth_lewis = 1
            else:
                duckworth_lewis = 0
            try:
                m.team_2()['team_name']
            except KeyError:
                continue
            try:
                m.team_1()['team_name']
            except KeyError:
Example #16
0
os.chdir('/home/david/Desktop/Documents/GitRepos/python-espncricinfo')
os.listdir()

############
# Basic tests
############

# Get this module from https://github.com/dwillis/python-espncricinfo

from espncricinfo.summary import Summary
s = Summary()
s.match_ids

from espncricinfo.match import Match
m = Match('64148')
m.description

############
# Import 49 matches from 2015 world cup; create big, clunky match_df
############

from match_ids import match_ids

match_data = {}
for i in match_ids:
    m = Match(i)
    match_data[i] = m
    print(i)
'''       
MORE ATTRIBUTES NOT USED:    
Example #17
0
import simplejson
from espncricinfo.match import Match

headers = ["team1", "team1_id", "team2", "team2_id", "win_toss", "bat_or_bowl", "outcome", "win_game", "date", "day_n_night", "ground", "rain", "duckworth_lewis", "match_id", "type_of_match", "match_type_id", "home_team_id", "umpire_1_id", "umpire_1_name", "umpire_1_country", "umpire_2_id", "umpire_2_name", "umpire_2_country", "tv_umpire_id", "tv_umpire_name", "tv_umpire_country", "referree_id", "referee_name", "referee_country", "url"]

matches = simplejson.loads(open('all_matches.json').read())
matches = list(set(matches)) # dedupe

##################################START PROCESSING DATA#########################################
with open("final_output.csv", "wb") as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow(headers)
    for match in matches:
        time.sleep(1)
        try:
            m = Match(int(match))
            if m.match_json()['match_status'] == 'forthcoming':
                continue
            if m.result() == '':
                continue
            if m.rain_rule() == 'D/L method':
                duckworth_lewis = 1
            else:
                duckworth_lewis = 0
            try:
                m.team_2()['team_name']
            except KeyError:
                continue
            try:
                m.team_1()['team_name']
            except KeyError:
Example #18
0
 def setUp(self):
     id = 857713
     self.match = Match(id)
Example #19
0
dataset = pd.DataFrame()

m = np.load(
    '/home/g1/Documents/Cricket/Batting data/IPL_2008-2019_match_ids.npy')
count_main = 0
size = m.size
while (1):  #[count_main:]:#[1:2]:
    if count_main == size:
        break

    print("Bowl Match ID=", count_main)
    match_no = m[count_main]
    print("Match no", match_no)

    try:
        mm = Match(match_no)

        pp = np.zeros([2, 11])
        for i in range(2):
            print(" Team:", i)
            for j in range(11):
                pp[i, j] = mm.json['team'][i]['player'][j]['object_id']

        pba = np.zeros([2, 11])
        pbs = np.zeros([2, 11])
        pbe = np.zeros([2, 11])
        for i in range(2):
            for j in range(11):
                p = Player(int(pp[i, j]))
                count = 0
                count1 = 0
Example #20
0
 def setUp(self):
     id=857713
     self.match = Match(id)
Example #21
0
 def _build_matches(self):
     return [Match(m) for m in self.match_ids]
Example #22
0
def get_score(team1, team2):
    score = ""
    print(team1)
    print(team2)
    soup = data_request()
    teamlist1 = get_teamlist1(soup)
    teamlist2 = get_teamlist2(soup)
    print(teamlist1)
    print(teamlist2)
    match_id = get_match_id(soup)
    if team1 != "" and team2 != "" and team1 in teamlist1:
        ind = teamlist1.index(team1)
        if teamlist2[ind] == team2:
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        else:
            score = "there is no match between " + team1 + " and " + team2

    elif team1 != "" and team2 != "" and team1 in teamlist2:
        ind = teamlist2.index(team1)
        if teamlist1[ind] == team2:
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        else:
            score = "there is no match between " + team1 + " and " + team2

    elif team1 != "" and team2 == "":
        if team1 in teamlist1:
            ind = teamlist1.index(team1)
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        elif team1 in teamlist2:
            ind = teamlist2.index(team1)
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        else:
            score = "there is no match going on for " + team1

    elif team1 == "" and team2 != "":
        if team2 in teamlist1:
            ind = teamlist1.index(team2)
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        elif team2 in teamlist2:
            ind = teamlist2.index(team2)
            match = match_id[ind]
            score = Match(match).current_summary
            score = score[0:score.index("(")]
            if score.find("/") == -1:
                score = score + " all out "
                score = score + " " + Match(match).result
            else:
                score = score.replace("/", " for ")
                score = score + " wickets"
                score = score + " " + Match(match).result
        else:
            score = "there is no match going on for " + team2

    elif team1 == "" and team2 == "":
        score = "Please tell me the team name, whose score you want to know"
    return score
Example #23
0
    games_season = 0
    matches = matchdict[season]
    for i in tqdm(matches):
        try:
            try:
                with open(path + '/Matches/' + i +
                          '.json') as json_file:  # If json exists, use that
                    minfo = json.load(json_file)
                    scorecard = minfo['scorecard']
                    temp = minfo['result']
                    totalovers = minfo['totalovers']
                    all_c_champ_matches.append(i)
                    games_season = games_season + 1
            except:
                try:
                    m = Match(i)  # Otherwise, scrape from cricinfo
                    # Get squads
                    team1squad = m.team_1_players
                    team1squad_id = []
                    team1squad_names = []
                    for j in list(range(0, len(team1squad))):
                        name = team1squad[j]['known_as']
                        p_id = team1squad[j]['object_id']
                        team1squad_names.append(name)
                        team1squad_id.append(p_id)

                    team2squad = m.team_2_players
                    team2squad_id = []
                    team2squad_names = []
                    for j in list(range(0, len(team2squad))):
                        name = team2squad[j]['known_as']
Example #24
0
# Get all matches
#matches = Series.get_events_for_season(cwc19,2019)

# Construct original table
#groupstage = pd.read_csv('cwc19_final_table.csv')

# Get County Championship
#cchamp1 = Series('8052')
#cchamp2 = Series('8204')

# Get county champsionship seasons
print('Getting Match IDs')
#matches = Series.get_events_for_season(cchamp1,2018)
#matches.append(Series.get_events_for_season(cchamp2,2018))

m = Match(1166949)
i1, i2, i3, i4 = m.getbattingdataframe()
pdb.set_trace()
req = requests.get(m.json_url)

url = m.espn_api_url


def get_json(url):
    r = requests.get(url)
    if r.status_code == 404:
        raise "Not Found"
    else:
        return r.json()