Exemple #1
0
def list_dir(path):
    path = text.urlencode_path(path)
    try:
        response = RPC.Files.GetDirectory(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':
                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]
Exemple #2
0
def resolve_player(player, lister, params):
    results = []
    for command_group in player.commands:
        if xbmc.Monitor().abortRequested() or not Lister().is_active():
            return
        command_group_results = []
        for command in command_group:
            if xbmc.Monitor().abortRequested() or not Lister().is_active():
                return
            lang = command.get('language', 'en')
            if not lang in params:
                continue
            parameters = params[lang]

            #CHANGES		link = text.apply_parameters(text.to_unicode(command['link']), parameters)
            #			link = text.apply_parameters(text.to_unicode(command['link']), parameters).replace(' & ','%20%26%20')
            #modified the following line to replace " & " with " and "
            link = text.apply_parameters(text.to_unicode(command['link']),
                                         parameters).replace(' & ', ' and ')
            #			xbmc.log(link, level=4)

            if link == 'movies' and player.media == 'movies':
                video = tools.get_movie_from_library(parameters['imdb'])
                if video:
                    command_group_results.append(video)
            elif link == 'tvshows' and player.media == 'tvshows':
                video = tools.get_episode_from_library(parameters['id'],
                                                       parameters['season'],
                                                       parameters['episode'])
                if not video:
                    video = tools.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':
                    text.urlencode_path(link),
                    'action':
                    command.get('action', 'PLAY')
                })
            else:
                steps = [text.to_unicode(step) for step in command['steps']]
                files, dirs = Lister().get(link, steps, parameters)
                if files:
                    command_group_results += [{
                        'label':
                        f['label'],
                        'path': (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
Exemple #3
0
def resolve_player(player, lister, params):
    #	xbmc.log(str('def resolve_player(player, lister, params):')+'===>OPENMETA', level=xbmc.LOGNOTICE)
    results = []
    for command_group in player.commands:
        if xbmc.Monitor().abortRequested() or not lister.is_active():
            return
        command_group_results = []
        for command in command_group:
            if xbmc.Monitor().abortRequested() or not lister.is_active():
                return
            lang = command.get('language', 'en')
            if not lang in params:
                continue
            parameters = params[lang]
            link = text.apply_parameters(text.to_unicode(command['link']),
                                         parameters)
            if link == 'movies' and player.media == 'movies':
                video = tools.get_movie_from_library(parameters['imdb'])
                if video:
                    command_group_results.append(video)
            elif link == 'tvshows' and player.media == 'tvshows':
                video = tools.get_episode_from_library(parameters['id'],
                                                       parameters['season'],
                                                       parameters['episode'])
                if not video:
                    video = tools.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':
                    text.urlencode_path(link),
                    'action':
                    command.get('action', 'PLAY')
                })
            else:
                steps = [text.to_unicode(step) for step in command['steps']]
                files, dirs = lister.get(link, steps, parameters)
                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