LINEUP ACTIVE MATCH

From Whipped Octupus, 1 Week ago, written in Plain Text, viewed 4 times. This paste will die in 2 Weeks.
URL https://paste.afonso.co/view/004fe1b3 Embed
Download Paste or View Raw
  1. import clr
  2. clr.AddReference("Wtvision.Sports.Tools.UefaDigitalAPIImporter")
  3. from Wtvision.Sports import UefaDigitalApiProxy
  4. from System import Array, DateTime
  5. import helper
  6. from System.Threading.Tasks import Task
  7.  
  8. def __beforeProgram(graphicOnAirItem, momentExecution):
  9.         graphicOnAirItem.Scene.Show("Statistics_to_Substitutes")       
  10.         graphic = GraphicTemplatesManager.GetGraphicByName("ScoreWithScorers_LineUp")
  11.         Task.Run(action = lambda : IntelliflowController.TakeIn(graphic, OutputManager.ActiveChannelOutput, workflowType = IntelliflowController.EWorkflowType.Program))
  12.        
  13. def __getData(graphicOnAirItem, viewBag, momentExecution):
  14.         """_getData internal inteliflow callback
  15.                         Parameters:
  16.                                 graphicOnAirItem, viewBag, momentExecution
  17.         """
  18.         #Graphic Data
  19.         matches = __getTodayMatches()
  20.         if not matches:
  21.                 momentExecution.MessageType = momentExecution.MessageType.Info
  22.                 momentExecution.Message = "No other matches found!"
  23.                 momentExecution.Cancel = True
  24.                 return
  25.  
  26.         __clearTags(viewBag)
  27.        
  28.         ## NOTE!!!!!!
  29.         #__fillBottomInformation(viewBag, matches) ## NOT TO SHOW BOTTOM GAMES ON LINEUP ACTIVE MATCH
  30.         viewBag.SetFloat("vBottomGames", 0)  ## COMMENT THIS LINE IN CASE OF SHOW BOTTOM GAMES
  31.        
  32.         __fillTeamData(Game.HomeTeam,viewBag)
  33.         __fillTeamData(Game.AwayTeam,viewBag)
  34.  
  35. def __fillTeamData(team, viewBag):
  36.         """Fill Team tags information
  37.                 Parameters:
  38.                         team: Wtvision.Sports.Team, viewBag
  39.                 Returns:
  40.                         bool:Returns true if fill all tags, false on exception
  41.         """
  42.         #Define if the Team is Home or Away to affect the correct Tag information
  43.         teamType = "Home" if team == Game.HomeTeam else "Away"
  44.         viewBag.SetTranslatedText("t{homeoraway}CoachFunction".format(homeoraway=teamType), "{{%s}}.{{LineUp}}|filter:ToUpper " % team.Coach.Function)
  45.         viewBag.SetString("t{homeoraway}CoachFirstName".format(homeoraway=teamType), "")
  46.         viewBag.SetString("t{homeoraway}CoachLastName".format(homeoraway=teamType), team.Coach.ShortName)
  47.         # if the Caoch is at Risk the Card type is 1 to show the yellowcard otherwise 0 to hide the card
  48.         viewBag.SetInt("v{homeoraway}CoachCard",1 if team.Coach.AtRisk else 0)
  49.         players = []
  50.         players.extend(team.InPlayByKeeperAndShirt)
  51.         players.extend([None]*(11-len(players)))
  52.         players.extend(team.InBenchByKeeperAndShirt)
  53.  
  54.         for enum,player in enumerate(players):
  55.                 viewBag.SetVisibility("v{homeoraway}SubstitutionVisibility{idx:02d}".format(homeoraway=teamType, idx=(enum+1)), False)
  56.                 viewBag.SetInt("v{homeoraway}Card{idx:02d}".format(homeoraway=teamType, idx=(enum+1)), 1 if player.AtRisk else 0)
  57.                 viewBag.SetString("t{homeoraway}Number{idx:02d}".format(homeoraway=teamType, idx=(enum+1)), player.Number)
  58.                 viewBag.SetString("t{homeoraway}Name{idx:02d}".format(homeoraway=teamType, idx=(enum+1)), "")
  59.                 viewBag.SetString("t{homeoraway}LastName{idx:02d}".format(homeoraway=teamType, idx=(enum+1)), player.OtherNames.upper() if player.OtherNames else player.ShortName.upper())
  60.  
  61. def __getTodayMatches():
  62.         """Get Today Matches
  63.                 Parameters:
  64.                         team: Wtvision.Sports.Team
  65.                 Returns:
  66.                         bool:Returns match array for Today
  67.         """
  68.         competitionId = Game.Competition.IdCompetition
  69.         matchDayId = Game.Attributes["MatchDayId"]
  70.         matches = UefaDigitalApiProxy.GetMatches(offset= "0",limit = "500",competitionId = Array[str]([Game.Competition.IdCompetition]),matchDayId = Array[str]([matchDayId]))
  71.         matchId = Game.ExternalId
  72.         mygame = next(iter([match for match in matches if match.Id == matchId]), None) # Get myGame
  73.         if not mygame:
  74.                 #No Data
  75.                 return None
  76.         matches = sorted(matches, key=lambda match: match.KickOffTime.DateTime) # No need just games for today
  77.         return [match for match in matches if match.KickOffTime.Date == mygame.KickOffTime.Date] # JUST GAMES  IN THE SAME DAY OF MY GAME
  78.          
  79.  
  80. def __fillBottomInformation(viewBag, matches):
  81.         viewBag.SetFloat("vBottomGames", len(matches))
  82.  
  83.         for enum, match in enumerate(matches):
  84.                 viewBag.SetString("tHomeBottomTeam%02d" % (enum+1), match.HomeTeam.TeamCode.ToString().upper())
  85.                 viewBag.SetString("tAwayBottomTeam%02d" % (enum+1), match.AwayTeam.TeamCode.ToString().upper())
  86.                
  87.                 status = match.Status.ToString().upper()
  88.                 if status == "FINISHED":
  89.                         if hasattr(match.Score, "Total"):
  90.                                 result = "%s - %s" % (match.Score.Total.Home, match.Score.Total.Away)
  91.                                 viewBag.SetString("tBottomTime%02d" % (enum+1), result)
  92.                         else:
  93.                                 result = "%s - %s" % (match.Score.Regular.Home, match.Score.Regular.Away)
  94.                                 viewBag.SetString("tBottomTime%02d" % (enum+1), result)
  95.                 elif status == "LIVE":
  96.                         if hasattr(match.Score, "Total"):
  97.                                 result = "(%s - %s)" % (match.Score.Total.Home, match.Score.Total.Away)
  98.                                 viewBag.SetString("tBottomTime%02d" % (enum+1), result)
  99.                         else:
  100.                                 result = "(%s - %s)" % (match.Score.Regular.Home, match.Score.Regular.Away)
  101.                                 viewBag.SetString("tBottomTime%02d" % (enum+1), result)
  102.                 elif status == "UPCOMING":
  103.                         date = match.KickOffTime.DateTime.ToLocalTime()
  104.                         hour_minute = "%sH%02d" % (date.Hour, date.Minute)
  105.                         viewBag.SetTranslatedText("tGameInfo%02d" % enum, "{{%s}}.{{AggregateSummaryResults}}" % date)
  106.                         viewBag.SetString("tBottomTime%02d" % (enum+1), "%s" % hour_minute)
  107.                 if match.Id.ToString() == Game.ExternalId.ToString():
  108.                         viewBag.SetVisibility("vHighlightVisibility", True)
  109.                         viewBag.SetFloat("vBottomHighlight", enum+1)
  110.                         viewBag.SetString("tHomeBottomTeamHighlight", match.HomeTeam.TeamCode.ToString().upper())
  111.                         viewBag.SetString("tAwayBottomTeamHighlight", match.AwayTeam.TeamCode.ToString().upper())
  112.  
  113.                         status = match.Status.ToString().upper()
  114.                         if status == "FINISHED" or status == "LIVE":
  115.                                 if hasattr(match.Score, "Total"):
  116.                                         result = "%s - %s" % (match.Score.Total.Home, match.Score.Total.Away)
  117.                                         viewBag.SetString("tBottomTimeHighlight", result)
  118.                                 else:
  119.                                         result = "%s - %s" % (match.Score.Regular.Home, match.Score.Regular.Away)
  120.                                         viewBag.SetString("tBottomTimeHighlight", result)
  121.                         elif status == "UPCOMING":
  122.                                 date = match.KickOffTime.DateTime.ToLocalTime()
  123.                                 hour_minute = "%sH%02d" % (date.Hour, date.Minute)
  124.                                 viewBag.SetString("tBottomTimeHighlight", "%s" % hour_minute)
  125.  
  126. def __clearTags(viewBag):
  127.         """Cleanup tag information
  128.                 Parameters:
  129.                         viewBag
  130.  
  131.         """
  132.         viewBag.SetVisibility("vHighlightVisibility", False)
  133.         for team in ["Home", "Away"]:
  134.                 viewBag.SetString("t%sCoachFunction"%team, "")
  135.                 viewBag.SetString("t%sCoachFirstName"%team, "")
  136.                 viewBag.SetString("t%sCoachLastName"%team, "")
  137.                 viewBag.SetInt("v%sCoachCard"%team, 0)
  138.                 for i in range(1,25):
  139.                         viewBag.SetString("t%sName%02d" % (team, i), "")
  140.                         viewBag.SetString("t%sLastName%02d" % (team, i), "")
  141.                         viewBag.SetString("t%sNumber%02d" % (team, i), "")
  142.                         viewBag.SetInt("v%sCard%02d" % (team, i), 0)           
  143.                         viewBag.SetVisibility("v%sSubstitutionVisibility%02d" % (team, i), False)
  144.                 for tagidx in range(1,6):
  145.                         viewBag.SetString("t%sSubstitutionName%02d"%(team, tagidx), "")
  146.                         viewBag.SetString("t%sSubstitutionLastName%02d"%(team, tagidx), "")
  147.                         viewBag.SetInt("v%sSubstitutionCard%02d"%(team, tagidx), 0)
  148.                        
  149. def __beforeProgramOut(graphicOnAirItem, momentExecution):
  150.  
  151.         graphic = GraphicTemplatesManager.GetGraphicByName("ScoreWithScorers_LineUp")
  152.         Task.Run(action = lambda: intelliflowController.TakeOut(graphic, output, workflowType = intelliflowController.EWorkflowType.Program))

Reply to "LINEUP ACTIVE MATCH"

Here you can reply to the paste above