def OnSearchEverywhere(self): query = mc.ShowDialogKeyboard( mc.GetLocalizedString(137) + " EX.UA", "", False) if 0 != len(query): mc.LogInfo("string to search: %s" % query) pagesDict = self.model.searchAllPagesDict(query) self.UpdatePagesPanelWithSearchResults(query, pagesDict)
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 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 login(self): username = mc.ShowDialogKeyboard("User name", "", False) if len(username) == 0: return -2 password = mc.ShowDialogKeyboard("Password", "", True) if len(password) == 0: return -2 #login to the Navi-X server self.user_id = self.nxLogin(username, password) if self.user_id == '': #failed return -1 print "Login to the NXServer was successful" #save the returned user ID self.save_user_id() #success return 0
def search(self): setMain() result = mc.ShowDialogKeyboard(__language__(1000), "", False) if len(result) > 0: try: self._search = Search(self, defaultCoverArt=self.defaultCoverArt) self._search.search(self.gs, result) self.start() self.searchshow() except: self.notification('Sorry') traceback.print_exc()
def OnSearchInActiveSection(self): if self.GetNavSearchContext(): query = mc.ShowDialogKeyboard( mc.GetLocalizedString(137) + " " + mc.GetLocalizedString(1405) + " " + self.GetNavSectionName(), "", False) if 0 != len(query): pagesDict = self.model.searchInSectionPagesDict( self.GetNavSearchContext(), query) self.UpdatePagesPanelWithSearchResults(query, pagesDict) else: mc.LogInfo( "No search context present - unable to perform search in active section" )
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 getInput(self, title, default="", hidden=False): response = mc.ShowDialogKeyboard(str(title), str(default), hidden) if response != '': return response else: return None
def doAction(action, label, title = "", subtitle = ""): # show loading dialog mc.ShowDialogWait() # get cookies and set them action = action.split("/") print action # push state for back button but not when on the index if action[2] != "index": mc.GetWindow(14000).PushState() if action[2] == "zoek": # get search query query = mc.ShowDialogKeyboard("Zoekterm:", "", False) subtitle = query # make url for search url = ZOEK_URI +query.replace(" ","%20") data = uzgf.GetCached(url).decode('latin-1') data = data.replace("<span class=\"highlight\">", "").replace("</span>", "") # create and fill the list with items from Shows list = mc.GetWindow(14000).GetList(51) list_items = mc.ListItems() result = re.compile(REGEX_PAGE_PAGES, re.DOTALL + re.IGNORECASE).findall(data) # more pages? if len(result) > 0: for e in result: url2 = url + '&pgNum=' + str(e[0]) list_items = Shows(list_items, uzgf.GetCached(url2).decode('latin-1'), REGEX_SEARCH_ITEM, "Zoeken", subtitle) else: list_items = Shows(list_items, data, REGEX_SEARCH_ITEM, "Zoeken", subtitle) try: list.SetItems(list_items) except: # no results? list_items = mc.ListItems() list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) # set everything in the list item list_item.SetLabel("Geen resultaten") list_item.SetDescription("Probeer een andere (langere) zoekterm") # set the path for doAction list_item.SetPath("feed://zoek/") list_item.SetThumbnail("") # add the item to the list items container list_item.SetProperty("title", "Zoeken") list_item.SetProperty("subtitle", subtitle) list_items.append(list_item) list.SetItems(list_items) if action[2] == "dag": # create url for day url = DAY_URI +action[3] data = uzgf.GetCached(url, 600).decode('latin-1') data = data.replace("<span class=\"highlight\">", "").replace("</span>", "") # create and fill the list with items from Shows list = mc.GetWindow(14000).GetList(51) list_items = mc.ListItems() result = re.compile(REGEX_PAGE_PAGES, re.DOTALL + re.IGNORECASE).findall(data) # more pages? if len(result) > 0: for e in result: url2 = url + '&pgNum=' + str(e[0]) list_items = Shows(list_items, uzgf.GetCached(url2, 600).decode('latin-1'), REGEX_PAGE_ITEM, label, "") else: list_items = Shows(list_items, data, REGEX_PAGE_ITEM, label, "") list.SetItems(list_items) if action[2] == "zender": # create url for zender url = ZENDER_URI +action[3] data = uzgf.GetCached(url, 3600).decode('latin-1') data = data.replace("<span class=\"highlight\">", "").replace("</span>", "") # create and fill the list with items from Shows list = mc.GetWindow(14000).GetList(51) list_items = mc.ListItems() result = re.compile(REGEX_PAGE_PAGES, re.DOTALL + re.IGNORECASE).findall(data) # more pages? if len(result) > 0: for e in result: url2 = url + '&pgNum=' + str(e[0]) list_items = Shows(list_items, uzgf.GetCached(url2, 3600).decode('latin-1'), REGEX_PAGE_ITEM, title, label) else: list_items = Shows(list_items, data, REGEX_PAGE_ITEM, title, subtitle) list.SetItems(list_items) if action[2] == "shows": # create url for show url = ROOT_URI + "index.php/serie" + base64.b64decode(action[3]) data = uzgf.GetCached(url, 600).decode('latin-1') print data.encode('utf-8') results = re.compile(REGEX_PAGE_ITEM2, re.DOTALL + re.IGNORECASE + re.M).findall(data) if len(results) < 1: data = uzgf.GetCached(ROOT_URI, 1) time.sleep(2) data = uzgf.GetCached(url, 1).decode('latin-1') # create and fill the list with items from ShowItems list = mc.GetWindow(14000).GetList(51) list_items = mc.ListItems() list_items = ShowItems(list_items, data, REGEX_PAGE_ITEM2, subtitle, label) list.SetItems(list_items) if action[2] == "play": # we don't want to render the index again when we get back from playing the video config.SetValue("wantindex", "no") # we got an item to play. lets call getStreamUrl to get the url and send it to the player url = getStreamUrl(action[3]) player = mc.GetPlayer() # make a list item for the player list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_EPISODE) # set url list_item.SetPath(str(url)) # report to server list_item.SetReportToServer(True) # set label list_item.SetLabel(str(label)) # we want to add it to our history list_item.SetAddToHistory(True) # set title from label_2 list_item.SetTVShowTitle(str(config.GetValue("label_2"))) # set description from xml feed list_item.SetDescription("Video from Uitzending Gemist (dutch)") # and play it player.Play(list_item) if action[2] == "zenders": # we should set some labels config.SetValue("label_1", "Kies een zender") config.SetValue("label_2", "") list = mc.GetWindow(14000).GetList(51) list_items = mc.ListItems() list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) # set everything in the list item list_item.SetLabel("Nederland 1") list_item.SetDescription("Bekijk programma's van Nederland 1") # set the path for doAction list_item.SetPath("feed://zender/1") list_item.SetThumbnail("http://www.bartsidee.nl/boxee/apps/uzg/thumbs/ned1.png") list_item.SetProperty("title", "Zenders") list_item.SetProperty("subtitle", "Kies een zender") # add the item to the list items container list_items.append(list_item) list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) # set everything in the list item list_item.SetLabel("Nederland 2") list_item.SetDescription("Bekijk programma's van Nederland 2") # set the path for doAction list_item.SetPath("feed://zender/2") list_item.SetThumbnail("http://www.bartsidee.nl/boxee/apps/uzg/thumbs/ned2.png") list_item.SetProperty("title", "Zenders") list_item.SetProperty("subtitle", "Kies een zender") # add the item to the list items container list_items.append(list_item) list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) # set everything in the list item list_item.SetLabel("Nederland 3") list_item.SetDescription("Bekijk programma's van Nederland 3") # set the path for doAction list_item.SetPath("feed://zender/3") list_item.SetThumbnail("http://www.bartsidee.nl/boxee/apps/uzg/thumbs/ned3.png") list_item.SetProperty("title", "Zenders") list_item.SetProperty("subtitle", "Kies een zender") # add the item to the list items container list_items.append(list_item) # add all the items to the list control list.SetItems(list_items) if action[2] == "index": list = mc.GetWindow(14000).GetList(51) list_items = mc.ListItems() list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) # set everything in the list item list_item.SetLabel("Zenders") list_item.SetDescription("Bekijk per zender") # set the path for doAction list_item.SetPath("feed://zenders/") list_item.SetProperty("title", "Uitzending Gemist") list_item.SetProperty("subtitle", "Maak je keuze") list_item.SetThumbnail("ned1.png") # add the item to the list items container list_items.append(list_item) list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) # set everything in the list item list_item.SetLabel("Vandaag") list_item.SetDescription("Bekijk programma's van vandaag") # set the path for doAction list_item.SetPath("feed://dag/vandaag") list_item.SetThumbnail("") # add the item to the list items container list_item.SetProperty("title", "Uitzending Gemist") list_item.SetProperty("subtitle", "Maak je keuze") list_items.append(list_item) list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) # set everything in the list item list_item.SetLabel("Gisteren") list_item.SetDescription("Bekijk programma's van gisteren") # set the path for doAction list_item.SetPath("feed://dag/gisteren") list_item.SetThumbnail("") # add the item to the list items container list_item.SetProperty("title", "Uitzending Gemist") list_item.SetProperty("subtitle", "Maak je keuze") list_items.append(list_item) list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP) # set everything in the list item list_item.SetLabel("Zoeken") list_item.SetDescription("Zoek naar programma's") # set the path for doAction list_item.SetPath("feed://zoek/") list_item.SetThumbnail("") # add the item to the list items container list_item.SetProperty("title", "Uitzending Gemist") list_item.SetProperty("subtitle", "Maak je keuze") list_items.append(list_item) list.SetItems(list_items) # we should be done! hide the wait dialog mc.HideDialogWait()
import mc import dreamboxee config = mc.GetApp().GetLocalConfig() ipaddress = config.GetValue("ipaddress") if ipaddress: mc.ShowDialogNotification("IP address is: " + ipaddress) else: ipaddress = mc.ShowDialogKeyboard("Dreambox IP", "", False) config.SetValue("ipaddress", ipaddress) mc.ActivateWindow(14000)
def PlaylistSearch(item): string = '' searchstring = mc.ShowDialogKeyboard("Search", "", False) if len(searchstring) == 0: return None #get the search type: index = item.type.find(":") if index != -1: search_type = item.type[index + 1:] else: search_type = '' #youtube search if (item.type == 'search_youtube') or (search_type == 'html_youtube'): fn = searchstring.replace(' ', '+') if item.URL != '': URL = item.URL else: URL = 'http://gdata.youtube.com/feeds/base/videos?max-results=50&alt=rss&q=' URL = URL + fn choice = 0 ## no easy way to do a Select Dialog in Boxee API ## youtube search always by Relevance #validate the selected item if choice == 1: #Date Added URL = URL + '&search_sort=video_date_uploaded' elif choice == 2: #View Count URL = URL + '&search_sort=video_view_count' elif choice == 3: #Rating URL = URL + '&search_sort=video_avg_rating' mediaitem = CMediaItem() mediaitem.URL = URL mediaitem.type = 'rss:video' mediaitem.name = 'search results: ' + searchstring mediaitem.player = item.player mediaitem.processor = item.processor return mediaitem elif (item.type == 'search_shoutcast') or (search_type == 'xml_shoutcast'): fn = urllib.quote(searchstring) URL = 'http://www.shoutcast.com/sbin/newxml.phtml?search=' URL = URL + fn mediaitem = CMediaItem() mediaitem.URL = URL mediaitem.type = 'xml_shoutcast' mediaitem.name = 'search results: ' + searchstring mediaitem.player = item.player mediaitem.processor = item.processor return mediaitem ############ Haven't tested search_flickr yet elif (item.type == 'search_flickr') or (search_type == 'html_flickr'): fn = searchstring.replace(' ', '+') URL = 'http://www.flickr.com/search/?q=' URL = URL + fn mediaitem = CMediaItem() mediaitem.URL = URL mediaitem.type = 'html_flickr' mediaitem.name = 'search results: ' + searchstring mediaitem.player = item.player mediaitem.processor = item.processor return mediaitem else: #generic search fn = urllib.quote(searchstring) URL = item.URL URL = URL + fn mediaitem = CMediaItem() mediaitem.URL = URL if search_type != '': mediaitem.type = search_type else: #default mediaitem.type = 'playlist' mediaitem.name = 'search results: ' + searchstring mediaitem.player = item.player mediaitem.processor = item.processor return mediaitem