From d5ba283281092bf74649496419987d027c1f18eb Mon Sep 17 00:00:00 2001 From: Jan Krcmar Date: Fri, 29 Oct 2010 13:15:32 +0200 Subject: [PATCH] added __back__ to the list of files --- bin/tv | 2 +- filechooser.py | 11 +++++++++++ tv_web.py | 7 +++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bin/tv b/bin/tv index 715b4e1..d23dd1b 100755 --- a/bin/tv +++ b/bin/tv @@ -2,7 +2,7 @@ # mplayer parametres #prms="-stereo 1 -vf pp=lb -cache 2048" -prms="--extraintf ncurses --video-filter=deinterlace --deinterlace-mode=blend -f" +prms="--extraintf ncurses --play-and-exit --video-filter=deinterlace --deinterlace-mode=blend -f" conf="$HOME/bin/tv.conf" # shows all available channels diff --git a/filechooser.py b/filechooser.py index 0ce288b..c910dca 100644 --- a/filechooser.py +++ b/filechooser.py @@ -10,7 +10,9 @@ class FileChooser(): '/mnt/data', '/home/ftp/serialy', '/mnt/kesunka/serialy', + '/mnt/kesunka/video', ] + self.back_item = '__back__' self.cpath = self.allowed_prefix[0] def getAllowed(self): @@ -34,6 +36,14 @@ class FileChooser(): return True else: return False + + def goBack(self, item=None): + print "go back" + if item.split('/')[-1] == self.back_item: + print "matches ", self.back_item + out = self.cpath[:self.cpath.rfind('/')] + if re.match("("+string.join(self.allowed_prefix, "|")+")", out): + self.cpath = out def getList(self): out = self.transformList(os.listdir(self.cpath)) @@ -45,6 +55,7 @@ class FileChooser(): for d in list: if all(ord(c) < 128 for c in d): out.append(d) + out.insert(0, self.back_item) return out diff --git a/tv_web.py b/tv_web.py index ca116a9..db7576c 100755 --- a/tv_web.py +++ b/tv_web.py @@ -103,6 +103,7 @@ class TvWeb: monitoroff.exposed = True + # file action def fcaction(self, item=None): if not self.hostallowed(): return "You are not alowed." if cherrypy.request.method == 'GET': @@ -111,8 +112,10 @@ class TvWeb: self.lastip = cherrypy.request.remote.ip self.mpc.play(item) time.sleep(2) - if os.path.isdir(item): - self.filechooser.setPath(item) + elif os.path.isdir(item): + self.filechooser.setPath(item) + else: + self.filechooser.goBack(item) raise cherrypy.HTTPRedirect('/tvweb') return "GET request expected, but "+cherrypy.request.method+" arrived!" -- 2.11.4.GIT