diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2016-05-26 22:09:13 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2016-05-26 22:09:13 +0200 |
commit | f8d069e3ea2659f15cdbce188c0d05bf55027a4b (patch) | |
tree | 8a904fe5908619086532da2892471639d273e537 | |
parent | b889d9355b73eaacf5c27dae6571e4d5d17fdec3 (diff) | |
download | flask-mediabrowser-f8d069e3ea2659f15cdbce188c0d05bf55027a4b.tar.gz flask-mediabrowser-f8d069e3ea2659f15cdbce188c0d05bf55027a4b.zip |
fix kodi plugin
-rw-r--r-- | kodi-mediabrowser/main.py | 12 | ||||
-rw-r--r-- | mediabrowser/__init__.py | 8 |
2 files changed, 7 insertions, 13 deletions
diff --git a/kodi-mediabrowser/main.py b/kodi-mediabrowser/main.py index ad70506..95cf5f4 100644 --- a/kodi-mediabrowser/main.py +++ b/kodi-mediabrowser/main.py @@ -16,19 +16,17 @@ logging.basicConfig(level=logging.INFO) _url = sys.argv[0] # Get the plugin handle as an integer number. _handle = int(sys.argv[1]) - +# Read settings addon = xbmcaddon.Addon() - endpoint = addon.getSetting('endpoint') def list_files(path): resp = requests.get(endpoint + path) data = resp.json() - files = data['files'] - listing = [] - for file in files: + + for file in data['files']: list_item = xbmcgui.ListItem(label=file['name']) if file['type'] == 'directory': @@ -41,6 +39,7 @@ def list_files(path): list_item.setProperty('IsPlayable', 'true') url = endpoint + file['m3u8'] listing.append((url, list_item, False)) + xbmcplugin.addDirectoryItems(_handle, listing, len(listing)) xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) xbmcplugin.endOfDirectory(_handle) @@ -50,8 +49,7 @@ def router(paramstring): params = dict(parse_qsl(paramstring)) if params: if params['action'] == 'list_files': - # Display the list of videos in a provided category. - list_videos(params['path']) + list_files(params['path']) else: raise Exception('Invalid params') else: diff --git a/mediabrowser/__init__.py b/mediabrowser/__init__.py index 5faed84..139fbf3 100644 --- a/mediabrowser/__init__.py +++ b/mediabrowser/__init__.py @@ -297,20 +297,16 @@ def build(root_directory, cache): else: return {'type': 'file', 'name': filename, - 'download': url_for('mediabrowser.download', - path=os.path.join(path, filename)), 'poster': url_for('mediabrowser.poster', path=os.path.join(path, filename)), - 'trailer': url_for('mediabrowser.thumbnail_video', - path=os.path.join(path, filename)), 'm3u8': url_for('mediabrowser.m3u8', path=os.path.join(path, filename))} try: path = os.path.normpath(path) ospath = os.path.join(root_directory, path) - files = list( - map(partial(gather_fileinfo, path, ospath), os.listdir(ospath))) + files = list(filter(lambda it: it is not None, + map(partial(gather_fileinfo, path, ospath), os.listdir(ospath)))) return jsonify({'files': files}) except FileNotFoundError: abort(404) |