do not overwrite output file if exists

Sat, 25 Nov 2017 12:24:17 +0100

author
mdd
date
Sat, 25 Nov 2017 12:24:17 +0100
changeset 11
821c02fa7070
parent 10
f436a7f94c6a
child 12
f0c7db3b239d

do not overwrite output file if exists

ts2mkv.py file | annotate | diff | comparison | revisions
--- a/ts2mkv.py	Fri Nov 24 23:42:30 2017 +0100
+++ b/ts2mkv.py	Sat Nov 25 12:24:17 2017 +0100
@@ -143,10 +143,17 @@
         if not self.filename:
             return None
 
+
         commands = []
         fn = "\\'".join(p for p in self.filename.split("'"))
         fn = fn.replace(" ", "\\ ")
         outfn = self.outfilebase + ".mkv"
+        # double-check: pull the kill switch and exit if outfile exists already!
+        # we do not want to overwrite files in accident (caused by automatic file naming)
+        if len(glob.glob(outfn)) > 0:
+            print "Output file exists: %s" % outfn
+            print "NOT overwriting it!"
+            return None
         outfn = "\\'".join(p for p in outfn.split("'"))
         outfn = outfn.replace(" ", "\\ ")
 
@@ -221,6 +228,10 @@
 
 
         self.msg_prepare += "Video Stream selected: Stream #%s\n" % v
+
+        # TODO: Old dreambox images did a file split: .ts .ts.001 .ts.002 etc.
+        # Find all these files and join them!
+
         cmd = [
             "ffmpeg",
             "-i %s" % fn,

mercurial