예제 #1
0
 def _get_local_file(self, file):
     if not file:
         return
     if file.endswith('.strm'):
         contents = read_file(file)
         if contents.startswith('plugin://plugin.video.themoviedb.helper'):
             return
     return file
def get_players_from_file():
    players = {}
    basedirs = [PLAYERS_BASEDIR_USER]
    if ADDON.getSettingBool('bundled_players'):
        basedirs += [PLAYERS_BASEDIR_BUNDLED]
    basedirs += [PLAYERS_BASEDIR_SAVE
                 ]  # Add saved players last so they overwrite
    for basedir in basedirs:
        files = get_files_in_folder(basedir, r'.*\.json')
        for file in files:
            meta = loads(read_file(basedir + file)) or {}
            plugins = meta.get(
                'plugin'
            ) or 'plugin.undefined'  # Give dummy name to undefined plugins so that they fail the check
            plugins = plugins if isinstance(
                plugins, list) else [plugins]  # Listify for simplicity of code
            for i in plugins:
                if not xbmc.getCondVisibility(
                        u'System.HasAddon({0})'.format(i)):
                    break  # System doesn't have a required plugin so skip this player
            else:
                meta['plugin'] = plugins[0]
                players[try_decode(file)] = meta
    return players