#! /usr/bin/env python # This script will launch mplayer or xine depending # on the subtitle format (filename actually) import sys import os movieName = sys.argv[1] if len(movieName) < 1: """Usage: ./launchmovie.py path/to/movie""" sys.exit() i = len(movieName) - 1 while i > 0 and movieName[i] != ".": i -= 1 if 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 = movieName if 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)