def __get_event_name(event, date, time, competition): color = 'yellow' now = datetime.datetime.now() event_date = date.split('/') event_time = time.split(':') event_dt_start = datetime.datetime(int(event_date[2]), int(event_date[1]), int(event_date[0]), int(event_time[0]), int(event_time[1])) # noinspection PyTypeChecker if event_dt_start - datetime.timedelta( minutes=5) <= now <= event_dt_start + datetime.timedelta( hours=2): color = 'lime' elif now >= event_dt_start: color = 'orange' name = event.split('-') name = '%s - %s' % (name[0], name[1]) if len(name) == 2 else event return '[COLOR %s](%s %s:%s)[/COLOR] (%s) [B]%s[/B]' % \ (color, date[:5], event_time[0], event_time[1], lang.translate(competition), name)
def get_sports(self): sport_events = [] sports = [] sports_list = [] events = self.get_all_events() # Lista de deportes en la guía for event in events: if not event['sport'] in sports: sports.append(event['sport']) # Construye la lista deportes: añade al título el número de eventos que contiene for sport in sports: sport_events[:] = [] sport_art = art.get_sport_art(sport, self.__settings['path']) for event in events: if event['sport'] == sport: sport_events.append(sport) sports_list.append({ 'name': '[B]%s[/B] (%i)' % (lang.translate(sport), len(sport_events)), 'sport_id': sport, 'icon': sport_art['icon'], 'fanart': sport_art['fanart'] }) return sports_list
def get_competitions(self): competitions = [] competition_events = [] competitions_list = [] events = self.get_all_events() # Lista de competiciones en la guía for event in events: if not event['competition'] in competitions: competitions.append(event['competition']) # Construye la lista competiciones: añade al título el número de eventos que contiene for competition in competitions: competition_events[:] = [] sport = self.__get_sport(events, competition) competition_art = self.__get_competition_art(sport, competition) for event in events: if event['competition'] == competition: competition_events.append(competition) competitions_list.append({ 'name': '[B]%s[/B] (%i)' % (lang.translate(competition), len(competition_events)), 'competition_id': competition, 'icon': competition_art['icon'], 'fanart': competition_art['fanart'] }) return competitions_list
def __get_event_name(event): color = 'yellow' now = datetime.datetime.now() start = datetime.datetime.fromtimestamp(event['start']) end = datetime.datetime.fromtimestamp(event['end']) # noinspection PyTypeChecker if start - datetime.timedelta(minutes=5) <= now <= end: color = 'lime' elif now >= start: color = 'orange' return '[COLOR %s](%s %s)[/COLOR] (%s) [B]%s - %s[/B]' % ( color, start.strftime('%d/%m'), start.strftime('%H:%M'), lang.translate( event['competition']), tools.str_sanitize( event['team1']), tools.str_sanitize(event['team2']))