Example #1
0
    def pgsDataForTrackNumber(self,trackNumber):
        tmpDir = apppath.pathTemporary('disk_track')
        pgsFile = os.path.join(tmpDir,'tmpFile.sup')
        
        if os.path.exists(pgsFile):
            os.remove(pgsFile)
        
        cmdargs = [apppath.mkvextract(),'tracks',self.filepath,str(trackNumber)+':'+pgsFile]
        logging.debug('Running command ' + ' '.join(cmdargs))

        cmd = subprocess.Popen(cmdargs,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        response = cmd.communicate()
        
        pgsdata = None
        
        if os.path.exists(pgsFile):
            logging.debug('Found pgs file ' + pgsFile)
            fPgs = open(pgsFile,'r')
            pgsdata = fPgs.read()
            assert(len(pgsdata)>0)
            fPgs.close()
        else:
            logging.error('Failed to find PGS file ' + str(pgsFile))

        return pgsdata
Example #2
0
    def vobsubDataForTrackNumber(self,trackNumber):
        tmpDir = apppath.pathTemporary('disk_track')
        vobsubFile = os.path.join(tmpDir,'tmpFile.sub')
        
        if os.path.exists(vobsubFile):
            os.remove(vobsubFile)
        
        idxFile = os.path.join(tmpDir,'tmpFile.idx')
        
        if os.path.exists(idxFile):
            os.remove(idxFile)
        
        cmdargs = [apppath.mkvextract(),'tracks',self.filepath,str(trackNumber)+':'+vobsubFile]
        logging.debug('Running command ' + ' '.join(cmdargs))
        cmd = subprocess.Popen(cmdargs,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
#         cmd.wait()
        response = cmd.communicate()
        
        vobsubdata = None
        idxdata = None
        
        if os.path.exists(vobsubFile) and os.path.exists(idxFile):
            logging.debug('Found vob sub file ' + vobsubFile)
            fSub = open(vobsubFile,'r')
            vobsubdata = fSub.read()
            fSub.close()

            fIdx = open(idxFile,'r')
            idxdata = fIdx.read()
            fIdx.close()
        else:
            logging.error('Failed to find vobsub file ' + str(vobsubFile))

        return [vobsubdata,idxdata]