Last active
December 15, 2015 09:49
-
-
Save schlamar/5240832 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VLCFileSystem(object): | |
_cur_path = None | |
_cur_dir = None | |
@classmethod | |
def listdir(cls, path): | |
url = 'http://127.0.0.1:8080/requests/browse.json?dir=%s' % path | |
resp = requests.get(url) | |
data = resp.json()['element'] | |
cls._cur_dir = dict((f['path'], f) for f in data if f['name'] != u'..') | |
return cls._cur_dir.keys() | |
@classmethod | |
def is_hidden(cls, fn): | |
return False | |
@classmethod | |
def sort_files(cls, files): | |
return sorted(files) | |
@classmethod | |
def isdir(cls, fn): | |
if fn.startswith('..'): | |
return True | |
if not fn in cls._cur_dir: | |
return False | |
return cls._cur_dir[fn]['type'] == u'dir' | |
@classmethod | |
def getsize(cls, fn): | |
if not fn in cls._cur_dir: | |
return 0 | |
return cls._cur_dir[fn]['size'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment