def mostrar_perfil(item): logger.debug() alfav = KodfavouritesData() itemlist = [] i_perfil = item.i_perfil if not alfav.user_favorites[i_perfil]: return itemlist last_i = len(alfav.user_favorites[i_perfil]['items']) - 1 ruta_runtime = config.get_runtime_path() for i_enlace, enlace in enumerate(alfav.user_favorites[i_perfil]['items']): it = Item().fromurl(enlace) it.from_channel = 'kodfavorites' it.context = [{ 'title': config.get_localized_string(70617), 'channel': item.channel, 'action': 'acciones_enlace', 'i_enlace': i_enlace, 'i_perfil': i_perfil }] it.plot += '[CR][CR]' + config.get_localized_string( 70724) + ': ' + it.channel + ' ' + config.get_localized_string( 60266) + ': ' + it.action if (type(it.extra) is str) and it.extra != '': it.plot += ' Extra: ' + it.extra it.plot += '[CR]Url: ' + it.url if isinstance(it.url, str) else '...' if it.date_added != '': it.plot += '[CR]' + config.get_localized_string( 70469) + ': ' + it.date_added if it.server: it.thumbnail = it.contentThumbnail it.title += ' [{}]'.format(it.serverName) # If it is not a url, nor does it have the system path, convert the path since it will have been copied from another device. # It would be more optimal if the conversion was done with an import menu, but at the moment it is controlled in run-time. # if it.thumbnail and '://' not in it.thumbnail and not it.thumbnail.startswith(ruta_runtime): # ruta, fichero = filetools.split(it.thumbnail) # if ruta == '' and fichero == it.thumbnail: # in linux the split with a windows path does not separate correctly # ruta, fichero = filetools.split(it.thumbnail.replace('\\','/')) # if 'channels' in ruta and 'thumb' in ruta: # it.thumbnail = filetools.join(ruta_runtime, 'resources', 'media', 'channels', 'thumb', fichero) # elif 'themes' in ruta and 'default' in ruta: # it.thumbnail = filetools.join(ruta_runtime, 'resources', 'media', 'themes', 'default', fichero) itemlist.append(it) return itemlist
def mainlist(item): logger.info() item.category = 'Descargas' itemlist = [] if download_path.startswith('smb://'): fichs = sorted(filetools.listdir(download_path)) ficheros = [ filetools.join(download_path, fit) for fit in fichs if fit.endswith('.json') ] else: path = filetools.join(download_path, '*.json') ficheros = glob.glob(path) ficheros.sort(key=os.path.getmtime, reverse=False) for down_path in ficheros: # ~ it = Item().fromjson(path=down_path) # falla con smb:// it = Item().fromjson(filetools.read(down_path)) it.from_channel = it.channel it.from_action = it.action it.channel = item.channel it.action = 'acciones_enlace' it.jsonfile = down_path it.folder = False if it.downloadStatus == STATUS_CODES.completed: it.title = '[B][COLOR gold][Ok] %s [%s][/COLOR][/B]' % ( it.downloadFilename, config.format_bytes(it.downloadSize)) elif it.downloadStatus == STATUS_CODES.canceled: it.title = '[COLOR red][%s%%] %s [%s de %s][/COLOR]' % ( int(it.downloadProgress), it.downloadFilename, config.format_bytes(it.downloadCompleted), config.format_bytes(it.downloadSize)) elif it.downloadStatus == STATUS_CODES.error: it.title = '[I][COLOR gray][Error] %s[/COLOR][/I]' % it.downloadFilename else: it.title = '[I][COLOR gray][???] %s[/COLOR][/I]' % it.downloadFilename itemlist.append(it) return itemlist