def dosearch(plugin, module, classname, text, page=1): xbmcplugin.setPluginCategory(HANDLE, 'Search Result') xbmcplugin.setContent(HANDLE, 'movies') if not text: keyboard = xbmc.Keyboard('', 'Search iPlayer') keyboard.doModal() if keyboard.isConfirmed(): text = keyboard.getText() if not text: return XbmcHelper.search_history_save(text) print("*********************** searching %s" % text) movies = plugin().search(text) if movies is not None: for item in movies['movies']: try: list_item = xbmcgui.ListItem(label=item['label']) list_item.setLabel2(item['realtitle']) list_item.setIconImage('DefaultVideo.png') list_item.setArt({ 'thumb': item['thumb'], }) url = build_url( {'mode': 'movie', 'url': item['id'], 'thumb': item['thumb'], 'title': item['title'], 'module': module, 'class': classname}) is_folder = True xbmcplugin.addDirectoryItem(HANDLE, url, list_item, is_folder) except: print(item) else: return xbmcplugin.endOfDirectory(HANDLE)
def do_global_search(text): xbmcplugin.setPluginCategory(HANDLE, 'Search Result') xbmcplugin.setContent(HANDLE, 'movies') if not text: keyboard = xbmc.Keyboard('', 'Search iPlayer') keyboard.doModal() if keyboard.isConfirmed(): text = keyboard.getText() if not text: return XbmcHelper.search_history_save(text) print("*********************** searching %s" % text) def _search(plugin, module, classname, text): movies = None try: movies = plugin().search(text) except: pass if movies is not None and len(movies.get('movies')) > 0: label = "[COLOR red][B][---- %s : [COLOR yellow]%d found[/COLOR] View All ----][/B][/COLOR]" % ( classname, len(movies['movies'])) sli = xbmcgui.ListItem(label=label) url = build_url({'mode': 'dosearch', 'module': module, 'className': classname, 'url': text}) xbmcplugin.addDirectoryItem(HANDLE, url, sli, isFolder=True) for item in movies['movies'][:5]: try: list_item = xbmcgui.ListItem(label=item['label']) list_item.setLabel2(item['realtitle']) list_item.setIconImage('DefaultVideo.png') list_item.setArt({ 'thumb': item['thumb'], }) url = build_url( {'mode': 'movie', 'url': item['id'], 'thumb': item['thumb'], 'title': item['title'], 'module': module, 'className': classname}) is_folder = True xbmcplugin.addDirectoryItem(HANDLE, url, list_item, is_folder) except: print(item) threads = [] for site in SITES: if site['version'] > KODI_VERSION: continue plugin, module, classname = get_plugin({'className': [site['className']], "module": [site['plugin']]}) process = Thread(target=_search, args=[plugin, module, classname, text]) process.setDaemon(True) process.start() threads.append(process) for process in threads: process.join() xbmcplugin.endOfDirectory(HANDLE)
def searching(): query = json.loads(plugin.args['query'][0]) instance, module, class_name = load_plugin(query) text = query.get('text') xbmcplugin.setPluginCategory(plugin.handle, 'Search / %s' % text) xbmcplugin.setContent(plugin.handle, 'movies') if not text: keyboard = xbmc.Keyboard('', 'Search iPlayer') keyboard.doModal() if keyboard.isConfirmed(): text = keyboard.getText() if not text: return helper.search_history_save(text) movies = instance().search(text) if movies is not None: label = "[COLOR red][B][---- %s : [COLOR yellow]%d found[/COLOR] View All ----][/B][/COLOR]" % ( class_name, len(movies['movies'])) sli = xbmcgui.ListItem(label=label) xbmcplugin.addDirectoryItem(plugin.handle, None, sli, isFolder=False) for item in movies['movies']: try: list_item = xbmcgui.ListItem(label=item['label']) list_item.setLabel2(item['realtitle']) list_item.setArt({ 'thumb': item['thumb'], }) url = plugin.url_for(show_movie, query=json.dumps({ 'movie_item': item, 'cat_name': 'Search', 'module': module, 'className': class_name })) xbmcplugin.addDirectoryItem(plugin.handle, url, list_item, isFolder=True) except: print(item) else: return xbmcplugin.endOfDirectory(plugin.handle)
def dosearch(plugin, module, classname, text, page=1, recall=False): xbmcplugin.setPluginCategory(HANDLE, 'Search Result') xbmcplugin.setContent(HANDLE, 'movies') if not text: keyboard = xbmc.Keyboard('', 'Search iPlayer') keyboard.doModal() if keyboard.isConfirmed(): text = keyboard.getText() if not text: return XbmcHelper.search_history_save(text) print(text) print("*********************** searching {}".format(text)) movies = plugin().search(text) if movies is not None: label = "[COLOR red][B][---- %s : [COLOR yellow]%d found[/COLOR] View All ----][/B][/COLOR]" % ( classname, len(movies['movies'])) sli = xbmcgui.ListItem(label=label) xbmcplugin.addDirectoryItem(HANDLE, None, sli, isFolder=False) for item in movies['movies']: try: list_item = xbmcgui.ListItem(label=item['label']) list_item.setLabel2(item['realtitle']) list_item.setIconImage('DefaultVideo.png') list_item.setArt({ 'thumb': item['thumb'], }) url = build_url({ 'mode': 'movie', 'url': item['id'], 'thumb': item['thumb'], 'title': item['title'], 'module': module, 'className': classname }) is_folder = True xbmcplugin.addDirectoryItem(HANDLE, url, list_item, is_folder) except: print(item) else: return if not recall: xbmcplugin.endOfDirectory(HANDLE)
def dosearch(plugin, module, classname, text, page=1): xbmcplugin.setPluginCategory(HANDLE, 'Search Result') xbmcplugin.setContent(HANDLE, 'movies') if not text: keyboard = xbmc.Keyboard('', 'Search iPlayer') keyboard.doModal() if keyboard.isConfirmed(): text = keyboard.getText() if not text: return XbmcHelper.search_history_save(text) print("*********************** searching %s" % text) movies = plugin().search(text) if movies is not None: for item in movies['movies']: try: list_item = xbmcgui.ListItem(label=item['label']) list_item.setLabel2(item['realtitle']) list_item.setIconImage('DefaultVideo.png') list_item.setArt({ 'thumb': item['thumb'], }) url = build_url({ 'mode': 'movie', 'url': item['id'], 'thumb': item['thumb'], 'title': item['title'], 'module': module, 'className': classname }) is_folder = True xbmcplugin.addDirectoryItem(HANDLE, url, list_item, is_folder) except: print(item) else: return xbmcplugin.endOfDirectory(HANDLE)
def do_global_search(text): xbmcplugin.setPluginCategory(HANDLE, 'Search Result') xbmcplugin.setContent(HANDLE, 'movies') if not text: keyboard = xbmc.Keyboard('', 'Search iPlayer') keyboard.doModal() if keyboard.isConfirmed(): text = keyboard.getText() if not text: return XbmcHelper.search_history_save(text) print("*********************** searching {}".format(text)) progress = { 'percent': 0, 'step': 5, 'counter': 0, 'length': 0, 'dialog': xbmcgui.DialogProgress(), 'results': [] } def _search(site, text, progress): try: plugin, module, classname = get_plugin({ 'className': [site['className']], "module": [site['plugin']] }) progress['dialog'].update( progress['percent'], 'Searching %d/%d sites' % (progress['counter'], progress['length']), "", "Looking on: %s" % classname) progress['results'].append( (module, classname, plugin().search(text))) progress['percent'] += progress['step'] progress['counter'] += 1 progress['dialog'].update( progress['percent'], 'Searching %d/%d sites' % (progress['counter'], progress['length']), "", "Looking on: %s" % classname) except: pass threads = [] for site in SITES: if site['version'] > KODI_VERSION or ('searchable' in site and not site['searchable']): continue progress['length'] += 1 progress['dialog'].create( 'Processing', "Searching %d/%d sites" % (progress['counter'], progress['length'])) progress['step'] = 100 / progress['length'] for site in SITES: if site['version'] > KODI_VERSION or ('searchable' in site and not site['searchable']): continue process = Thread(target=_search, args=[site, text, progress]) process.setDaemon(True) process.start() threads.append(process) for process in threads: process.join() for module, classname, movies in progress['results']: # if movies is not None and len(movies.get('movies')) > 0: label = "[COLOR red][B][---- %s : [COLOR yellow]%d found[/COLOR] View All ----][/B][/COLOR]" % ( classname, len(movies['movies'])) sli = xbmcgui.ListItem(label=label) url = build_url({ 'mode': 'dosearch', 'module': module, 'className': classname, 'url': text }) xbmcplugin.addDirectoryItem(HANDLE, url, sli, isFolder=True) for item in movies['movies'][:5]: try: list_item = xbmcgui.ListItem(label=item['label']) list_item.setLabel2(item['realtitle']) list_item.setIconImage('DefaultVideo.png') list_item.setArt({ 'thumb': item['thumb'], }) url = build_url({ 'mode': 'movie', 'movie_item': json.dumps(item), 'module': module, 'className': classname }) is_folder = True xbmcplugin.addDirectoryItem(HANDLE, url, list_item, is_folder) except: print(item) xbmcplugin.endOfDirectory(HANDLE)
def searching_all(): text = None if not plugin.args: keyboard = xbmc.Keyboard('', 'Search iPlayer') keyboard.doModal() if keyboard.isConfirmed(): text = keyboard.getText() else: text = plugin.args.get('query')[0] if not text: return xbmcplugin.setPluginCategory(plugin.handle, 'Search Result: {}'.format(text)) xbmcplugin.setContent(plugin.handle, 'movies') helper.search_history_save(text) progress = { 'percent': 0, 'step': 5, 'counter': 0, 'length': 0, 'dialog': xbmcgui.DialogProgress(), 'results': [] } def _search(site, text, progress): try: plugin, module, class_name = load_plugin({ 'className': site.get('className'), "module": site.get('plugin') }) progress['dialog'].update( int(progress['percent']), 'Searching on %s totally %d/%d sites' % (class_name, progress['counter'], progress['length'])) progress['results'].append( (module, class_name, plugin().search(text))) progress['percent'] += progress['step'] progress['counter'] += 1 progress['dialog'].update( int(progress['percent']), 'Searching on %s totally %d/%d sites' % (class_name, progress['counter'], progress['length'])) except Exception as inst: print(type(inst)) print(inst.args) print(inst) pass threads = [] sites = SITES for group in sites: if group['version'] > helper.KODI_VERSION or ('searchable' in group and not group['searchable']): continue for site in group['sites']: progress['length'] += 1 progress['dialog'].create( 'Processing', "Searching %d/%d sites" % (progress['counter'], progress['length'])) progress['step'] = 100 / progress['length'] for group in sites: if group['version'] > helper.KODI_VERSION or ('searchable' in group and not group['searchable']): continue for site in group['sites']: if site['version'] > helper.KODI_VERSION or ( 'searchable' in site and not site['searchable']): continue process = Thread(target=_search, args=[site, text, progress]) process.setDaemon(True) process.start() threads.append(process) for process in threads: process.join() for module, class_name, movies in progress['results']: # if movies is not None and len(movies.get('movies')) > 0: label = "[COLOR red][B][---- %s : [COLOR yellow]%d found[/COLOR] View All ----][/B][/COLOR]" % ( class_name, len(movies['movies'])) sli = xbmcgui.ListItem(label=label) url = plugin.url_for(searching, query=json.dumps({ 'module': module, 'className': class_name, 'text': text })) xbmcplugin.addDirectoryItem(plugin.handle, url, sli, isFolder=True) for item in movies['movies'][:5]: try: list_item = xbmcgui.ListItem(label=item['label']) list_item.setLabel2(item['realtitle']) list_item.setArt({ 'thumb': item['thumb'], }) url = plugin.url_for(show_movie, query=json.dumps({ 'movie_item': item, 'cat_name': 'Search', 'module': module, 'className': class_name })) xbmcplugin.addDirectoryItem(plugin.handle, url, list_item, isFolder=True) except: print(item) xbmcplugin.endOfDirectory(plugin.handle)