diff --git a/platformcode/globalsearch.py b/platformcode/globalsearch.py index 44c5d968..45e68d0a 100644 --- a/platformcode/globalsearch.py +++ b/platformcode/globalsearch.py @@ -26,7 +26,7 @@ def set_workers(): def Search(item): xbmc.executebuiltin('Dialog.Close(all,true)') SearchWindow('GlobalSearch.xml', config.get_runtime_path()).start(item) - xbmc.sleep(600) + xbmc.sleep(700) # Actions LEFT = 1 @@ -52,8 +52,9 @@ RESULTS = 102 PROGRESS = 500 COUNT = 501 -CLOSE = 502 +MENU = 502 BACK = 503 +CLOSE = 504 # Servers EPISODESLIST = 200 @@ -375,25 +376,7 @@ class SearchWindow(xbmcgui.WindowXML): action = action.getId() focus = self.getFocusId() if action in [CONTEXT] and focus in [RESULTS]: - pos = self.RESULTS.getSelectedPosition() - name = self.CHANNELS.getSelectedItem().getLabel() - item = self.results[name][0][pos] - context = [config.get_localized_string(70739), config.get_localized_string(70557), config.get_localized_string(60359)] - context_commands = ["RunPlugin(%s?%s)" % (sys.argv[0], 'action=open_browser&url=' + item.url), - "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=kodfavorites&action=addFavourite&from_channel=' + item.channel + '&from_action=' + item.action), - "RunPlugin(%s?%s)" % (sys.argv[0], 'channel=trailertools&action=buscartrailer&contextual=True&search_title=' + item.contentTitle if item.contentTitle else item.fulltitle)] - if item.contentType == 'movie': - context += [config.get_localized_string(60353), config.get_localized_string(60354)] - context_commands += ["RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'action=add_pelicula_to_library&from_action=' + item.action), - "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' +item.action)] - - else: - context += [config.get_localized_string(60352), config.get_localized_string(60355), config.get_localized_string(60357)] - context_commands += ["RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'action=add_serie_to_library&from_action=' + item.action), - "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action), - "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel +'&from_action=' + item.action)] - index = xbmcgui.Dialog().contextmenu(context) - if index > 0: xbmc.executebuiltin(context_commands[index]) + self.context() elif action in [SWIPEUP]: self.setFocusId(CHANNELS) @@ -410,9 +393,9 @@ class SearchWindow(xbmcgui.WindowXML): self.RESULTS.addItems(items) self.RESULTS.selectItem(subpos) - elif action in [DOWN] and focus in [BACK, CLOSE]: - if self.EPISODES.isVisible(): self.setFocusId(EPISODES) - if self.SERVERS.isVisible(): self.setFocusId(SERVERS) + elif action in [DOWN] and focus in [BACK, CLOSE, MENU]: + if self.SERVERS.isVisible(): self.setFocusId(SERVERLIST) + if self.EPISODES.isVisible(): self.setFocusId(EPISODESLIST) else: self.setFocusId(RESULTS) elif focus in [RESULTS] and self.item.mode == 'all': @@ -446,6 +429,9 @@ class SearchWindow(xbmcgui.WindowXML): elif control_id in [CLOSE]: self.Close() + elif control_id in [MENU]: + self.context() + elif search: pos = self.RESULTS.getSelectedPosition() if search == 'next': @@ -475,8 +461,14 @@ class SearchWindow(xbmcgui.WindowXML): self.pos = self.EPISODESLIST.getSelectedPosition() item = self.episodes[self.pos] # dbg() - self.channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel]) - self.itemsResult = getattr(self.channel, item.action)(item) + try: + self.channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel]) + self.itemsResult = getattr(self.channel, item.action)(item) + except: + import traceback + logger.error('error importing/getting search items of ' + item.channel) + logger.error(traceback.format_exc()) + self.itemsResult = [] if self.itemsResult and self.itemsResult[0].action in ['play']: @@ -554,6 +546,7 @@ class SearchWindow(xbmcgui.WindowXML): self.setFocusId(RESULTS) self.RESULTS.selectItem(self.pos) elif self.EPISODES.isVisible(): + self.episodes = [] self.Focus(SEARCH) self.setFocusId(RESULTS) self.RESULTS.selectItem(self.pos) @@ -569,4 +562,25 @@ class SearchWindow(xbmcgui.WindowXML): busy(True) while self.thread.is_alive(): xbmc.sleep(200) busy(False) - self.close() \ No newline at end of file + self.close() + + def context(self): + pos = self.RESULTS.getSelectedPosition() + name = self.CHANNELS.getSelectedItem().getLabel() + item = self.results[name][0][pos] + context = [config.get_localized_string(70739), config.get_localized_string(70557), config.get_localized_string(60359)] + context_commands = ["RunPlugin(%s?%s)" % (sys.argv[0], 'action=open_browser&url=' + item.url), + "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=kodfavorites&action=addFavourite&from_channel=' + item.channel + '&from_action=' + item.action), + "RunPlugin(%s?%s)" % (sys.argv[0], 'channel=trailertools&action=buscartrailer&contextual=True&search_title=' + item.contentTitle if item.contentTitle else item.fulltitle)] + if item.contentType == 'movie': + context += [config.get_localized_string(60353), config.get_localized_string(60354)] + context_commands += ["RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'action=add_pelicula_to_library&from_action=' + item.action), + "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' +item.action)] + + else: + context += [config.get_localized_string(60352), config.get_localized_string(60355), config.get_localized_string(60357)] + context_commands += ["RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'action=add_serie_to_library&from_action=' + item.action), + "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action), + "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel +'&from_action=' + item.action)] + index = xbmcgui.Dialog().contextmenu(context) + if index > 0: xbmc.executebuiltin(context_commands[index]) \ No newline at end of file diff --git a/resources/skins/Default/720p/GlobalSearch.xml b/resources/skins/Default/720p/GlobalSearch.xml index 3003afc6..5d4a783b 100644 --- a/resources/skins/Default/720p/GlobalSearch.xml +++ b/resources/skins/Default/720p/GlobalSearch.xml @@ -99,7 +99,7 @@ 100% 570 101 - 503 + 502 horizontal 300 @@ -302,8 +302,8 @@ 520 700 570 - 503 - 503 + 502 + 502 300 @@ -376,8 +376,8 @@ 520 700 570 - 503 - 503 + 502 + 502 300 @@ -492,7 +492,7 @@ 00000000 right center - Conditional + Conditional Control.IsVisible(500) @@ -526,6 +526,19 @@ Control.IsVisible(5) + + Menu + 30 + 110 + 40 + 40 + 504 + 503 + menu.png + menu.png + Integer.IsGreater(Container(101).NumItems, 0) + + Back 30 @@ -533,19 +546,19 @@ 40 40 502 - 502 + 504 left.png left.png - + Close 30 30 40 40 503 - 503 + 502 close.png close.png diff --git a/resources/skins/Default/media/menu.png b/resources/skins/Default/media/menu.png new file mode 100644 index 00000000..eac13daf Binary files /dev/null and b/resources/skins/Default/media/menu.png differ