diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 4d950d4b..fe0ca7be 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -135,6 +135,11 @@ def run(item=None): from platformcode import infoplus return infoplus.Main(item) + # elif item.channel == "search" and item.action == 'new_search': + # from specials import search + # item.mode = 'all' + # return search.new_search(item) + elif item.channel == "backup": from platformcode import backup return getattr(backup, item.action)(item) diff --git a/resources/settings.xml b/resources/settings.xml index 6edd64e5..86b9d346 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -81,6 +81,7 @@ + diff --git a/resources/skins/Default/720p/GlobalSearch.xml b/resources/skins/Default/720p/GlobalSearch.xml new file mode 100644 index 00000000..3f7630c7 --- /dev/null +++ b/resources/skins/Default/720p/GlobalSearch.xml @@ -0,0 +1,373 @@ + + + + + + + + + + + 0 + 0 + 100% + 100% + white.png + white.png + WindowOpen + WindowClose + Action(close) + + + + 0 + 0 + + + + + + + + + + + 355 + 490 + 300 + 10 + white.png + !Integer.IsGreater(Container(102).NumItems, 0) + Conditional + + + + 100% + 100% + center + $INFO[Container(103).ListItem.Property(fanart)] + + + + + Control.IsVisible(1) + + + 30 + 30 + 1000 + 30 + font30_title + FFFFFFFF + 00000000 + Integer.IsGreater(Container(102).NumItems, 0) + left + center + + + + Integer.IsGreater(Container(102).NumItems, 0) + Visible + + + 400 + 90 + 840 + 30 + font30_title + FFFFFFFF + 00000000 + + left + center + + + + 400 + 150 + 840 + 170 + font13 + FFFFFFFF + 00000000 + + left + + + 70 + 0 + 100% + 570 + 102 + horizontal + 300 + + + + 0 + 0 + 180 + 270 + $INFO[ListItem.Property(thumb)] + 10 + scale + + + + + + 0 + 0 + 380 + 570 + $INFO[ListItem.Property(thumb)] + 10 + scale + + + + + + + + -100 + 100% + 150 + Conditional + Conditional + + 100% + 100% + Conditional + white.png + + + 100% + 100% + white.png + + + 100% + 150 + 103 + horizontal + 300 + + + + 0 + 0 + 150 + 150 + $INFO[ListItem.Property(thumb)] + scale + + + + 0 + 0 + 40 + 40 + white.png + scale + + + + 5 + 5 + 30 + 30 + font30_title + 22FFFFFF + 00000000 + + center + center + + + + + + 0 + 0 + 150 + 150 + $INFO[ListItem.Property(thumb)] + scale + + + + 0 + 0 + 40 + 40 + white.png + scale + + + + 5 + 5 + 30 + 30 + font30_title + FFFFFFFF + 00000000 + + center + center + + + + + + + + 0 + -10 + 1330 + 7 + false + white.png + white.png + progress.png + progress.png + Integer.IsGreater(Container(102).NumItems, 0) + + + 30 + 30 + 200 + 40 + font30_title + FFFFFFFF + 00000000 + right + center + Integer.IsGreater(Container(102).NumItems, 0) + + + + + + Control.IsVisible(2) + + + + + Control.IsVisible(3) + + Poster + 0 + 0 + 480 + 720 + $INFO[Container(103).ListItem.Property(thumb)] + + + Title + 520 + 40 + 1150 + 30 + font30_title + FFFFFFFF + 00000000 + left + center + + + + + + 40 + 520 + 700 + 570 + + 300 + + + + 5 + 5 + 120 + 120 + $INFO[ListItem.Property(thumb)] + scale + + + 35 + 150 + 60 + 60 + $INFO[ListItem.Property(quality)] + scale + + + Title + 220 + 35 + 450 + 60 + font30_title + FFFFFFFF + 00000000 + left + center + + + + + + 700 + 130 + white.png + scale + + + + 0 + 0 + 130 + 130 + Control.HasFocus(300) + white.png + scale + + + 5 + 5 + 120 + 120 + $INFO[ListItem.Property(thumb)] + scale + + + 35 + 150 + 60 + 60 + $INFO[ListItem.Property(quality)] + scale + + + Title + 220 + 35 + 450 + 60 + font30_title + FFFFFFFF + 00000000 + left + center + + + + + + + + + diff --git a/resources/skins/Default/media/fhd.png b/resources/skins/Default/media/fhd.png new file mode 100644 index 00000000..c3b4d3f5 Binary files /dev/null and b/resources/skins/Default/media/fhd.png differ diff --git a/resources/skins/Default/media/hd.png b/resources/skins/Default/media/hd.png new file mode 100644 index 00000000..b14a6eb2 Binary files /dev/null and b/resources/skins/Default/media/hd.png differ diff --git a/resources/skins/Default/media/progress.png b/resources/skins/Default/media/progress.png new file mode 100644 index 00000000..433a70ad Binary files /dev/null and b/resources/skins/Default/media/progress.png differ diff --git a/resources/skins/Default/media/sd.png b/resources/skins/Default/media/sd.png new file mode 100644 index 00000000..d381dfbe Binary files /dev/null and b/resources/skins/Default/media/sd.png differ diff --git a/resources/skins/Default/media/uhd.png b/resources/skins/Default/media/uhd.png new file mode 100644 index 00000000..399ae8e8 Binary files /dev/null and b/resources/skins/Default/media/uhd.png differ diff --git a/resources/skins/Default/media/white.png b/resources/skins/Default/media/white.png index 528c66f6..fe67a33a 100644 Binary files a/resources/skins/Default/media/white.png and b/resources/skins/Default/media/white.png differ diff --git a/specials/search.py b/specials/search.py index 5ea500e2..b34cc5e2 100644 --- a/specials/search.py +++ b/specials/search.py @@ -18,12 +18,17 @@ if PY3: else: from concurrent_py2 import futures from core.item import Item -from core import tmdb, scrapertools, channeltools, filetools, jsontools +from core import tmdb, scrapertools, channeltools, filetools, jsontools, servertools from channelselector import get_thumb from platformcode import logger, config, platformtools, unify from core.support import typo +import xbmcgui import gc + +import xbmc +from threading import Thread +from core.support import dbg gc.disable() info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json @@ -191,6 +196,8 @@ def channel_search(item): return itemlist else: filetools.remove(temp_search_file) + if config.get_setting('new_search'): + return Search(item) searched_id = item.infoLabels['tmdb_id'] @@ -199,10 +206,8 @@ def channel_search(item): searching += channel_list searching_titles += channel_titles cnt = 0 - progress = platformtools.dialog_progress(config.get_localized_string(30993) % item.title, config.get_localized_string(70744) % len(channel_list) + '\n' + ', '.join(searching_titles)) config.set_setting('tmdb_active', False) - search_action_list = [] module_dict = {} for ch in channel_list: @@ -810,4 +815,276 @@ def get_saved_searches(): else: saved_searches_list = list(current_saved_searches_list) - return saved_searches_list \ No newline at end of file + return saved_searches_list + + +SearchWindows = [] + +def Search(item): + # if SearchWindows: + # SearchWindows[-1].doModal() + # SearchWindows[:-1] + # item.text = 'matrix' + SearchWindow('GlobalSearch.xml', config.get_runtime_path()).start(item) + +# Actions +LEFT = 1 +RIGHT = 2 +UP = 3 +DOWN = 4 +EXIT = 10 +BACKSPACE = 92 + +# Container +SEARCH = 1 +EPISODES = 2 +SERVERS = 3 + +# Search +PROGRESS = 100 +MAINTITLE = 101 +CHANNELS = 102 +RESULTS = 103 +COUNT = 104 + +# Servers +SERVERLIST = 300 +# UHDIMG = 301 +# FHDIMG = 302 +# HDIMG = 303 +# SDIMG = 304 +# UHD = 305 +# FHD = 306 +# HD = 307 +# SD = 308 + +class SearchWindow(xbmcgui.WindowXMLDialog): + def start(self, item): + self.exit = False + self.item = item + self.channels = [] + self.results = {} + self.channelsList, self.channelsTitle = get_channels(item) + self.focus = SEARCH + self.doModal() + + def getModule(self, channel): + try: + module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel]) + mainlist = getattr(module, 'mainlist')(Item(channel=channel, global_search=True)) + action = [elem for elem in mainlist if elem.action == "search" and (self.item.mode == 'all' or elem.contentType in [self.item.mode, 'undefined'])] + return module, action + except: + import traceback + logger.error('error importing/getting search items of ' + channel) + logger.error(traceback.format_exc()) + + def onInit(self): + self.CHANNELS = self.getControl(CHANNELS) + self.RESULTS = self.getControl(RESULTS) + self.PROGRESS = self.getControl(PROGRESS) + self.COUNT = self.getControl(COUNT) + self.MAINTITLE = self.getControl(MAINTITLE) + self.MAINTITLE.setText(typo(config.get_localized_string(30993).replace('...','') % '"%s"' % self.item.text, 'bold')) + self.SEARCH = self.getControl(SEARCH) + self.EPISODES = self.getControl(EPISODES) + self.SERVERS = self.getControl(SERVERS) + self.SERVERLIST = self.getControl(SERVERLIST) + + self.moduleDict = {} + self.searchActions = [] + + self.Focus(self.focus) + + if not self.channels: + with futures.ThreadPoolExecutor() as executor: + for channel in self.channelsList: + if self.exit: break + module, action = executor.submit(self.getModule, channel).result() + self.moduleDict[channel] = module + self.searchActions += action + + self.executor = futures.ThreadPoolExecutor() + self.thread = Thread(target=self.search) + self.thread.start() + + def search(self): + for i, searchAction in enumerate(self.searchActions): + if self.exit: break + self.update(i, searchAction.channel, self.executor.submit(get_channel_results, self.item, self.moduleDict, searchAction).result()) + + def Focus(self, focusid): + if focusid in [SEARCH]: + self.focus = CHANNELS + self.SEARCH.setVisible(True) + self.EPISODES.setVisible(False) + self.SERVERS.setVisible(False) + if focusid in [EPISODES]: + self.focus = focusid + self.SEARCH.setVisible(False) + self.EPISODES.setVisible(True) + self.SERVERS.setVisible(False) + if focusid in [SERVERS]: + self.focus = SERVERLIST + self.SEARCH.setVisible(False) + self.EPISODES.setVisible(False) + self.SERVERS.setVisible(True) + + def update(self, i, channel, result): + if result[1]: + channelParams = channeltools.get_channel_parameters(channel) + name = channelParams['title'] + if name not in self.results: + self.results[name] = [result[1], len(self.channels)] + item = xbmcgui.ListItem(name) + item.setProperty('thumb', channelParams['thumbnail']) + item.setProperty('position', '0') + item.setProperty('results', str(len(self.results[name][0]))) + self.channels.append(item) + else: + self.results[name].append([result[1], len(self.channels)]) + self.channels[int(self.results[name][1])].setProperty('results', str(len(self.results[name][0]))) + pos = self.CHANNELS.getSelectedPosition() + self.CHANNELS.reset() + self.CHANNELS.addItems(self.channels) + self.CHANNELS.selectItem(pos) + if len(self.channels) == 1: + self.setFocusId(CHANNELS) + items = [] + for result in self.results[name][0]: + item = xbmcgui.ListItem(result.title) + item.setProperty('thumb', result.thumbnail) + item.setProperty('fanart', result.fanart) + item.setProperty('plot', result.plot) + items.append(item) + self.RESULTS.addItems(items) + percent = (i + 1) / len(self.searchActions) * 100 + self.PROGRESS.setPercent(percent) + self.COUNT.setText("%s/%s" %(i + 1, len(self.searchActions))) + + def onAction(self, action): + action = action.getId() + focus = self.getFocusId() + if action in [LEFT, RIGHT] and focus in [CHANNELS]: + items = [] + name = self.CHANNELS.getSelectedItem().getLabel() + subpos = int(self.CHANNELS.getSelectedItem().getProperty('position')) + for result in self.results[name][0]: + logger.info(result) + item = xbmcgui.ListItem(result.title) + item.setProperty('thumb', result.thumbnail) + item.setProperty('fanart', result.fanart) + item.setProperty('plot', result.plot) + items.append(item) + self.RESULTS.reset() + self.RESULTS.addItems(items) + self.RESULTS.selectItem(subpos) + if focus in [RESULTS]: + pos = self.RESULTS.getSelectedPosition() + self.CHANNELS.getSelectedItem().setProperty('position', str(pos)) + + if action in [BACKSPACE]: + if self.SERVERS.isVisible(): + self.Focus(SEARCH) + self.setFocusId(RESULTS) + self.RESULTS.selectItem(self.pos) + else: + self.exit = True + self.close() + + if action in [EXIT]: + self.exit = True + self.close() + + def onClick(self, control_id): + if control_id in [CHANNELS]: + items = [] + name = self.CHANNELS.getSelectedItem().getLabel() + subpos = int(self.CHANNELS.getSelectedItem().getProperty('position')) + for result in self.results[name][0]: + logger.info(result) + item = xbmcgui.ListItem(result.title) + item.setProperty('thumb', result.thumbnail) + item.setProperty('fanart', result.fanart) + item.setProperty('plot', result.plot) + items.append(item) + self.RESULTS.reset() + self.RESULTS.addItems(items) + self.RESULTS.selectItem(subpos) + if control_id in [RESULTS]: + name = self.CHANNELS.getSelectedItem().getLabel() + self.pos = self.RESULTS.getSelectedPosition() + item = self.results[name][0][self.pos] + logger.info('ITEM',item) + channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel]) + self.servers = getattr(channel, item.action)(item) + + if config.get_setting('checklinks') and not config.get_setting('autoplay'): + checklinks_number = config.get_setting('checklinks_number') + self.servers = servertools.check_list_links(self.servers, checklinks_number) + uhd = [] + fhd = [] + hd = [] + sd = [] + unknown = [] + for i, item in enumerate(self.servers): + if item.server: + color = scrapertools.find_single_match(item.alive, r'(FF[^\]]+)') + it = xbmcgui.ListItem(item.infoLabels['title']) + it.setProperty('channel', channeltools.get_channel_parameters(item.channel).get('title','')) + it.setProperty('action', item.action) + it.setProperty('thumb', "https://raw.githubusercontent.com/kodiondemand/media/master/resources/servers/%s.png" % item.server.lower()) + it.setProperty('servername', servertools.get_server_parameters(item.server.lower()).get('name',item.server)) + it.setProperty('server', item.server) + it.setProperty('url', item.url) + # it.setProperty('quality', item.quality) + it.setProperty('color', color if color else 'FF0082C2') + + it.setProperty('index', str(i)) + if item.quality in ['4k', '2160p', '2160', '4k2160p', '4k2160', '4k 2160p', '4k 2160', '2k']: + it.setProperty('quality', 'uhd.png') + uhd.append(it) + elif item.quality in ['fullhd', 'fullhd 1080', 'fullhd 1080p', 'full hd', 'full hd 1080', 'full hd 1080p', 'hd1080', 'hd1080p', 'hd 1080', 'hd 1080p', '1080', '1080p']: + it.setProperty('quality', 'Fhd.png') + fhd.append(it) + elif item.quality in ['hd', 'hd720', 'hd720p', 'hd 720', 'hd 720p', '720', '720p', 'hdtv']: + it.setProperty('quality', 'hd.png') + hd.append(it) + elif item.quality in ['sd', '480p', '480', '360p', '360', '240p', '240']: + it.setProperty('quality', 'sd.png') + sd.append(it) + else: + it.setProperty('quality', '') + unknown.append(it) + + # dbg() + uhd.sort(key=lambda it: it.getProperty('server')) + fhd.sort(key=lambda it: it.getProperty('server')) + hd.sort(key=lambda it: it.getProperty('server')) + sd.sort(key=lambda it: it.getProperty('server')) + unknown.sort(key=lambda it: it.getProperty('server')) + + serverlist = uhd + fhd + hd + sd + unknown + self.Focus(SERVERS) + + self.SERVERLIST.reset() + self.SERVERLIST.addItems(serverlist) + self.setFocusId(SERVERLIST) + if control_id in [SERVERLIST]: + control = self.getControl(control_id).getSelectedItem() + index = int(self.getControl(control_id).getSelectedItem().getProperty('index')) + server = self.servers[index] + # server.player_mode = 3 + self.close() + from platformcode.launcher import run + run(server) + while not platformtools.is_playing(): + pass + + while platformtools.is_playing(): + pass + # dbg() + self.doModal() + + +