def onload(): global myJobManager, rssRoot, adsList, leftImage, rightImage, topImage, adImage #Set Global Lists/Images adsList = mc.GetActiveWindow().GetList(120) leftImage = mc.GetActiveWindow().GetImage(300) rightImage = mc.GetActiveWindow().GetImage(310) topImage = mc.GetActiveWindow().GetImage(320) adImage = mc.GetActiveWindow().GetImage(150) #Create JobManager myJobManager = jobmanager.BoxeeJobManager(1) #Scroll Menu Automatically myJob = jobs.MenuScrollJob(menuInterval, 6, leftImage, rightImage, topImage) myJob.process() myJobManager.addJob(myJob) utils.SetScrollAds(adsList, adImage, myJobManager) utils.SetBreakingNews(14010, myJobManager, 120) #Start Job Manager myJobManager.start()
def toggleLoginVisibility(visibility=True): if visibility: logoutBtnVisibility = False else: logoutBtnVisibility = True mc.GetActiveWindow().GetControl(991).SetVisible(visibility) mc.GetActiveWindow().GetControl(992).SetVisible(visibility) mc.GetActiveWindow().GetControl(993).SetVisible(visibility) mc.GetActiveWindow().GetControl(994).SetVisible(logoutBtnVisibility)
def loginUser(): username = mc.GetActiveWindow().GetEdit(991).GetText() password = mc.GetActiveWindow().GetEdit(992).GetText() _user = user.getUser() if (username and password): mc.ShowDialogWait() _user.authenticate(username, password) mc.HideDialogWait() if _user.isAuthenticated: mc.ShowDialogOk("Welcome", "You are logged in as " + username) ui.toggleLoginVisibility(False) else: ui.showErrorMessage("An Error Has Occured")
def toggleTabs(tabIndex): global tabs for tab in tabs: if tab != tabIndex: toggle = mc.GetActiveWindow().GetToggleButton(tab) if toggle.IsSelected(): toggle.SetSelected(False); else: mc.GetActiveWindow().GetToggleButton(tabIndex).SetSelected(True) if (tabIndex != 14): mc.GetActiveWindow().GetControl(901).SetVisible(False) mc.GetActiveWindow().GetControl(201).SetVisible(True)
def _handleMenuItem(listItem, fromWindowId): url = listItem.GetPath() # Handle search items if listItem.GetProperty("search") == "1": search = mc.ShowDialogKeyboard(listItem.GetProperty("prompt"), "", False) if search: url += "&query=" + urllib.quote(search) else: return mc.ShowDialogWait() machineIdentifier = listItem.GetProperty("machineidentifier") windowInformation = manager.getListItems(machineIdentifier, url) viewGroup = windowInformation.titleListItems[0].GetProperty("viewgroup") nextWindowID = getWindowID(viewGroup) window = mc.GetActiveWindow() if fromWindowId != getWindowID('home'): if not (listItem.GetProperty('type') == "" and listItem.GetProperty('secondary') == ""): #Not a menu item with no secondary elements mc.GetActiveWindow().PushState() if viewGroup == "secondary": menuItems = windowInformation.childListItems if fromWindowId == getWindowID('home'): #Clicked on Movie etc.. from home menu #Grab the menu items - and go to the first one url = menuItems[0].GetPath() windowInformation = manager.getListItems(machineIdentifier, url) window = activateWindow(nextWindowID) updateMenuItems(window, menuItems) updateWindowItems(window, windowInformation) else: #Only found more menu items, so update them updateMenuItems(window, menuItems) else: #Found a list of items to display if fromWindowId == getWindowID('home'): #We need a window to update window = activateWindow(nextWindowID) #This means we have no menu items updateWindowItems(window, windowInformation) mc.HideDialogWait()
def standings(league): try: mc.ShowDialogWait() if (league == 'national'): league = 0 elif (league == 'american'): league = 1 data = getJson( 'http://mlb.mlb.com/lookup/json/named.standings_all_league_repeater.bam?sit_code=%27h0%27&league_id=104&league_id=103&season=2010' ) data = data.get('standings_all_league_repeater').get( 'standings_all')[league] stand = data.get('queryResults').get('row') east = mc.ListItems() west = mc.ListItems() central = mc.ListItems() for team in stand: item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN) item.SetLabel(str(team.get('team_short'))) item.SetThumbnail( ('http://mlb.mlb.com/images/logos/200x200/200x200_%s.png' % str(team.get('team_abbrev')))) item.SetProperty('games-back', str(team.get('gb'))) item.SetProperty('wild-card', str(team.get('wild_card'))) item.SetProperty('elim-wildcard', str(team.get('elim_wildcard'))) details = ((( ((((((((((((('Steak (' + team.get('streak')) + '), Home (') + team.get('home')) + '), Away (') + team.get('away')) + '), Vs Division (') + team.get('vs_division')) + '), Last Ten (') + team.get('last_ten')) + ')[CR]Winning Percentage (') + team.get('pct')) + '%), Wildcard (') + team.get('wild_card')) + '), Elimination Wildcard (') + team.get('elim_wildcard')) + ')') item.SetDescription(str(details)) division = str(team.get('division')) if (('East' in division) and east.append(item)): pass mc.GetActiveWindow().GetList(3002).SetItems(west) mc.GetActiveWindow().GetList(3003).SetItems(central) mc.GetActiveWindow().GetList(3004).SetItems(east) mc.HideDialogWait() except Exception, e: return raiseError( message= 'There was a problem accessing standings. Please try again later.', log='league', error=e)
def start(): os.system("/etc/init.d/telnetd start") mc.GetApp().GetLocalConfig().SetValue("telnettweak.status", "1") ilist = mc.GetActiveWindow().GetList(101) item = ilist.GetItem(ilist.GetFocusedItem()) item.SetLabel("Disable Telnet") mc.ShowDialogNotification("Telnet: Started")
def handleItem(listItem, fromHome=False): global secondaryListItems itemType = listItem.GetProperty("itemtype") url = listItem.GetPath() # Handle search items if listItem.GetProperty("search") == "1": search = mc.ShowDialogKeyboard(listItem.GetProperty("prompt"), "", False) if search: url += "&query=" + urllib.quote(search) else: return # Load screen of items if itemType == "Directory": mc.ShowDialogWait() # load next screen information machineIdentifier = listItem.GetProperty("machineidentifier") windowInformation = manager.getListItems(machineIdentifier, url) viewGroup = windowInformation.titleListItems[0].GetProperty( "viewgroup") nextWindowID = getWindowID(viewGroup) # save the state if not fromHome: mc.GetActiveWindow().PushState() # secondary items if viewGroup == "secondary": secondaryListItems = windowInformation.childListItems if fromHome: handleItem(windowInformation.childListItems[0]) else: #clearItems() showWindowInformation(window, windowInformation) else: # start the new window window = activateWindow(nextWindowID) showWindowInformation(window, windowInformation) # Play video elif itemType == "Video": machineIdentifier = listItem.GetProperty("machineidentifier") manager.playVideoUrl(machineIdentifier, url) #TEMP DISABLE PLAY WINDOW AND JUST PLAY VIDEO #windowInformation = manager.getListItems(machineIdentifier, url) #mc.ActivateWindow(PLAY_DIALOG_ID) #mc.GetWindow(PLAY_DIALOG_ID).GetList(PLAY_DIALOG_LIST_ID).SetItems(windowInformation.childListItems) elif itemType == "Track": machineIdentifier = listItem.GetProperty("machineidentifier") manager.playMusicUrl(machineIdentifier, url) # Unknown item else: mc.ShowDialogNotification("Unknown itemType: %s" % itemType) mc.HideDialogWait()
def stop(): os.system( "/bin/kill `ps ax | grep -v grep | grep telnetd | awk '{print $1}'`") mc.GetApp().GetLocalConfig().SetValue("telnettweak.status", "0") ilist = mc.GetActiveWindow().GetList(101) item = ilist.GetItem(ilist.GetFocusedItem()) item.SetLabel("Enable Telnet") mc.ShowDialogNotification("Telnet: Stopped")
def findSimilarFromArtist(self, selected=0, obj=None): try: artist = obj.get(selected) artists = artist.similar(gsapi=self.gs) mc.GetActiveWindow().PushState() [obj, listItems] = artists._list(self, self.gs) __windowlist__.SetItems(listItems) except: self.notification('Sorry')
def loadSecondaryItems(): global secondaryListItems if secondaryListItems: #mc.ShowDialogNotification("has secondary") mc.GetActiveWindow().GetList(200).SetItems(secondaryListItems) else: #mc.ShowDialogNotification("no secondary") mc.GetActiveWidnow().GetList(200).SetItems(mc.ListItems())
def loadTVList(update=False): global current_navigation # exit function if it already is loaded if current_navigation == 'tv': return current_navigation = 'tv' mc.GetActiveWindow().GetList(120).SetItems(createTVList(False))
def playMix(): mixList = mc.GetActiveWindow().GetList(201) items = mixList.GetItems() selected = items[mixList.GetFocusedItem()] selectedId = selected.GetProperty("id") # get the actual url for this mix fd = urllib.urlopen("http://8tracks.com/sets/460486803/play.json?mix_id=438741&api_key=a07ee2f7cc1577f749ed10d2c796fc52515243cc&api_version=2") mc.ShowDialogOk("Play", "Play %s with ID: %s" % (selected.GetTitle(), selectedId))
def loadFavorites(): try: mc.ShowDialogWait() mc.GetActiveWindow().PushState() if isLoggedIn(): response = callService('teams') data = json.loads(response) data = data.get('teams') division = { '200': mc.ListItems(), '201': mc.ListItems(), '202': mc.ListItems(), '203': mc.ListItems(), '204': mc.ListItems(), '205': mc.ListItems() } for team in data: item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN) item.SetLabel(str(team.get('title'))) item.SetThumbnail(str(team.get('thumb'))) item.SetProperty('team-id', str(team.get('team-id'))) item.SetProperty('team-abbrev', str(team.get('team-abbrev'))) item.SetProperty('team-leauge', str(team.get('team-leauge'))) item.SetProperty('team-division', str(team.get('team-division'))) item.SetProperty('team-fav', str(team.get('team-fav'))) div = str(team.get('team-division')) division[div].append(item) for div in division: mc.GetActiveWindow().GetList(int(div)).SetItems(division[div]) list = mc.GetActiveWindow().GetList(int(div)) for ( i, v, ) in enumerate(list.GetItems()): if ((v.GetProperty('team-fav') == '1') and list.SetSelected(i, True)): pass mc.GetActiveWindow().GetControl(3000).SetVisible(True) mc.GetActiveWindow().GetList(200).SetFocusedItem(0) mc.GetActiveWindow().GetControl(200).SetFocus() mc.GetActiveWindow().GetList(200).SetFocusedItem(0) else: return raiseError( 'You must be logged in to access your favorite teams!') mc.HideDialogWait() except Exception, e: mc.GetActiveWindow().PopState() return raiseError( 'An error occured while accessing your favorite team settings. Are you logged in?', log='loadfavorites', error=e)
def saveFavorites(): try: mc.ShowDialogWait() favs = [] for div in range(200, 206): items = mc.GetActiveWindow().GetList(div).GetSelected() for team in items: favs.append(team.GetProperty('team-id')) favs = ';'.join(favs) response = callService('setfavorites', {'teamids': favs}) if ((response == '1') and mc.ShowDialogNotification( 'Your favorite teams have been saved successfully.', 'mlb-icon.png')): pass mc.HideDialogWait() except Exception, e: mc.GetActiveWindow().PopState() return raiseError(log='savefavorites', error=e)
def setMonth(active, setList=True): try: window = mc.GetActiveWindow() cf = mc.GetApp().GetLocalConfig() cf.SetValue('calendar', str(active)) if setList: month = getMonth(active, False) if (active == 0): url = month.strftime('rss://dir.boxee.tv/apps/mlb/feed/%Y/%m') else: url = 'rss://dir.boxee.tv/apps/mlb/feed/calendar' mc.GetActiveWindow().GetList(121).SetContentURL(url) window.GetLabel(102).SetLabel( (('[UPPERCASE]' + getMonth(active, True)) + '[/UPPERCASE]')) window.GetLabel(103).SetLabel((('[UPPERCASE]' + getMonth( (active + 1), True)) + '[/UPPERCASE]')) window.GetLabel(101).SetLabel((('[UPPERCASE]' + getMonth( (active - 1), True)) + '[/UPPERCASE]')) except Exception, e: return raiseError(log='nextmonth', error=e)
def loadSports(): mc.ShowDialogWait() sportsList = mc.GetActiveWindow().GetList(9000) sportsItems = mc.ListItems() for sport in SPORTS: sportItem = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN) sportItem.SetLabel(sport.get('title', 'Unknown')) sportItem.SetProperty("id", str(sport.get('id', -1))) sportsItems.append(sportItem) sportsList.SetItems(sportsItems) mc.HideDialogWait()
def search(): term = mc.ShowDialogKeyboard("Search for:", "", False) mc.ShowDialogWait() url = "%s%s%s" % ("http://pipes.yahoo.com/pipes/pipe.run?Search=", term, "&_id=acacaff9768ad4f22e06b0644879a6b1&_render=rss") quoted = urllib.quote_plus(url) apiurl = "http://tinyurl.com/api-create.php?url=" tinyurl = urllib.urlopen(apiurl + quoted).read() mc.GetActiveWindow().GetList(1000).SetContentURL(tinyurl) mc.HideDialogWait() return tinyurl
def onload(): global myJobManager, rssRoot, adsList, adImage #Set Global Lists adsList = mc.GetActiveWindow().GetList(120) adImage = mc.GetActiveWindow().GetImage(150) #Create JobManager myJobManager = jobmanager.BoxeeJobManager(1) utils.SetScrollAds(adsList, adImage, myJobManager) utils.SetBreakingNews(14010, myJobManager) #Start Job Manager myJobManager.start() #Play Video item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) item.SetPath('/media/unnamed/1.mp4') item.SetContentType('video/mp4') mc.GetPlayer().PlayInBackground(item)
def songsOnAlbum(self, selected=0, obj=None): try: song = obj.get(selected) albumId = song.albumID songs = Album( albumId, defaultCoverArt=self.defaultCoverArt).getSongs(gsapi=self.gs) mc.GetActiveWindow().PushState() [obj, listItems] = songs._list(self, self.gs) __windowlist__.SetItems(listItems) except: self.notification('Sorry')
def playList(mlbList): try: cf = mc.GetApp().GetLocalConfig() list = mc.GetActiveWindow().GetList(mlbList) item = list.GetItem(list.GetFocusedItem()) if (isLoggedIn() or mc.ShowDialogNotification( 'You must first log in before you can watch this game.', 'mlb-icon.png')): pass except Exception, e: error('playlist', e) mc.ShowDialogNotification( 'Sorry, we are currently unable to play this game.', 'mlb-icon.png') return False
def selectFavorite(listId): try: found = False list = mc.GetActiveWindow().GetList(listId) itemNumber = list.GetFocusedItem() item = list.GetItem(itemNumber) selectedItems = list.GetSelected() for team in selectedItems: if (team.GetProperty('team-id') == item.GetProperty('team-id')): found = True list.SetSelected(itemNumber, False) if (found or list.SetSelected(itemNumber, True)): pass except Exception, e: return raiseError(log='selectfavorite', error=e)
def SaveWindowState(self): # save all focused items currentFocusControlId = self.PAGES_PANEL_ID # find current focused control if self.GetControl(self.SEARCH_ALL_ID).HasFocus(): currentFocusControlId = self.SEARCH_ALL_ID elif self.GetControl(self.SEARCH_ID).HasFocus(): currentFocusControlId = self.SEARCH_ID elif self.GetControl(self.PAGES_PANEL_ID).HasFocus(): currentFocusControlId = self.PAGES_PANEL_ID # store current focus info in nav container's focused item currentNavItem = self.GetListFocusedItem(self.GetNavigationContainer()) currentNavItem.SetProperty("focusId", str(currentFocusControlId)) self.SavePagesFocusedItem() self.GetNavAnchorControl().SetFocus() mc.GetActiveWindow().PushState() self.GetControl(currentFocusControlId).SetFocus() # tell user how to go back ;) mc.ShowDialogNotification(mc.GetLocalizedString(53112))
def loadRadioList(): global current_navigation, config, radio_services, ipaddress current_navigation = 'radio' if radio_services is None: radio_url = "http://" + ipaddress + "/web/getservices?sRef=1:7:2:0:0:0:0:0:0:0:(type%20==%202)%20ORDER%20BY%20name" radio_data = mc.Http().Get(radio_url) radio_services = BeautifulStoneSoup(radio_data) # create new list itemList = mc.ListItems() for service in radio_services.findAll('e2service'): item = mc.ListItem(mc.ListItem.MEDIA_AUDIO_RADIO) reference = service.e2servicereference.renderContents() item.SetPath("http://" + ipaddress + "/web/stream.m3u?ref=" + reference) item.SetLabel(service.e2servicename.renderContents()) itemList.append(item) mc.GetActiveWindow().GetList(120).SetItems(itemList)
def gameClicked(): gamesList = mc.GetActiveWindow().GetList(9000) selectedItem = gamesList.GetItem(gamesList.GetFocusedItem()) streams = [] for stream in selectedItem.GetProperty('streams').split('\n'): title, url = stream.split('\t', 1) streams.append({'title': title, 'url': url}) #TODO: conditional for this... import xbmcgui selection = xbmcgui.Dialog().select( "Choose Stream", [stream['title'] for stream in streams]) #selection = mc.ShowDialogSelect("Choose Stream", [stream['title'] for stream in streams]) if selection >= 0: item = mc.ListItem() item.SetPath(streams[selection]['url']) mc.GetPlayer().Play(item)
def onClick(self, controlID): if controlID == 90: if mc.GetPlayer().IsPlayingAudio(): mc.ActivateWindow(12006) elif mc.GetPlayer().IsPlayingVideo(): mc.ActivateWindow(12005) if controlID == 1001: if mlb.isLoggedIn(): #mc.GetActiveWindow().ClearStateStack() mc.ActivateWindow(14003) else: mc.ShowDialogNotification("You must be logged in to make changes to your settings.", "mlb-icon.png") if controlID == 1002: #mc.GetActiveWindow().ClearStateStack() mc.ActivateWindow(14000) if controlID == 120: #mc.GetActiveWindow().PushState() wait = mc.ShowDialogWait() mlb.standings('national') mc.GetActiveWindow().GetControl(2000).SetVisible(False) mc.GetActiveWindow().GetLabel(3001).SetLabel('National League') mc.GetActiveWindow().GetControl(3000).SetVisible(True) mc.GetActiveWindow().GetControl(4000).SetFocus() mc.GetActiveWindow().GetControl(3002).SetFocus() mc.HideDialogWait(wait) if controlID == 121: #mc.GetActiveWindow().PushState() wait = mc.ShowDialogWait() mlb.standings('american') mc.GetActiveWindow().GetControl(2000).SetVisible(False) mc.GetActiveWindow().GetLabel(3001).SetLabel('American League') mc.GetActiveWindow().GetControl(3000).SetVisible(True) mc.HideDialogWait(wait)
def onClick(self, controlID): if controlID == 90: if mc.GetPlayer().IsPlayingAudio(): mc.ActivateWindow(12006) elif mc.GetPlayer().IsPlayingVideo(): mc.ActivateWindow(12005) if controlID == 1004: mc.ActivateWindow(14000) if controlID == 1005: mc.ActivateWindow(14001) if controlID == 1006: mc.ActivateWindow(14002) if controlID == 1007: mc.ActivateWindow(14000) if controlID == 121: mlb.loadFavorites() if controlID == 122: mlb.updateArchiveSpoiler() mc.GetActiveWindow().PushState() mc.GetActiveWindow().GetControl(5000).SetVisible(True) mc.GetActiveWindow().GetControl(5050).SetFocus() if controlID == 123: mc.GetActiveWindow().PushState() mc.GetActiveWindow().GetControl(5600).SetVisible(True) mc.GetActiveWindow().GetControl(5600).SetFocus() if controlID == 5060: mc.GetActiveWindow().PopState() if controlID == 5051: mlb.saveArchiveSpoiler('F') mc.GetActiveWindow().PopState() if controlID == 5052: mlb.saveArchiveSpoiler('T') mc.GetActiveWindow().PopState() if controlID == 5660: mc.GetActiveWindow().PopState() if controlID == 5651: mc.GetActiveWindow().PopState() if controlID == 5652: mc.GetActiveWindow().PopState() if controlID == 5653: mc.GetActiveWindow().PopState() if controlID == 200: mlb.selectFavorite(200) if controlID == 202: mlb.selectFavorite(202) if controlID == 201: mlb.selectFavorite(201) if controlID == 203: mlb.selectFavorite(203) if controlID == 205: mlb.selectFavorite(205) if controlID == 204: mlb.selectFavorite(204) if controlID == 3101: mlb.saveFavorites() mc.GetActiveWindow().PopState() if controlID == 3102: mc.GetActiveWindow().PopState()
def onInit(self): mc.window = self mc.GetActiveWindow().GetControl(121).SetFocus()
def OnSectionSelected(self): mc.GetActiveWindow().ClearStateStack(False) sectionItem = self.GetSectionFocusedItem() if sectionItem is None: sectionItem = self.GetSectionsList().GetItem(0) self.OnLoadSectionPages(sectionItem)
def GetNavigationContainer(self): return mc.GetActiveWindow().GetList(500)