def resolve_player(player, lister, params): results = [] for command_group in player.commands: if xbmc.abortRequested or not lister.is_active(): return command_group_results = [] for command in command_group: if xbmc.abortRequested or not lister.is_active(): return lang = command.get("language", "en") if not lang in params: continue parameters = params[lang] try: link = apply_parameters(to_unicode(command["link"]), parameters) except: print_exc() continue if link == "movies" and player.media == "movies": video = get_movie_from_library(parameters['imdb']) if video: command_group_results.append(video) elif link == "tvshows" and player.media == "tvshows": video = get_episode_from_library(parameters['id'], parameters['season'], parameters['episode']) if not video: video = get_episode_from_library(parameters['tmdb'], parameters['season'], parameters['episode']) if video: command_group_results.append(video) elif not command.get("steps"): command_group_results.append({ 'label': player.title, 'path': urlencode_path(link), 'action': command.get("action", "PLAY") }) else: steps = [to_unicode(step) for step in command["steps"]] files, dirs = lister.get(link, steps, parameters) if command.get("action", "PLAY") == "ACTIVATE": files += dirs if files: command_group_results += [{ 'label': f['label'], 'path': player.postprocess(f['path']), 'action': command.get("action", "PLAY") } for f in files] if command_group_results: break results += command_group_results if results: return player.title, results
def resolve_player(player, lister, params): results = [] for command_group in player.commands: if xbmc.abortRequested or not lister.is_active(): return command_group_results = [] for command in command_group: if xbmc.abortRequested or not lister.is_active(): return lang = command.get("language", "en") if not lang in params: continue parameters = params[lang] try: link = apply_parameters(to_unicode(command["link"]), parameters) except: print_exc() continue if link == "movies" and player.media == "movies": video = get_movie_from_library(parameters["imdb"]) if video: command_group_results.append(video) elif link == "tvshows" and player.media == "tvshows": video = get_episode_from_library(parameters["id"], parameters["season"], parameters["episode"]) if not video: video = get_episode_from_library(parameters["tmdb"], parameters["season"], parameters["episode"]) if video: command_group_results.append(video) elif not command.get("steps"): command_group_results.append( {"label": player.title, "path": urlencode_path(link), "action": command.get("action", "PLAY")} ) else: steps = [to_unicode(step) for step in command["steps"]] files, dirs = lister.get(link, steps, parameters) if command.get("action", "PLAY") == "ACTIVATE": files += dirs if files: command_group_results += [ { "label": f["label"], "path": player.postprocess(f["path"]), "action": command.get("action", "PLAY"), } for f in files ] if command_group_results: break results += command_group_results if results: return player.title, results
def list_dir(path): path = urlencode_path(path) try: response = RPC.files.get_directory(media="files", directory=path, properties=["season","episode"]) except: plugin.log.error(path) raise dirs = [] files = [] for item in response.get('files', []): if item.has_key('file') and item.has_key('filetype') and item.has_key('label'): if item['filetype'] == 'directory': # ignore .xsp and .xml directories for ext in (".xsp", ".xml"): if item['file'].endswith(ext) or item['file'].endswith(ext+"/"): continue dirs.append({'path':item['file'], 'label':item['label'], 'season': item.get('season')}) else: files.append({'path':item['file'], 'label':item['label'], 'season': item.get('season'), 'episode': item.get('episode')}) return [path,dirs,files]
def list_dir(path): path = urlencode_path(path) try: response = RPC.files.get_directory(media="files", directory=path, properties=["season", "episode"]) except: plugin.log.error(path) raise dirs = [] files = [] for item in response.get('files', []): if item.has_key('file') and item.has_key('filetype') and item.has_key( 'label'): if item['filetype'] == 'directory': # ignore .xsp and .xml directories for ext in (".xsp", ".xml"): if item['file'].endswith(ext) or item['file'].endswith( ext + "/"): continue dirs.append({ 'path': item['file'], 'label': item['label'], 'season': item.get('season') }) else: files.append({ 'path': item['file'], 'label': item['label'], 'season': item.get('season'), 'episode': item.get('episode') }) return [path, dirs, files]
def resolve_player(player, lister, params): results = [] for command_group in player.commands: if xbmc.abortRequested or not lister.is_active(): return command_group_results = [] for command in command_group: if xbmc.abortRequested or not lister.is_active(): return lang = command.get("language", "en") if not lang in params: continue parameters = params[lang] try: link = to_unicode(command["link"]).format(**parameters) except: print_exc() continue if link == "movies" and player.media == "movies": video = get_movie_from_library(parameters['imdb']) if video: command_group_results.append(video) elif link == "tvshows" and player.media == "tvshows": video = get_episode_from_library(parameters['id'], parameters['season'], parameters['episode']) if not video: video = get_episode_from_library(parameters['tmdb'], parameters['season'], parameters['episode']) if video: command_group_results.append(video) elif not command.get("steps"): command_group_results.append( { 'label': player.title, 'path': urlencode_path(link), # TODO: or replace(" ", "%20")? 'action': command.get("action", "RESOLVE") } ) else: steps = [to_unicode(step) for step in command["steps"]] files, dirs = lister.get(link, steps, parameters) if command.get("action", "RESOLVE") == "ACTIVATE": files += dirs if files: command_group_results += [ { 'label': f['label'], 'path': player.postprocess(f['path']), 'action': command.get("action", "RESOLVE") } for f in files] if command_group_results: break results += command_group_results if results: return player.title, results