def __init__( self, *args, **kwargs ): self.leagueid = kwargs["leagueid"] self.teamObjs = {} self.cache_object = AddonCache()
if not params: if "script-matchcenter-MainMenu.xml" not in xbmc.getInfoLabel('Window.Property(xmlfile)'): mainmenu.start() else: #Integration patterns below ''' Eg: xbmc.executebuiltin("RunScript(script.matchcenter, /eventdetails/506227)") ''' if params[0] == 'ignoreleagues': ignoreleagues.start() elif params[0] == 'keymapeditor': keymapeditor.run() elif params[0] == 'removecache': AddonCache.removeCachedData() elif params[0] == 'livescores': livescores.start(standalone=True) elif params[0] == 'leagueselection': leagueselection.start(standalone=True) elif params[0] == 'football_league_selection': football_league_selection.start(standalone=True) elif params[0] == 'leaguetables' and params[1]: leaguetables.start_table(leagueid=params[1]) elif params[0] == 'matchhistory' and params[1]: matchhistory.start(teamid=params[1]) elif params[0] == 'eventdetails' and params[1]: eventdetails.showDetails(match=None,matchid=params[1]) try: xbmcplugin.endOfDirectory(int(sys.argv[1]))
class detailsDialog(xbmcgui.WindowXMLDialog): def __init__( self, *args, **kwargs ): self.leagueid = kwargs["leagueid"] self.teamObjs = {} self.cache_object = AddonCache() def onInit(self): self.getControl(32540).setImage(os.path.join(addon_path,"resources","img","goal.png")) xbmc.executebuiltin("SetProperty(loading-script-matchcenter-tables,1,home)") self.setTable() xbmc.executebuiltin("ClearProperty(loading-script-matchcenter-tables,Home)") def updateCacheTimes(self): self.t2 = datetime.datetime.now() self.hoursList = [168, 336, 504, 672, 840] self.interval = int(addon.getSetting("new_request_interval")) return def setTable(self): self.updateCacheTimes() #league data update_league_data = True if self.cache_object.isCachedLeague(self.leagueid): update_league_data = abs(self.t2 - self.cache_object.getCachedLeagueTimeStamp(self.leagueid)) > datetime.timedelta(hours=self.hoursList[self.interval]) if update_league_data: xbmc.log(msg="[Match Center] Timedelta was reached for league %s new request to be made..." % (str(self.leagueid)), level=xbmc.LOGDEBUG) league = api.Lookups().League(self.leagueid)[0] self.cache_object.cacheLeague(leagueid=self.leagueid,league_obj=league) else: xbmc.log(msg="[Match Center] Using cached object for league %s" % (str(self.leagueid)), level=xbmc.LOGDEBUG) league = self.cache_object.getcachedLeague(self.leagueid) if league: self.getControl(32500).setLabel(league.strLeague) table = api.Lookups().Table(leagueid=self.leagueid) if table: #team data update_team_data = True if self.cache_object.isCachedLeagueTeams(self.leagueid): update_team_data = abs(self.t2 - self.cache_object.getCachedLeagueTeamsTimeStamp(self.leagueid)) > datetime.timedelta(hours=self.hoursList[self.interval]) if update_team_data: xbmc.log(msg="[Match Center] Timedelta was reached for teams in league %s new request to be made..." % (str(self.leagueid)), level=xbmc.LOGDEBUG) teams_in_league = api.Lookups().Team(leagueid=self.leagueid) self.cache_object.cacheLeagueTeams(leagueid=self.leagueid,team_obj_list=teams_in_league) else: xbmc.log(msg="[Match Center] Using cached object for teams in league %s" % (str(self.leagueid)), level=xbmc.LOGDEBUG) teams_in_league = self.cache_object.getcachedLeagueTeams(self.leagueid) self.table = [] position = 1 for tableentry in table: try: item = xbmcgui.ListItem(tableentry.name) for team in teams_in_league: if tableentry.teamid == team.idTeam: item.setArt({ 'thumb': team.strTeamBadge }) if show_alternative == "true": item.setLabel(team.AlternativeNameFirst) item.setProperty('teamid',team.idTeam) item.setProperty('position','[B]'+str(position)+ ' - [/B]' ) item.setProperty('totalgames',str(tableentry.played)) item.setProperty('totalwins',str(tableentry.win)) item.setProperty('totaldraws',str(tableentry.draw)) item.setProperty('totallosts',str(tableentry.loss)) item.setProperty('goalsscored',str(tableentry.goalsfor)) item.setProperty('goalsconceeded',str(tableentry.goalsagainst)) item.setProperty('goaldifference',str(tableentry.goalsdifference)) item.setProperty('points',str(tableentry.total)) position += 1 self.table.append(item) except Exception, e: xbmc.log(msg="[Match Center] Exception: %s" % (str(e)), level=xbmc.LOGDEBUG) self.getControl(32501).addItems(self.table) self.setFocusId(32501) return
if not params: if "script-matchcenter-MainMenu.xml" not in xbmc.getInfoLabel('Window.Property(xmlfile)'): mainmenu.start() else: #Integration patterns below ''' Eg: xbmc.executebuiltin("RunScript(script.matchcenter, /eventdetails/506227)") ''' if params[0] == 'ignoreleagues': ignoreleagues.start() elif params[0] == 'keymapeditor': keymapeditor.run() elif params[0] == 'removecache': AddonCache.removeCachedData() elif params[0] == 'removetwitterhistory': tweet.remove_twitter_hashtag_history() elif params[0] == 'livescores': livescores.start(standalone=True) elif params[0] == 'twitter': if not params[1]: tweets.start() else: tweets.start(twitterhash=params[1], standalone=True) elif params[0] == 'leagueselection': leagueselection.start(standalone=True) elif params[0] == 'leaguetables' and params[1]: leaguetables.start_table(leagueid=params[1]) elif params[0] == 'matchhistory' and params[1]: matchhistory.start(teamid=params[1])
def __init__( self, *args, **kwargs ): self.teamid = kwargs["teamid"] self.teamObjs = {} self.eventObjs = {} self.cache_object = AddonCache()
class detailsDialog(xbmcgui.WindowXMLDialog): def __init__( self, *args, **kwargs ): self.teamid = kwargs["teamid"] self.teamObjs = {} self.eventObjs = {} self.cache_object = AddonCache() def onInit(self): self.setHistory(self.teamid) def updateCacheTimes(self): self.t2 = datetime.datetime.now() self.hoursList = [168, 336, 504, 672, 840] self.interval = int(addon.getSetting("new_request_interval")) return def setHistory(self,teamid): self.getControl(32540).setImage(os.path.join(addon_path,"resources","img","goal.png")) xbmc.executebuiltin("SetProperty(loading-script-matchcenter-history,1,home)") self.updateCacheTimes() if teamid: self.teamid = teamid panel_ids = [32502,32503] event_listall = [api.Schedules().Next().Team(teamid=self.teamid),api.Schedules().Last().Team(teamid=self.teamid)] #iterate either future or past events for i in xrange(0,len(event_listall)): items = [] events = event_listall[i] if events: for event in events: id_teams = [event.idHomeTeam,event.idAwayTeam] index = 0 for id_team in id_teams: update_team_data = True if self.cache_object.isCachedTeam(id_team): update_team_data = abs(self.t2 - self.cache_object.getCachedTeamTimeStamp(id_team)) > datetime.timedelta(hours=self.hoursList[self.interval]) if update_team_data: try: teamobject = api.Lookups().Team(teamid=id_team)[0] self.cache_object.cacheTeam(teamid=id_team,team_obj=teamobject) xbmc.log(msg="[Match Center] Timedelta was reached for team %s new request to be made..." % (str(id_team)), level=xbmc.LOGDEBUG) except: teamobject = None else: teamobject = self.cache_object.getcachedTeam(id_team) xbmc.log(msg="[Match Center] Used cached data for team %s..." % (str(id_team)), level=xbmc.LOGDEBUG) if index == 0: event.setHomeTeamObj(obj=teamobject) else: event.setAwayTeamObj(obj=teamobject) index += 1 #Append to event objects to move the event information between windows. Avoid making #another request self.eventObjs[event.idEvent] = event #create listitem item = xbmcgui.ListItem(event.strHomeTeam + "|" + event.strAwayTeam) if event.HomeTeamObj and event.AwayTeamObj: if show_alternative == "true": item.setProperty('hometeamname',event.HomeTeamObj.AlternativeNameFirst) item.setProperty('awayteamname',event.AwayTeamObj.AlternativeNameFirst) else: item.setProperty('hometeamname',event.strHomeTeam) item.setProperty('awayteamname',event.strAwayTeam) item.setProperty('competitionandround',event.strLeague + " - " + "Round" + " " + str(event.intRound)) item.setProperty('hometeambadge',event.HomeTeamObj.strTeamBadge) item.setProperty('awayteambadge',event.AwayTeamObj.strTeamBadge) item.setProperty('eventid',event.idEvent) #Set event time try: db_time = pytz.timezone(str(pytz.timezone("Etc/UTC"))).localize(event.eventDateTime) my_location=pytz.timezone(pytz.all_timezones[int(my_timezone)]) converted_time=db_time.astimezone(my_location) starttime=converted_time.strftime("%a, %d %b %Y %H:%M") item.setProperty('date',starttime) except: pass #Set score for past matches if i == 1: if event.intHomeScore and event.intAwayScore: result = str(event.intHomeScore) + "-" + str(event.intAwayScore) item.setProperty("result","[B]" + result + "[/B]") items.append(item) self.getControl(panel_ids[i]).addItems(items) xbmc.executebuiltin("ClearProperty(loading-script-matchcenter-history,Home)") xbmc.executebuiltin("SetProperty(has_history,1,home)") def onClick(self,controlId): if controlId == 32503: eventid = self.getControl(controlId).getSelectedItem().getProperty("eventid") eventdetails.showDetails(self.eventObjs[eventid])
def __init__(self, *args, **kwargs): self.leagueid = kwargs["leagueid"] self.teamObjs = {} self.cache_object = AddonCache()
class detailsDialog(xbmcgui.WindowXMLDialog): def __init__(self, *args, **kwargs): self.leagueid = kwargs["leagueid"] self.teamObjs = {} self.cache_object = AddonCache() def onInit(self): self.getControl(32540).setImage( os.path.join(addon_path, "resources", "img", "goal.png")) xbmc.executebuiltin( "SetProperty(loading-script-matchcenter-tables,1,home)") self.setTable() xbmc.executebuiltin( "ClearProperty(loading-script-matchcenter-tables,Home)") def updateCacheTimes(self): self.t2 = datetime.datetime.now() self.hoursList = [168, 336, 504, 672, 840] self.interval = int(addon.getSetting("new_request_interval")) return def setTable(self): self.updateCacheTimes() #league data update_league_data = True if self.cache_object.isCachedLeague(self.leagueid): update_league_data = abs( self.t2 - self.cache_object.getCachedLeagueTimeStamp(self.leagueid) ) > datetime.timedelta(hours=self.hoursList[self.interval]) if update_league_data: xbmc.log( msg= "[Match Center] Timedelta was reached for league %s new request to be made..." % (str(self.leagueid)), level=xbmc.LOGDEBUG) league = api.Lookups().League(self.leagueid)[0] self.cache_object.cacheLeague(leagueid=self.leagueid, league_obj=league) else: xbmc.log(msg="[Match Center] Using cached object for league %s" % (str(self.leagueid)), level=xbmc.LOGDEBUG) league = self.cache_object.getcachedLeague(self.leagueid) if league: self.getControl(32500).setLabel(league.strLeague) table = api.Lookups().Table(leagueid=self.leagueid) if table: #team data update_team_data = True if self.cache_object.isCachedLeagueTeams(self.leagueid): update_team_data = abs( self.t2 - self.cache_object.getCachedLeagueTeamsTimeStamp( self.leagueid)) > datetime.timedelta( hours=self.hoursList[self.interval]) if update_team_data: xbmc.log( msg= "[Match Center] Timedelta was reached for teams in league %s new request to be made..." % (str(self.leagueid)), level=xbmc.LOGDEBUG) teams_in_league = api.Lookups().Team(leagueid=self.leagueid) self.cache_object.cacheLeagueTeams( leagueid=self.leagueid, team_obj_list=teams_in_league) else: xbmc.log( msg= "[Match Center] Using cached object for teams in league %s" % (str(self.leagueid)), level=xbmc.LOGDEBUG) teams_in_league = self.cache_object.getcachedLeagueTeams( self.leagueid) self.table = [] position = 1 for tableentry in table: try: item = xbmcgui.ListItem(tableentry.name) for team in teams_in_league: if tableentry.teamid == team.idTeam: item.setArt({'thumb': team.strTeamBadge}) if show_alternative == "true": item.setLabel(team.AlternativeNameFirst) item.setProperty('teamid', team.idTeam) item.setProperty('position', '[B]' + str(position) + ' - [/B]') item.setProperty('totalgames', str(tableentry.played)) item.setProperty('totalwins', str(tableentry.win)) item.setProperty('totaldraws', str(tableentry.draw)) item.setProperty('totallosts', str(tableentry.loss)) item.setProperty('goalsscored', str(tableentry.goalsfor)) item.setProperty('goalsconceeded', str(tableentry.goalsagainst)) item.setProperty('goaldifference', str(tableentry.goalsdifference)) item.setProperty('points', str(tableentry.total)) position += 1 self.table.append(item) except Exception, e: xbmc.log(msg="[Match Center] Exception: %s" % (str(e)), level=xbmc.LOGDEBUG) self.getControl(32501).addItems(self.table) self.setFocusId(32501) return