def InstallApp(URL='', mediaitem=CMediaItem()): type = mediaitem.GetType(0) attributes = mediaitem.GetType(1) if type == 'app': response = mc.ShowDialogConfirm("Message", "Install Boxee App?", "No", "Yes") if response == False: return mc.ShowDialogWait() #loading text installer = CInstaller() # if attributes == 'navi-x': result = installer.InstallNaviX(URL, mediaitem) # else: # result = installer.InstallScript(URL, mediaitem) if result == 0: mc.ShowDialogOk("Installer", "Installation successful.") mc.ShowDialogOk("Installer", "Please restart Boxee.") elif result == -1: mc.ShowDialogOk("Installer", "Installation aborted.") elif result == -3: mc.ShowDialogOk("Installer", "Invalid ZIP file.") else: mc.ShowDialogOk("Installer", "Installation failed.") mc.HideDialogWait() return
def MenuRightSelectItem(itemNumber): if itemNumber == 0: #add item to favorites stackitem = mc.GetWindow(14000).GetList(555).GetItem(0) URL = stackitem.GetProperty("URL") if URL.find(favorites_URL) != -1: mc.ShowDialogOk("Error", "Cannot Add From Favorite List.") return ModifyFavoriteList('add') mc.GetWindow(14000).GetList(GetListView()).SetFocus() elif itemNumber == 1: #remove items from favorites stackitem = mc.GetWindow(14000).GetList(555).GetItem(0) URL = stackitem.GetProperty("URL") if URL.find(favorites_URL) == -1: mc.ShowDialogOk("Error", "Please Select Favorite List First.") return ModifyFavoriteList('remove') userkey = mc.GetApp().GetLocalConfig().GetValue("userkey") arguments = "?user="******"&request=get&type=.plx" ParsePlaylist(URL=favorites_URL + arguments) mc.GetWindow(14000).GetList(GetListView()).SetFocus() elif itemNumber == 2: #about Navi-X mc.GetWindow(14000).PushState() OpenTextFile(URL='readme.txt')
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 raiseError(message=False, log=False, error=False): mc.HideDialogWait() if (log and error): mc.LogError(((('@mlb.tv (' + log) + ') ') + str(error))) if message: response = message else: response = 'An error has occurred. Details have been saved in your log. Please notify Boxee support.' mc.ShowDialogOk('MLB.TV', response) return False
def MenuLeftSelectItem(itemNumber): if itemNumber == 0: SelectItem(iURL=home_URL) mc.GetWindow(14000).GetList(GetListView()).SetFocus() elif itemNumber == 1: userkey = mc.GetApp().GetLocalConfig().GetValue("userkey") arguments = "?user="******"&request=get&type=.plx" SelectItem(iURL=favorites_URL + arguments) elif itemNumber == 2: ListView = mc.GetApp().GetLocalConfig().GetValue("listview") if ListView == "default": mc.GetApp().GetLocalConfig().SetValue("listview", "thumbnails") elif ListView == "thumbnails": mc.GetApp().GetLocalConfig().SetValue("listview", "list") else: mc.GetApp().GetLocalConfig().SetValue("listview", "default") Init() ParsePlaylist(reload=False) mc.GetWindow(14000).GetList(122).SetFocus() mc.GetWindow(14000).GetList(122).SetFocusedItem(itemNumber) elif itemNumber == 3: if nxserver.is_user_logged_in() == True: response = mc.ShowDialogConfirm("Message", "Sign out?", "No", "Yes") if response: nxserver.logout() mc.ShowDialogOk("Sign out", "Sign out Successful.") Init() else: result = nxserver.login() if result == 0: mc.ShowDialogOk("Sign in", "Sign in Successful.") Init() elif result == -1: mc.ShowDialogOk("Sign in", "Sign in Failed.") mc.GetWindow(14000).GetList(GetListView()).SetFocus() elif itemNumber == 4: mc.CloseWindow() pass
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 OnMainWindowLoad(self): # load sections menu if it is empty #systemVersion = xbmc.getInfoLabel('System.BuildVersion') #mc.LogInfo("system version: %s" % systemVersion) mc.LogInfo("On Load Main Window") if 0 == len(self.GetSectionsList().GetItems()): tracker.trackMainView('UA-25431823-1') mc.LogInfo("On Load: Generate sections menu") sectionsMenu = mc.ListItems() sectionsList = self.LoadSectionsList() if 0 == len(sectionsList): mc.LogInfo("Failed to load data from url: %s" % self.model.URL) mc.ShowDialogOk( self.localizedString("No access to www.fs.to"), self.localizedString( "Please make sure you have proxy disabled and check access to www.fs.ua in your internet browser" )) mc.GetApp().Close() return mc.ShowDialogWait() # fill sections list with available items for section in sectionsList: item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN) item.SetLabel(section["name"]) item.SetPath(section["path"]) item.SetProperty("search", str(section["cleanUrl"])) sectionsMenu.append(item) self.GetSectionsList().SetItems(sectionsMenu) self.GetSectionsList().SetFocusedItem(0) self.GetControl(self.SECTIONS_LIST_ID).SetVisible(True) self.OnSectionSelected() mc.HideDialogWait() else: mc.LogInfo("Main Window Re-load") self.FixupNavigation() if self.IsRecentlyViewedActive(): self.ReloadRecentlyViewedSection()
def onClick(self, controlID): """start your code""" """end your code""" if controlID == 91: mlb.prevMonth() if controlID == 92: mlb.nextMonth() 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 == 1003: mc.ActivateWindow(14000) if controlID == 121: clear = mc.ListItems() mc.GetActiveWindow().GetList(4002).SetItems(clear) list = mc.GetActiveWindow().GetList(121) item = list.GetItem(list.GetFocusedItem()) if item.GetProperty('today'): mc.ActivateWindow(14000) elif not item.GetProperty('display') or not item.GetDescription(): mc.ShowDialogNotification('No games available for this day.', 'mlb-icon.png') else: date = item.GetPath() date = date.split(':') games = mlb.getGames(date[0], date[1], date[2]) if games: mc.GetActiveWindow().PushState() mc.GetActiveWindow().GetList(4002).SetItems(games) mc.GetActiveWindow().GetControl(4000).SetVisible(True) mc.GetActiveWindow().GetList(4002).SetFocusedItem(0) mc.GetActiveWindow().GetControl(4002).SetFocus() mc.GetActiveWindow().GetList(4002).SetFocusedItem(0) else: mc.ShowDialogOk( "MLB.TV", "To view MLB Post Season content, please disconnect and reconnect your MLB.TV account at http://boxee.tv/services." ) item.Dump() if controlID == 4002: mlb.playList(4002) if controlID == 4003: mc.GetActiveWindow().PopState() if controlID == 501: mlb.playItem(501)
def loadSport(sport_id): mc.LogDebug("Loading sport %s" % sport_id) mc.ShowDialogWait() label = mc.GetActiveWindow().GetLabel(9010) sport = None for SPORT in SPORTS: if SPORT['id'] == sport_id: sport = SPORT break else: mc.LogError("Sport %s not found." % sport_id) mc.ShowDialogOk("Error", "Sport %s not found." % sport_id) mc.CloseWindow() label.SetLabel(sport['title']) gamesList = mc.GetActiveWindow().GetList(9000) gamesItems = mc.ListItems() content = feedparser.parse(urllib.urlopen(FEED % sport_id)) for item in content['entries']: title = str(item.title) match = sport['regex_title'].match(title) if match: day_date = date(int(match.group('year')), MONTHS.index(match.group('month').lower()), int(match.group('day'))) if day_date < date.today(): continue for game in sport['regex_game'].finditer(str(item.content)): game_time = time.strptime( '%s %s EST' % (day_date, game.group('est_time')), '%Y-%m-%d %I:%M %p %Z') #Skip games that occured more than 5 hours ago if time.localtime(time.mktime(game_time) + 5 * 60 * 60) < time.time(): continue name = '%s @ %s' % (game.group('team_away').strip(), game.group('team_home').strip()) streams = [] for stream in sport['regex_stream'].finditer( game.group('streams')): mc.LogDebug( 'MYP2P::: "%s" - Stream "%s" (%s)' % (name, stream.group('name'), stream.group('url'))) streams.append(stream.groupdict()) stream_string = '\n'.join([ '%s\t%s' % (stream['name'], stream['url']) for stream in streams ]) gameItem = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN) gameItem.SetLabel(name) gameItem.SetProperty('streams', stream_string) gamesItems.append(gameItem) gamesList.SetItems(gamesItems) mc.HideDialogWait()
def SelectItem(iURL='', listitem=''): if listitem != '': mediaitem = CMediaItem() mediaitem.URL = listitem.GetProperty("url") mediaitem.processor = listitem.GetProperty("processor") mediaitem.type = listitem.GetProperty("media_type") mediaitem.background = listitem.GetProperty("background") elif iURL != '': mediaitem = CMediaItem() mediaitem.URL = iURL ext = getFileExtension(iURL) if ext == 'plx': mediaitem.type = 'playlist' elif ext == 'xml' or ext == 'atom': mediaitem.type = 'rss' elif ext == 'jpg' or ext == 'png' or ext == 'gif': mediaitem.type = 'image' elif ext == 'txt': mediaitem.type == 'text' elif ext == 'zip': mediaitem.type == 'script' else: mediaitem.type = 'video' #same as audio else: if playlist.size() == 0: #playlist is empty return mediaitem = playlist.list[pos] #type = mediaitem.type type = mediaitem.GetType() #mediaitem is some type of playlist (non-search, non-media) if type == 'playlist' or type == 'favorite' or type[0:3] == 'rss' or \ type == 'rss_flickr_daily' or type == 'directory' or \ type == 'html_youtube' or type == 'xml_shoutcast' or \ type == 'xml_applemovie' or type == 'atom' or type == 'opml': #add new URL to the history array mc.GetWindow(14000).PushState() #exception case: Do not add Youtube pages to history list # if mediaitem.GetType() == 'html_youtube': # append = False result = ParsePlaylist(mediaitem=mediaitem) ##mc.ShowDialogOk("Debug", "ParsePlaylist result = " + str(result)) if result != 0: ### ParsePlaylist failed + playlist cleared by ParsePlaylist mc.HideDialogWait() return -1 #mediaitem is a audio or video to play elif type == 'video' or type == 'audio' or type == 'html': mc.ShowDialogWait() MyPlayer = CPlayer() ##mc.ShowDialogOk("Debug in SelectItem", "type = " + mediaitem.type + '\n' + "processor = " + mediaitem.processor) result = MyPlayer.play_URL(mediaitem.URL, mediaitem) mc.HideDialogWait() if result["code"] == 1: # general error try: result["data"] except KeyError: result["data"] = "Cannot open file" if result["data"][0:2] == 'p:': result["data"] = result["data"][2:] etitle = "Processor Error" else: etitle = "Error" mc.ShowDialogOk(etitle, result["data"]) elif result["code"] == 2: # redirect to playlist redir_item = CMediaItem() redir_item.URL = result["data"] redir_item.type = 'playlist' ParsePlaylist(mediaitem=redir_item, URL=result["data"]) else: #When app reloads after play it will resume at the last playlist viewed mc.GetApp().GetLocalConfig().SetValue("resume", "True") #mediaitem is other type: go through possibilites elif type == 'image': viewImage(0, mediaitem) #single file show mc.GetApp().GetLocalConfig().SetValue("resume", "True") elif type == 'text': mc.GetWindow(14000).PushState() OpenTextFile(mediaitem=mediaitem) elif (type[0:3] == 'app'): InstallApp(mediaitem=mediaitem) elif type == 'download': mc.ShowDialogOk("Error", "This item is not supported because it is a " + type) elif (type[0:6] == 'search'): mediaitem_search = PlaylistSearch(mediaitem) if mediaitem_search != None: mc.GetWindow(14000).PushState() result = ParsePlaylist(mediaitem=mediaitem_search) elif type == 'window': mc.ShowDialogOk("Error", "This item is not supported because it is a " + type) else: mc.ShowDialogOk("Playlist format error", '"' + type + '"' + " is not a valid type.") return 0
def ParsePlaylist(URL='', mediaitem=CMediaItem(), reload=True, view=''): if reload == False: listcontrol = mc.GetWindow(14000).GetList(GetListView()).GetItems() stackitem = mc.GetWindow(14000).GetList(555).GetItem(0) view = stackitem.GetProperty("view") SetListView(view) mc.GetWindow(14000).GetList(GetListView()).SetFocus() mc.GetWindow(14000).GetList(GetListView()).SetItems(listcontrol) #pos = stackitem.GetProperty("focusseditem") #mc.GetWindow(14000).GetList(GetListView()).SetFocusedItem(pos) return if URL != '': mediaitem = CMediaItem() mediaitem.URL = URL mediaitem.type = 'playlist' mc.ShowDialogWait() playlist = CPlayList() type = mediaitem.GetType() ##mc.ShowDialogOk("Debug", "Parse mediaitem of type " + type) listcontrol = mc.GetWindow(14000).GetList(GetListView()).GetItems() del listcontrol[:] #load the playlist if type == 'rss_flickr_daily': result = playlist.load_rss_flickr_daily(URL, mediaitem) elif type[0:3] == 'rss': result = playlist.load_rss_20(URL, mediaitem) elif type[0:4] == 'atom': result = playlist.load_atom_10(URL, mediaitem) elif type == 'opml': result = playlist.load_opml_10(URL, mediaitem) elif type == 'html_youtube': result = playlist.load_html_youtube(URL, mediaitem) elif type == 'xml_shoutcast': result = playlist.load_xml_shoutcast(URL, mediaitem) elif type == 'xml_applemovie': result = playlist.load_xml_applemovie(URL, mediaitem) elif type == 'directory': result = playlist.load_dir(URL, mediaitem) else: #assume playlist file result = playlist.load_plx(URL, mediaitem) ### playlist.save(RootDir + 'source.plx') if result == -1: #error mc.ShowDialogOk("Error", "This playlist requires a newer Navi-X version") elif result == -2: #error mc.ShowDialogOk("Error", "Cannot open file.") if result != 0: #failure return -1 #display the new URL on top of the screen if len(playlist.title) > 0: title = playlist.title # + ' - (' + playlist.URL + ')' else: title = playlist.URL #remove the [COLOR] tags from the title as Boxee doesn't seem to support them #todo: this still strips out >> and following from labels but it's better than nothing reg1 = "(\[.*?\])" title = re.sub(reg1, '', title) stackitem = mc.ListItem() stackitem.SetProperty("URL", mediaitem.URL) stackitem.SetProperty("listtitle", title) stackitem.SetProperty("view", playlist.view) #stackitem.SetProperty("focusseditem", mc.GetWindow(14000).GetList(GetListView()).GetFocusedItem()) #set the background image m = playlist.background if (m == 'default') or (m == 'previous'): #default BG image stackitem.SetProperty("bgimage", imageDir + background_image1) else: stackitem.SetProperty("bgimage", playlist.background) stacklist = mc.ListItems() stacklist.append(stackitem) mc.GetWindow(14000).GetList(555).SetItems(stacklist) today = datetime.date.today() ## CPlayList -> mc.ListItems for i in range(0, playlist.size()): m = playlist.list[i] if int(m.version) <= int(plxVersion): icon, thumb = getPlEntryThumb(m, playlist) # set label2 label2 = '' if m.date != '': l = m.date.split('-') entry_date = datetime.date(int(l[0]), int(l[1]), int(l[2])) days_past = (today - entry_date).days if days_past <= 10: if days_past <= 0: label2 = 'NEW today' elif days_past == 1: label2 = 'NEW yesterday' else: label2 = 'NEW (' + str(days_past) + ' days ago)' if m.description != '': label2 = label2 + ' >' item = mc.ListItem() item.SetLabel(m.name) if m.URL != "": item.SetPath(m.URL + " : " + m.processor) item.SetProperty('label2', label2) item.SetProperty('description', m.description) item.SetProperty('background', m.background) item.SetProperty('processor', m.processor) item.SetProperty('thumb', m.thumb) item.SetProperty('url', m.URL) item.SetProperty('rating', imageDir + "rating" + m.rating + ".png") item.SetProperty('media_type', m.type) if (m.thumb != 'default'): item.SetThumbnail(m.thumb) elif playlist.logo != 'none': item.SetThumbnail(playlist.logo) else: item.SetThumbnail(thumb) item.SetProperty('icon', icon) ##mc.ShowDialogOk("item", "Label = " + item.GetLabel() + "Icon = " + item.GetIcon() + "Thumb = " + item.GetThumbnail() ) listcontrol.append(item) if view != '': playlist.view = view newview = SetListView(playlist.view, passive=True) mc.GetWindow(14000).GetList(newview).SetItems( listcontrol) #set displayed list SetListView(playlist.view, passive=False) mc.GetWindow(14000).GetList(newview).SetFocus() mc.HideDialogWait() return 0
def show_message(): mc.ShowDialogOk("MSG", 'Starting?')
# (at your option) any later version. # # PseudoTV is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with PseudoTV. If not, see <http://www.gnu.org/licenses/>. import mc import xbmc # Script constants #__scriptname__ = "PseudoTV" #__author__ = "Jason102" #__url__ = "http://github.com/Jasonra/XBMC-PseudoTV" #__settings__ = xbmcaddon.Addon(id='script.pseudotv') #__cwd__ = __settings__.getAddonInfo('path') # ENTRY POINT ################################################################## if ( __name__ == "__main__" ): app = mc.GetApp() config = app.GetLocalConfig() if xbmc.executehttpapi("GetVolume") == "False": mc.ShowDialogOk("Warning", "PseudoTV will run more efficiently with the Boxee web[CR]server enabled. Consider turning this on in the network settings.") mc.ActivateWindow(14000)