#!/usr/bin/python ##I have taken the concept of this script from http://s91928265.onlinehome.us/hfamily/mythtv/myth_ubuntu.html ##The script has not been updated in awhile and since Ubuntu Feisty came out, it no longer works ##I asked in #bash and everyone agreed that the original writer did not do a very good job. So I am going ##to take over and convert it to python and hopefully keep it up to date and working. I hope to add some extra features to it ##like an option to burn the dvd after creating the iso file! ##James Middendorff a.k.a riddlebox ##05/12/07 ## ##Depends on dvdauthor ########################################################################################################## ## ##Notes to myself while writing this! ## 1. Use sys.argv to pass arguments at the commandline! ## 2. Use sys.argv to create a -h to show the description and how to properly use the script ## 3. Create Functions to do the actual work! ## 4. use subprocess to run the commands instead of popen3 import os import sys import subprocess #create the variables for python to create the project name and take the file name #will eventually have more than one filename projName = sys.argv[1] file1 = sys.argv[2] #file2 = sys.argv[3] #file3 = sys.argv[4] ###These lines will setup our commands to actually do the work! def cleanUp(): os.remove('aud$i') os.remove('vid$i') os.remove('dvdmpg$i') os.remove('$dvdproj/') print 'finished cleaning up files' print 'Successfully completed the project, now you must burn the iso and enjoy!' def sub_mkiso(): print 'Starting the mkisofs process.....' sub_mkisofs = subprocess.call(['mkisofs',' -dvd-video', '-udf', '-V', 'MythDVD', '-r', '$dvdproj/', '>', 'MythDVD.iso']) if sub_mkisofs == 0: print 'Success creating the iso file' cleanUp() else: print 'An error occured' def sub_dvdAuth2(): print 'Starting the second round of dvdauthor.....' sub_dvdauth2 = subprocess.call(['dvdauthor', '-o', '$dvdproj', '-T']) if sub_dvdauth2 == 0: print 'Success with dvdauthor -o $dvdproj -T' sub_mkiso else: print 'An error occured' def sub_dvdAuth1(): print 'Starting the first round of dvdauthor' sub_dvdauthor = subporcess.call(['dvdauthor', '-o', '$dvdproj', '-f %s']%str) if sub_dvdauthor == 0: print 'Success with dvdauthor -o $dvdproj -f titlename' sub_dvdauth2() else: print 'An error occured' def sub_mplex(): print 'Starting the mplex' sub_mplexAll = subprocess.call(['mplex', '-f 8', '-V', '-o', 'dvdmpg$i', 'aud$i', 'vid$i']) if sub_mplexAll ==0: print 'Success with mplex -f 8 -V -o dvdmpg$i aud$i vid$i' os.popen3('mkdir $dvdproj') str = "dvdmpg$i" sub_dvdauth1() else: print 'Returned an error' def sub_mv(): print 'Starting to mpeg2desc the video' sub_mpeg_video = subprocess.call(['mpeg2desc', '-v0', '>', 'vid$i']) if sub_mpeg_video == 0: print 'Success with mpeg2desc -v0 > vid$i' sub_mplex() else: print 'Returned an error' def sub_ma(): print 'Starting to mpeg2desc the audio' sub_mpeg_audio = subprocess.call(['mpeg2desc', '-a0', '>', 'aud$i']) if sub_mpeg_audio == 0: print 'Success with mpeg2desc -a0 > aud$i' sub_mv() else: print 'Returned an error' ##First we will show the description and how to properly use the script, which I will hope to make this part a help file of some sort print "" print "makedvd: From a set of MythTV recordings, create an ISO" print " file suitable for burning directly to" print " a DVD. The output is nothing fancy; each" print " show is simply a chapter on the DVD, without" print " menus and such." print "" print "Usage: python makedvd.py dvdprojectname [list of .nuv files....]" print " The output file will be named dvdprojectname.iso." print "" print "" #This will pull the title info from the database using mythshows.sh def Main_App(): try: os.remove('TITLES.LOG') #this will try to remove the file TITLES.LOG print 'Removed TITLES.LOG, proceeding.' os.popen3('mytshows.sh |grep %s >> TITLES.LOG'%file1) #and if it is deleted then create the TITLES.LOG except: print 'No TITLES.LOG in this directory, proceeding.' #Will see there is no TITLES.LOG os.popen3('mythshows.sh |grep %s >> TITLES.LOG'%file1) #and will create the TITLES.LOG #the line with os.popen3 take the filename and use mythshows.sh to create the log with the name of the show to convert finally: print '#######################################' #moves on to the rest of the script print 'DVD Project is: %s'%projName #Eventually I want to display the filename and info that is being converted as well. print '#######################################' os.popen3('mkfifo aud$i') os.popen3('mkfifo vid$i') os.popen3('mkfifo dvdmpg$i') print 'made the fifo stuff' ##Start all of the defs here!!!! this will do most of the work subprocess.call(["ls","-l"]) sub_ma() Main_App()