J'en suis là pour le moment
Une fois que l'on a compris comment ça marche c'est assez simple de faire un bon script
[Cpp]
#!/usr/bin/python
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import optparse, re, sys
from optparse import OptionParser
from sys import *
class videoEncoder:
def getFileInfo(self, filename):
os.system("tcprobe -i "+filename" 2>/dev/null")
class Programe:
def __init__(
self.D2DHome="~/.divx2dvd/"
self.D2DTmp=self.D2DHome+"tmp/"
def setup(self):
#Try to access to know if the home dir exists... Really C like coding.
if access(self.D2DHome, F_OK)!=1 :
#Directory does not exist. Try to create it
try:
mkdir(self.D2DHome, 777)
else:
#Can not create it: access denied...
print "Impossible d'écrire dans "+self.D2DHome
print "Modifiez vérifiez les permissions"
return
#At this point we have a home dir. Try to create the tmp dir
if access(self.D2DTmp, F_OK)!=1 :
try:
mkdir(self.D2DTmp, 777)
else:
#Permission denied...
print "Impossible de créer "+self.D2DTmp
print "Vérifiez les permissions"
return
#At this point we have a tmp dir. Make sure we can write in it
if access(self.D2DTmp, W_OK)!=1 :
print "Impossible d'écrire dans "+self.D2DTmp
print "Vérifiez les permissions"
return
def parse_options(self):
parser = OptionParser()
parser.add_option("-i", "--input", dest="filename", help="Input filename", metavar="FILE")
parser.add_option("-z", dest="zoom", help="0:720x480- 1:704x480- 2:352x480- 3:352x240", metavar="SCREEN_SIZE")
parser.add_option("-s", dest="DVDSize", help="maximum size of DVD 10^6 bytes (4700 -> DVD)", metavar="SIZE")
parser.add_option("-o", dest="outDir", help="output directory for DVD structure", metavar="OUTPUT_DIR")
parser.add_option("--chapter", dest="chapter", help="automatically insert chapter markers every C min", metavar="C")
parser.add_option("--fastzoom", action="store_true", dest="fastZoom", default=False, help="zoom faster")
parser.add_option("--widescreen",action="store_true", dest="wideScreen", default=False, help="force widescreen 16:9")
parser.add_option("--normal", action="store_true", dest="normalScreen", default=True, help="force normal 4:3 asr")
parser.add_option("--mp2", action="store_true", dest="mp2", default=False, help="for mp2 audio format")
self.options, self.args = parser.parse_args()
def setDefaultsOptions(self):
if self.options["chapter"]==None :
self.options["chapter"]=5
if self.options["zoom"]> 3 or \
self.options["zoom"]<1 or \
self.options["zoom"]==None:
self.option["zoom"]=1
#Un cas étonnant...
if self.options["wideScreen"]==True and \
self.options["normalScreen"==True :
print "Hemmm... Ecran 16:9 et 4:3 simultanément??? Je prends 4:3"
self.options.["wideScreen"]==False
#On ne se base désormais que sur ws
if self.options["normalScreen"]==True :
self.options.["wideScreen"]==False
#Use the name of the divx to create the DVD directory structure
if self.options["outDir"]==None :
outFileName=os.path.basename(self.options["outDir"])
self.options["out"]=outFileName+"-DVD"
def run(self):
self.setup()
self.parse_options()
self.setDefaultsOptions()
#tool is independant from the encoder used.
vt=videoEncoder()
filename=self.options["filename"]
if access(filename, R_OK) !=1
print "Impossible d'ouvrir le fichier "+filename+" en lecture"
return
fileinfo = vt.getFileInfo(filename)
def main():
d2d=Programe()
d2d.run()
[/cpp]