diff -r 000000000000 -r 289e2d11d16c gmyth-stream/server/0.1/lib.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.1/lib.py Tue May 01 21:05:29 2007 +0100 @@ -0,0 +1,36 @@ +import time +import logging +import os +import stat + +ext = ['mpg', 'avi', 'mp4', 'nuv', 'mpeg', 'mov'] + +def now(): + return time.strftime("%Y-%m-%d %H:%M:%S"); + +def log(msg): + logging.log(logging.DEBUG, msg) + new_msg = "[%s] %s" % (now(), msg) + return new_msg + + +bin_path_list = os.environ["PATH"].split(os.pathsep) +def which(prg): + for d in bin_path_list: + path = os.path.join(d, prg) + if os.path.exists(path): + st = os.stat(path) + if st[stat.ST_MODE] & 0111: + return path + return "" + +def list_media_files(directory, file_list): + for root, dirs, files in os.walk(directory): + for name in files: + if os.path.splitext(name)[1].strip(".") in ext: + media = os.path.join(root,name) + if media not in file_list: + file_list.append(os.path.join(root,name)) + + return True +