Ticket #4538: mythburn-cleanuptempfiles.diff

File mythburn-cleanuptempfiles.diff, 4.0 KB (added by thrantastic@…, 12 years ago)

Clean up temporary files as soon as possible in mythburn.py to save space

  • mythburn.py

    old new  
    3636# version of script - change after each update
    3737VERSION="0.1.20080106-1"
    3838
     39# keep all temporary files for debugging purposes
     40# set this to True before a first run through when testing
     41# out new themes (see below)
     42debug_keeptempfiles = False
    3943
    4044##You can use this debug flag when testing out new themes
    4145##pick some small recordings, run them through as normal
     46##with debug_keeptempfiles = True (see above)
    4247##set this variable to True and then re-run the scripts
    4348##the temp. files will not be deleted and it will run through
    4449##very much quicker!
     
    41884193                write("File has a cut list - running mythtrancode to remove unwanted segments")
    41894194                chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
    41904195                starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
    4191                 if runMythtranscode(chanid, starttime, os.path.join(folder,'tmp'), True, localfile):
    4192                     mediafile = os.path.join(folder,'tmp')
     4196                if runMythtranscode(chanid, starttime, os.path.join(folder,'newfile.mpg'), True, localfile):
     4197                    mediafile = os.path.join(folder,'newfile.mpg')
    41934198                else:
    41944199                    write("Failed to run mythtranscode to remove unwanted segments")
    41954200            else:
     
    43014306                            audio1, audio2, aspectratio, profile)
    43024307            mediafile = os.path.join(folder, 'newfile2.mpg')
    43034308
    4304     #remove an intermediate file
    4305     if os.path.exists(os.path.join(folder, "newfile1.mpg")):
    4306         os.remove(os.path.join(folder,'newfile1.mpg'))
     4309            #remove the old mediafile that was run through mythtranscode
     4310            #if it exists
     4311            if debug_keeptempfiles==False:
     4312                if os.path.exists(os.path.join(folder, "newfile.mpg")):
     4313                    os.remove(os.path.join(folder,'newfile.mpg'))
    43074314
    43084315    # the file is now DVD compliant split it into video and audio parts
    43094316
     
    43174324    write("Splitting MPEG stream into audio and video parts")
    43184325    deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2)
    43194326
    4320     if os.path.exists(os.path.join(folder, "newfile2.mpg")):
    4321         os.remove(os.path.join(folder,'newfile2.mpg'))
     4327    # remove intermediate files
     4328    if debug_keeptempfiles==False:
     4329        if os.path.exists(os.path.join(folder, "newfile.mpg")):
     4330            os.remove(os.path.join(folder,'newfile.mpg'))
     4331        if os.path.exists(os.path.join(folder, "newfile2.mpg")):
     4332            os.remove(os.path.join(folder,'newfile2.mpg'))
    43224333
    43234334    # we now have a video stream and one or more audio streams
    43244335    # check if we need to convert any of the audio streams to ac3
     
    45254536            #Now all the files are completed and ready to be burnt
    45264537            runDVDAuthor()
    45274538
     4539            #Delete dvdauthor work files
     4540            if debug_keeptempfiles==False:
     4541                filecount=0
     4542                for node in files:
     4543                    filecount+=1
     4544                    folder=getItemTempPath(filecount)
     4545                    if os.path.exists(os.path.join(folder, "stream.mv2")):
     4546                        os.remove(os.path.join(folder,'stream.mv2'))
     4547                    if os.path.exists(os.path.join(folder, "stream0.mp2")):
     4548                        os.remove(os.path.join(folder,'stream0.mp2'))
     4549                    if os.path.exists(os.path.join(folder, "stream1.mp2")):
     4550                        os.remove(os.path.join(folder,'stream1.mp2'))
     4551                    if os.path.exists(os.path.join(folder, "stream0.ac3")):
     4552                        os.remove(os.path.join(folder,'stream0.ac3'))
     4553                    if os.path.exists(os.path.join(folder, "stream1.ac3")):
     4554                        os.remove(os.path.join(folder,'stream1.ac3'))
     4555
    45284556            #Get DVD title from first processed file
    45294557            #Get the XML containing information about this item
    45304558            infoDOM = xml.dom.minidom.parse( os.path.join(getItemTempPath(1),"info.xml") )