def start(twitterhash=None, standalone=False): if not twitterhash: userInput = True if os.path.exists(tweet_file): twitter_data = json.loads(FileIO.fileread(tweet_file)) twitterhash = twitter_data["hash"] twitter_mediafile = twitter_data["file"] if twitter_mediafile == xbmc.getInfoLabel('Player.Filenameandpath'): userInput = False else: userInput = False if userInput: dialog = xbmcgui.Dialog() twitterhash = dialog.input(translate(32046), type=xbmcgui.INPUT_ALPHANUM) if len(twitterhash) != 0: twitterhash = twitterhash.replace("#", "") else: xbmcgui.Dialog().ok(translate(32000), translate(32047)) mainmenu.start() if twitterhash: # Save twitter hashtag if twitter_history_enabled == 'true': tweet.add_hashtag_to_twitter_history(twitterhash) if xbmc.getCondVisibility("Player.HasMedia") and save_history_during_playback == 'true': tweet.savecurrenthash(twitterhash) main = TwitterDialog('script-sinaweibo-Twitter.xml', addon_path, getskinfolder(), '', hash=twitterhash, standalone=standalone) main.doModal() del main
def start(twitterhash=None, standalone=False): if not twitterhash: userInput = True if os.path.exists(tweet_file): twitter_data = json.loads(FileIO.fileread(tweet_file)) twitterhash = twitter_data["hash"] twitter_mediafile = twitter_data["file"] if twitter_mediafile == xbmc.getInfoLabel('Player.Filenameandpath'): userInput = False else: userInput = False if userInput: dialog = xbmcgui.Dialog() twitterhash = dialog.input(translate(32046), type=xbmcgui.INPUT_ALPHANUM) if len(twitterhash) != 0: twitterhash = twitterhash.replace("#","") else: xbmcgui.Dialog().ok(translate(32000), translate(32047)) mainmenu.start() if twitterhash: #Save twitter hashtag if twitter_history_enabled == 'true': tweet.add_hashtag_to_twitter_history(twitterhash) if xbmc.getCondVisibility("Player.HasMedia") and save_hashes_during_playback == 'true': tweet.savecurrenthash(twitterhash) main = TwitterDialog('script-matchcenter-Twitter.xml', addon_path, getskinfolder(), '', hash=twitterhash, standalone=standalone) main.doModal() del main
def start(twitterhash=None, standalone=False): if not twitterhash: userInput = True if os.path.exists(tweet_file): twitter_data = json.loads(FileIO.fileread(weibo_file)) twitterhash = twitter_data["hash"] twitter_mediafile = twitter_data["file"] if twitter_mediafile == xbmc.getInfoLabel('Player.Filenameandpath'): userInput = False else: userInput = False if userInput: dialog = xbmcgui.Dialog() twitterhash = dialog.input(translate(32048), type=xbmcgui.INPUT_NUMERIC) if len(twitterhash) > 0: # search for the given user's weibo twitterhash = twitterhash.replace("#", "") else: # show the following accounts in settings userList = list() for i in range(1, 11): username = addon.getSetting('UID%d' % i).replace('@', '') if len(username) > 0: userList.append(username) main = TwitterDialog('script-sinaweibo-Weibo.xml', addon_path, getskinfolder(), '', hash=userList, standalone=False) main.doModal() del main if twitterhash: # Save twitter hashtag if twitter_history_enabled == 'true': sina_tweet.add_hashtag_to_twitter_history(twitterhash) if xbmc.getCondVisibility("Player.HasMedia") and save_history_during_playback == 'true': sina_tweet.savecurrenthash(twitterhash) main = TwitterDialog('script-sinaweibo-Weibo.xml', addon_path, getskinfolder(), '', hash=twitterhash, standalone=standalone) main.doModal() del main
def setLineUps(self,team): xbmc.executebuiltin("ClearProperty(has_details,Home)") self.getControl(32519).setImage(os.path.join(addon_path,"resources","img","pitch.png")) xbmc.executebuiltin("SetProperty(has_lineups,1,home)") self.current_lineup = team if team == "home": if 'idEvent' not in self.match.__dict__.keys(): if self.match.HomeTeamObj: self.LineUpTeamObj = self.match.HomeTeamObj else: self.LineUpTeamObj = None self.teamname = self.match.HomeTeam self.formationlabel = self.match.HomeTeamFormation self.lineupgoalkeeper = self.match.HomeLineupGoalkeeper self.lineupdefenders = self.match.HomeLineupDefense self.lineupmidfielders = self.match.HomeLineupMidfield self.lineupforwarders = self.match.HomeLineupForward self.lineupsubs = self.match.HomeLineupSubstitutes if self.match.HomeLineupCoach: self.lineupcoach = self.match.HomeLineupCoach.replace(";","") else: self.lineupcoach = {} else: self.teamname = self.match.strHomeTeam self.LineUpTeamObj = self.match.HomeTeamObj self.formationlabel = self.match.strHomeFormation self.lineupgoalkeeper = self.match.strHomeLineupGoalkeeper self.lineupdefenders = self.match.strHomeLineupDefense self.lineupmidfielders = self.match.strHomeLineupMidfield self.lineupforwarders = self.match.strHomeLineupForward self.lineupsubs = self.match.strHomeLineupSubstitutes self.lineupcoach = {} self.getControl(32527).setLabel(translate(32027)) else: if 'idEvent' not in self.match.__dict__.keys(): if self.match.AwayTeamObj: self.LineUpTeamObj = self.match.AwayTeamObj else: self.LineUpTeamObj = None self.teamname = self.match.AwayTeam self.formationlabel = self.match.AwayTeamFormation self.lineupgoalkeeper = self.match.AwayLineupGoalkeeper self.lineupdefenders = self.match.AwayLineupDefense self.lineupmidfielders = self.match.AwayLineupMidfield self.lineupforwarders = self.match.AwayLineupForward self.lineupsubs = self.match.AwayLineupSubstitutes if self.match.AwayLineupCoach: self.lineupcoach = self.match.AwayLineupCoach.replace(";","") else: self.lineupcoach = {} else: self.teamname = self.match.strAwayTeam self.LineUpTeamObj = self.match.AwayTeamObj self.formationlabel = self.match.strAwayFormation self.lineupgoalkeeper = self.match.strAwayLineupGoalkeeper self.lineupdefenders = self.match.strAwayLineupDefense self.lineupmidfielders = self.match.strAwayLineupMidfield self.lineupforwarders = self.match.strAwayLineupForward self.lineupsubs = self.match.strAwayLineupSubstitutes self.lineupcoach = {} self.getControl(32527).setLabel(translate(32028)) #Set Labels for the panel self.getControl(32522).setLabel(translate(32029) + ":") self.getControl(32523).setLabel(translate(32030) + ":") #Set team information #Name self.getControl(32521).setLabel(self.teamname) if self.LineUpTeamObj: if show_alternative == "true": self.getControl(32521).setLabel(self.LineUpTeamObj.AlternativeNameFirst) #Set team Badge if self.LineUpTeamObj.strTeamBadge: self.getControl(32520).setImage(self.LineUpTeamObj.strTeamBadge) else: self.getControl(32520).setImage(os.path.join(addon_path,"resources","img","nobadge_placeholder.png")) else: self.getControl(32520).setImage(os.path.join(addon_path,"resources","img","nobadge_placeholder.png")) #Set team formation label if self.formationlabel: self.getControl(32518).setLabel(self.formationlabel) #Set coach if self.lineupcoach: self.getControl(32526).setLabel("[COLOR selected]" + translate(32026) + ":[/COLOR] " + self.lineupcoach) #Set Lineup starters = [] if self.lineupgoalkeeper: self.lineupgoalkeeper = self.lineupgoalkeeper.replace(";","") starters.append(self.lineupgoalkeeper) defenders = [] if self.lineupdefenders: for player in self.lineupdefenders.split(";"): if player: defenders.append(player.strip()) starters.append(player.strip()) self.lineupdefenders = defenders del defenders midfielders = [] if self.lineupmidfielders: for player in self.lineupmidfielders.split(";"): if player: midfielders.append(player.strip()) starters.append(player.strip()) self.lineupmidfielders = midfielders del midfielders forwarders = [] if self.lineupforwarders: for player in self.lineupforwarders.split(";"): if player: forwarders.append(player.strip()) starters.append(player.strip()) self.getControl(32524).reset() self.getControl(32524).addItems(starters) self.lineupforwarders = forwarders #Set Subs subs = [] if self.lineupsubs: for player in self.lineupsubs.split(";"): if player: subs.append(player.strip()) self.getControl(32525).reset() self.getControl(32525).addItems(subs) #Players on pitch pitch = self.getControl(32519) pitchPosition = pitch.getPosition() pitchHeight = pitch.getHeight() pitchWidth = pitch.getWidth() if self.formationlabel: formationsjson = eval(FileIO.fileread(json_formations)) formation = formationsjson[self.formationlabel] else: formation = None if formation: #goalkeeper goalkeeper = formation["goalkeeper"] image_size = positions.getShirtHeight(pitchHeight,goalkeeper[1]) image_x = int(goalkeeper[0]*float(pitchWidth))+int(0.15*image_size) image_y = int(goalkeeper[1]*float(pitchHeight))+int(0.15*image_size) if self.LineUpTeamObj and self.LineUpTeamObj.strTeamJersey: image = xbmcgui.ControlImage(image_x,image_y,image_size,image_size, self.LineUpTeamObj.strTeamJersey ) self.controls.append(image) else: image = xbmcgui.ControlImage(image_x,image_y,image_size,image_size, os.path.join(addon_path,"resources","img","nokit_placeholder.png") ) self.controls.append(image) label = positions.getLabel(image, "[B]" + self.lineupgoalkeeper + "[/B]") self.controls.append(label) #defenders defenders = formation["defenders"] if defenders: i = 0 for defender in defenders: image_size = positions.getShirtHeight(pitchHeight,defender[1]) image_x = int(defender[0]*float(pitchWidth))+int(0.15*image_size) image_y = int(defender[1]*float(pitchHeight))+int(0.15*image_size) if self.LineUpTeamObj and self.LineUpTeamObj.strTeamJersey: image = xbmcgui.ControlImage(image_x,image_y,image_size,image_size, self.LineUpTeamObj.strTeamJersey) self.controls.append(image) else: image = xbmcgui.ControlImage(image_x,image_y,image_size,image_size, os.path.join(addon_path,"resources","img","nokit_placeholder.png") ) self.controls.append(image) label = positions.getLabel(image,"[B]" + self.lineupdefenders[i] + "[/B]") self.controls.append(label) i += 1 #midfielders midfielders = formation["midfielders"] if midfielders: i = 0 for midfielder in midfielders: image_size = positions.getShirtHeight(pitchHeight,midfielder[1]) image_x = int(midfielder[0]*float(pitchWidth))+int(0.15*image_size) image_y = int(midfielder[1]*float(pitchHeight))+int(0.15*image_size) if self.LineUpTeamObj and self.LineUpTeamObj.strTeamJersey: image = xbmcgui.ControlImage(image_x,image_y,image_size,image_size, self.LineUpTeamObj.strTeamJersey) self.controls.append(image) else: image = xbmcgui.ControlImage(image_x,image_y,image_size,image_size, os.path.join(addon_path,"resources","img","nokit_placeholder.png") ) self.controls.append(image) label = positions.getLabel(image,"[B]" + self.lineupmidfielders[i] + "[/B]") self.controls.append(label) i += 1 #forwarders forwarders = formation["forwarders"] if forwarders: i = 0 for forwarder in forwarders: image_size = positions.getShirtHeight(pitchHeight,forwarder[1]) image_x = int(forwarder[0]*float(pitchWidth))+int(0.15*image_size) image_y = int(forwarder[1]*float(pitchHeight))+int(0.15*image_size) if self.LineUpTeamObj and self.LineUpTeamObj.strTeamJersey: image = xbmcgui.ControlImage(image_x,image_y,image_size,image_size, self.LineUpTeamObj.strTeamJersey) self.controls.append(image) else: image = xbmcgui.ControlImage(image_x,image_y,image_size,image_size, os.path.join(addon_path,"resources","img","nokit_placeholder.png") ) self.controls.append(image) label = positions.getLabel(image,"[B]" + self.lineupforwarders[i] + "[/B]") self.controls.append(label) i += 1 self.addControls(self.controls) self.setFocusId(32527)
def setLineUps(self, team): xbmc.executebuiltin("ClearProperty(has_details,Home)") self.getControl(32519).setImage( os.path.join(addon_path, "resources", "img", "pitch.png")) xbmc.executebuiltin("SetProperty(has_lineups,1,home)") self.current_lineup = team if team == "home": if 'idEvent' not in self.match.__dict__.keys(): if self.match.HomeTeamObj: self.LineUpTeamObj = self.match.HomeTeamObj else: self.LineUpTeamObj = None self.teamname = self.match.HomeTeam self.formationlabel = self.match.HomeTeamFormation self.lineupgoalkeeper = self.match.HomeLineupGoalkeeper self.lineupdefenders = self.match.HomeLineupDefense self.lineupmidfielders = self.match.HomeLineupMidfield self.lineupforwarders = self.match.HomeLineupForward self.lineupsubs = self.match.HomeLineupSubstitutes if self.match.HomeLineupCoach: self.lineupcoach = self.match.HomeLineupCoach.replace( ";", "") else: self.lineupcoach = {} else: self.teamname = self.match.strHomeTeam self.LineUpTeamObj = self.match.HomeTeamObj self.formationlabel = self.match.strHomeFormation self.lineupgoalkeeper = self.match.strHomeLineupGoalkeeper self.lineupdefenders = self.match.strHomeLineupDefense self.lineupmidfielders = self.match.strHomeLineupMidfield self.lineupforwarders = self.match.strHomeLineupForward self.lineupsubs = self.match.strHomeLineupSubstitutes self.lineupcoach = {} self.getControl(32527).setLabel(translate(32027)) else: if 'idEvent' not in self.match.__dict__.keys(): if self.match.AwayTeamObj: self.LineUpTeamObj = self.match.AwayTeamObj else: self.LineUpTeamObj = None self.teamname = self.match.AwayTeam self.formationlabel = self.match.AwayTeamFormation self.lineupgoalkeeper = self.match.AwayLineupGoalkeeper self.lineupdefenders = self.match.AwayLineupDefense self.lineupmidfielders = self.match.AwayLineupMidfield self.lineupforwarders = self.match.AwayLineupForward self.lineupsubs = self.match.AwayLineupSubstitutes if self.match.AwayLineupCoach: self.lineupcoach = self.match.AwayLineupCoach.replace( ";", "") else: self.lineupcoach = {} else: self.teamname = self.match.strAwayTeam self.LineUpTeamObj = self.match.AwayTeamObj self.formationlabel = self.match.strAwayFormation self.lineupgoalkeeper = self.match.strAwayLineupGoalkeeper self.lineupdefenders = self.match.strAwayLineupDefense self.lineupmidfielders = self.match.strAwayLineupMidfield self.lineupforwarders = self.match.strAwayLineupForward self.lineupsubs = self.match.strAwayLineupSubstitutes self.lineupcoach = {} self.getControl(32527).setLabel(translate(32028)) #Set Labels for the panel self.getControl(32522).setLabel(translate(32029) + ":") self.getControl(32523).setLabel(translate(32030) + ":") #Set team information #Name self.getControl(32521).setLabel(self.teamname) if self.LineUpTeamObj: if show_alternative == "true": self.getControl(32521).setLabel( self.LineUpTeamObj.AlternativeNameFirst) #Set team Badge if self.LineUpTeamObj.strTeamBadge: self.getControl(32520).setImage( self.LineUpTeamObj.strTeamBadge) else: self.getControl(32520).setImage( os.path.join(addon_path, "resources", "img", "nobadge_placeholder.png")) else: self.getControl(32520).setImage( os.path.join(addon_path, "resources", "img", "nobadge_placeholder.png")) #Set team formation label if self.formationlabel: self.getControl(32518).setLabel(self.formationlabel) #Set coach if self.lineupcoach: self.getControl(32526).setLabel("[COLOR selected]" + translate(32026) + ":[/COLOR] " + self.lineupcoach) #Set Lineup starters = [] if self.lineupgoalkeeper: self.lineupgoalkeeper = self.lineupgoalkeeper.replace(";", "") starters.append(self.lineupgoalkeeper) defenders = [] if self.lineupdefenders: for player in self.lineupdefenders.split(";"): if player: defenders.append(player.strip()) starters.append(player.strip()) self.lineupdefenders = defenders del defenders midfielders = [] if self.lineupmidfielders: for player in self.lineupmidfielders.split(";"): if player: midfielders.append(player.strip()) starters.append(player.strip()) self.lineupmidfielders = midfielders del midfielders forwarders = [] if self.lineupforwarders: for player in self.lineupforwarders.split(";"): if player: forwarders.append(player.strip()) starters.append(player.strip()) self.getControl(32524).reset() self.getControl(32524).addItems(starters) self.lineupforwarders = forwarders #Set Subs subs = [] if self.lineupsubs: for player in self.lineupsubs.split(";"): if player: subs.append(player.strip()) self.getControl(32525).reset() self.getControl(32525).addItems(subs) #Players on pitch pitch = self.getControl(32519) pitchPosition = pitch.getPosition() pitchHeight = pitch.getHeight() pitchWidth = pitch.getWidth() if self.formationlabel: formationsjson = eval(FileIO.fileread(json_formations)) formation = formationsjson[self.formationlabel] else: formation = None if formation: #goalkeeper goalkeeper = formation["goalkeeper"] image_size = positions.getShirtHeight(pitchHeight, goalkeeper[1]) image_x = int(goalkeeper[0] * float(pitchWidth)) + int( 0.15 * image_size) image_y = int(goalkeeper[1] * float(pitchHeight)) + int( 0.15 * image_size) if self.LineUpTeamObj and self.LineUpTeamObj.strTeamJersey: image = xbmcgui.ControlImage(image_x, image_y, image_size, image_size, self.LineUpTeamObj.strTeamJersey) self.controls.append(image) else: image = xbmcgui.ControlImage( image_x, image_y, image_size, image_size, os.path.join(addon_path, "resources", "img", "nokit_placeholder.png")) self.controls.append(image) label = positions.getLabel(image, "[B]" + self.lineupgoalkeeper + "[/B]") self.controls.append(label) #defenders defenders = formation["defenders"] if defenders: i = 0 for defender in defenders: image_size = positions.getShirtHeight( pitchHeight, defender[1]) image_x = int(defender[0] * float(pitchWidth)) + int( 0.15 * image_size) image_y = int(defender[1] * float(pitchHeight)) + int( 0.15 * image_size) if self.LineUpTeamObj and self.LineUpTeamObj.strTeamJersey: image = xbmcgui.ControlImage( image_x, image_y, image_size, image_size, self.LineUpTeamObj.strTeamJersey) self.controls.append(image) else: image = xbmcgui.ControlImage( image_x, image_y, image_size, image_size, os.path.join(addon_path, "resources", "img", "nokit_placeholder.png")) self.controls.append(image) label = positions.getLabel( image, "[B]" + self.lineupdefenders[i] + "[/B]") self.controls.append(label) i += 1 #midfielders midfielders = formation["midfielders"] if midfielders: i = 0 for midfielder in midfielders: image_size = positions.getShirtHeight( pitchHeight, midfielder[1]) image_x = int(midfielder[0] * float(pitchWidth)) + int( 0.15 * image_size) image_y = int(midfielder[1] * float(pitchHeight)) + int( 0.15 * image_size) if self.LineUpTeamObj and self.LineUpTeamObj.strTeamJersey: image = xbmcgui.ControlImage( image_x, image_y, image_size, image_size, self.LineUpTeamObj.strTeamJersey) self.controls.append(image) else: image = xbmcgui.ControlImage( image_x, image_y, image_size, image_size, os.path.join(addon_path, "resources", "img", "nokit_placeholder.png")) self.controls.append(image) label = positions.getLabel( image, "[B]" + self.lineupmidfielders[i] + "[/B]") self.controls.append(label) i += 1 #forwarders forwarders = formation["forwarders"] if forwarders: i = 0 for forwarder in forwarders: image_size = positions.getShirtHeight( pitchHeight, forwarder[1]) image_x = int(forwarder[0] * float(pitchWidth)) + int( 0.15 * image_size) image_y = int(forwarder[1] * float(pitchHeight)) + int( 0.15 * image_size) if self.LineUpTeamObj and self.LineUpTeamObj.strTeamJersey: image = xbmcgui.ControlImage( image_x, image_y, image_size, image_size, self.LineUpTeamObj.strTeamJersey) self.controls.append(image) else: image = xbmcgui.ControlImage( image_x, image_y, image_size, image_size, os.path.join(addon_path, "resources", "img", "nokit_placeholder.png")) self.controls.append(image) label = positions.getLabel( image, "[B]" + self.lineupforwarders[i] + "[/B]") self.controls.append(label) i += 1 self.addControls(self.controls) self.setFocusId(32527)