Beispiel #1
0
    def score(self):
        posts = format_date(date=self.date, date_format="%d/%m/%Y\nPostponed")
        times = format_date(date=self.date, date_format="%H:%M")
        dates = format_date(date=self.date, date_format="%d/%m/%Y\n%H:%M")
        score = str(self.score_home) + ' - ' + str(self.score_away)
        score = times if self.period == 'PreMatch' else score
        score = score if self.today or self.past else dates
        score = posts if self.period == 'Postponed' else score

        return score
Beispiel #2
0
  def save_matches(self):
    matches = self.get_matches()
    items   = []

    for item in matches:
      try:
        competition = self.data.get_single('competition', { 'api_id': item['competition']['id'] })
        home_team   = self.data.get_single('team', { 'api_id': item['team_home']['id'] })
        away_team   = self.data.get_single('team', { 'api_id': item['team_away']['id'] })
        form_date   = format_date(date=item['kickoff'], localize=True)

        items.append({
          'date':        form_date,
          'minute':      item['minute'],
          'period':      item['period'],
          'home_team':   home_team.id,
          'away_team':   away_team.id,
          'score_home':  item['score_home'],
          'score_away':  item['score_away'],
          'competition': competition.id,
          'api_id':      item['id']
        })
      except (AttributeError, KeyError):
        pass

    self.data.set_multiple('fixture', items, 'api_id')