#! /usr/bin/env python# This script will launch mplayer or xine depending # on the subtitle format (filename actually)import sysimport osmovieName = sys.argv[1]if len(movieName) < 1: """Usage: ./launchmovie.py path/to/movie""" sys.exit()i = len(movieName) - 1while i > 0 and movieName[i] != ".": i -= 1if movieName[i] == ".": sub = movieName[0:i]else: # the movie filename didn't contain any dotts, must be some weird movie... # but let's assume everything is in order sub = movieNameif os.path.isfile(sub + ".idx"): print "Launch movie with mplayer" cmd = '/usr/bin/mplayer -fs -zoom -quiet -vo xv "' + movieName + '"' bad = 0 tochild, fromchild, childerror = os.popen3(cmd) for line in childerror: if line[-13:-1] == 'decode_audio': bad = 1 tochild.close() fromchild.close() childerror.close() if bad: print 'ac3 sound detected, relaunching mplayer' os.system('/usr/bin/mplayer -ac hwac3 -fs -zoom -quiet -vo xv "' + movieName + '"')else: print "Launch movie with xine" os.execl('/usr/bin/xine', 'xine', '--no-splash', '-f', movieName)