3 __author__ = "Artur Duque de Souza"
4 __author_email__ = "artur.souza@indt.org.br"
11 import lib.utils as utils
15 __all__ = ("FileList", "list_media_files")
18 class TranscodedFile(object):
19 """This class creates and reads information about transcoded files."""
22 def __init__(self, filename, args):
23 if filename == "" or not os.path.exists(filename):
24 self.opts = args.copy()
26 if self.opts["type"][0] != "myth":
27 self.opts["original_mtime"] = os.path.getmtime(
30 name = os.path.basename(self.opts["uri"][0])
31 self.opts["original"] = name
32 output_file = os.path.basename(self.opts["outfile"][0])
33 output = open(".transcoded/%s.dat" % \
34 os.path.splitext(output_file)[0], "wb")
35 # dumps data using the highest protocol
36 pickle.dump(self.opts, output, -1)
39 name = os.path.splitext(os.path.basename(filename))[0]
40 pkl_file = open(".transcoded/%s.dat" % name, "rb")
41 self.opts = pickle.load(pkl_file)
48 """Class to hold file's list - reimplements str and repr."""
53 ret = ret + " %s" % item
63 def list_media_files(directory, file_list):
64 """Show all the media files with extension defined in the var 'ext'
65 that are in the directory, appending each one to 'file_list'."""
66 ext = ['mpg', 'avi', 'mp4', 'nuv', 'mpeg', 'mov']
67 for root, dirs, files in os.walk(directory):
69 if os.path.splitext(name)[1].strip(".") in ext:
70 dat_file = os.path.join(sys.path[0],root,
71 os.path.splitext(name)[0]+".dat")
73 if name not in file_list and \
74 os.path.exists(dat_file):
75 file_list.append(name)