def search(): user_info = get_user_info() user_cookie = user_info['cookie'] user_tokens = user_info['tokens'] key = cnkeyboard.keyboard(heading=u'输入文件名/关键词') if key: s = pcs.search(user_cookie, user_tokens, key) items = [] if len(s['list']) == 1: for result in s['list']: if result['isdir'] == 1: item = { 'label': result['server_filename'], 'path': plugin.url_for('directory', path=result['path'].encode('utf-8')), 'is_playable': False } items.append(item) elif result['category'] == 1: if 'thumbs' in result and 'url2' in result['thumbs']: ThumbPath = result['thumbs']['url2'] item = { 'label': result['server_filename'], 'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, 'icon': ThumbPath, } else: item = { 'label': result['server_filename'], 'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, } items.append(item) elif result['category'] == 2: item = { 'label': result['server_filename'], 'path': plugin.url_for('play_music', filepath=result['path'].encode('utf-8')), 'is_playable': False, } items.append(item) if items: return plugin.finish(items) else: dialog.ok('',u'搜素的文件不属于文件夹、视频或音频') elif s['list']: for result in s['list']: if result['isdir'] == 1: item = { 'label': result['path'], 'path': plugin.url_for('directory', path=result['path'].encode('utf-8')), 'is_playable': False } items.insert(0, item) elif result['category'] == 1: if 'thumbs' in result and 'url2' in result['thumbs']: ThumbPath = result['thumbs']['url2'] item = { 'label': result['path'], 'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, 'icon': ThumbPath, } else: item = { 'label': result['path'], 'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, } items.append(item) elif result['category'] == 2: item = { 'label': result['path'], 'path': plugin.url_for('play_music', filepath=result['path'].encode('utf-8')), 'is_playable': False, } items.append(item) if items: return plugin.finish(items) else: dialog.ok('',u'搜素的文件不属于文件夹、视频或音频') else: dialog.ok('',u'没有找到文件') return None return
def search(): user_info = get_user_info() user_cookie = user_info['cookie'] user_tokens = user_info['tokens'] key = dialog.input(heading=u'输入文件名/关键词') if key: s = pcs.search(user_cookie, user_tokens, key) items = [] if len(s['list']) == 1: for result in s['list']: if result['isdir'] == 1: item = { 'label': result['server_filename'], 'path': plugin.url_for('directory', path=result['path'].encode('utf-8')), 'is_playable': False } items.append(item) elif result['category'] == 1: if 'thumbs' in result and 'url2' in result['thumbs']: ThumbPath = result['thumbs']['url2'] item = { 'label': result['server_filename'], 'path': plugin.url_for( 'quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, 'icon': ThumbPath, } else: item = { 'label': result['server_filename'], 'path': plugin.url_for( 'quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, } items.append(item) elif result['category'] == 2: item = { 'label': result['server_filename'], 'path': plugin.url_for( 'play_music', filepath=result['path'].encode('utf-8')), 'is_playable': False, } items.append(item) if items: return plugin.finish(items) else: dialog.ok('', u'搜素的文件不属于文件夹、视频或音频') elif s['list']: for result in s['list']: if result['isdir'] == 1: item = { 'label': result['path'], 'path': plugin.url_for('directory', path=result['path'].encode('utf-8')), 'is_playable': False } items.insert(0, item) elif result['category'] == 1: if 'thumbs' in result and 'url2' in result['thumbs']: ThumbPath = result['thumbs']['url2'] item = { 'label': result['path'], 'path': plugin.url_for( 'quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, 'icon': ThumbPath, } else: item = { 'label': result['path'], 'path': plugin.url_for( 'quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, } items.append(item) elif result['category'] == 2: item = { 'label': result['path'], 'path': plugin.url_for( 'play_music', filepath=result['path'].encode('utf-8')), 'is_playable': False, } items.append(item) if items: return plugin.finish(items) else: dialog.ok('', u'搜素的文件不属于文件夹、视频或音频') else: dialog.ok('', u'没有找到文件') return None return