Пример #1
0
    def ripAllTracks(self,pathSave):
        didRip = True
        
        if not os.path.isdir(pathSave):
            os.makedirs(pathSave)
            
        try:
            
            ripType = 'file'

            logging.info('Started ripping all tracks to: ' + str(pathSave))
            cmdargs = [apppath.makemkvcon(),'-r','--noscan','mkv',ripType + ':' + str(self.filePath),'all',pathSave]
            logging.debug('Running command: ' + ' '.join(cmdargs))
            exitCode = subprocess.call(cmdargs)
                
            if exitCode is not 0:
                didRip = False

        except subprocess.CalledProcessError as e:
            logging.error( 'Failed to save track ' + str(track) + ', reason: **' + str(e.output) + '**' )
            didRip = False
        
        rippedTracks = []
        
        if didRip:
            for fileName in os.listdir(pathSave):
                if fileName.lower().endswith('.mkv'):
                    filePath = os.path.join(pathSave,fileName)
                    track = LocalTrackMkv(filePath)
                    rippedTracks.append(track)
        
        return rippedTracks
Пример #2
0
    def ripAllTracks(self,pathSave):
        didRip = True
        
        if not os.path.isdir(pathSave):
            os.makedirs(pathSave)
            
        try:
            
            ripType = 'dev'

            logging.info('Started ripping all tracks to: ' + str(pathSave))
            cmdargs = [apppath.makemkvcon(),'-r','--noscan','mkv',ripType + ':' + str(self.filePath),'all',pathSave]
            logging.debug('Running command: ' + ' '.join(cmdargs))
            exitCode = subprocess.call(cmdargs)
                
            if exitCode is not 0:
                didRip = False

        except subprocess.CalledProcessError as e:
            logging.error( 'Failed to save track ' + str(track) + ', reason: **' + str(e.output) + '**' )
            didRip = False
        
        rippedTracks = []
        
        if didRip:
            for fileName in os.listdir(pathSave):
                if fileName.lower().endswith('.mkv'):
                    filePath = os.path.join(pathSave,fileName)
                    track = DiscTrack.LocalTrackMkv(filePath)
                    rippedTracks.append(track)
        
        return rippedTracks
Пример #3
0
 def _driveInfoRawFromDevice(deviceName):
     try:
         cmdargs = [apppath.makemkvcon(),'-r','info','disc:%d' % 9999]
         logging.debug('Running command: ' + ' '.join(cmdargs))
         cmd = subprocess.Popen(cmdargs,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         cmd.wait()
         response = cmd.communicate()
         discs = response[0]
     except subprocess.CalledProcessError as e:
         logging.error( 'Failed to call makemkv: ' + str(e.output) )
         sys.exit(1)
         
     return discs
Пример #4
0
    def _hasMakeMkvKeyExpired():
        hasExpired = False
    
        try:
            cmdargs = [apppath.makemkvcon(),'--noscan','-r','info']
            logging.debug('Running command: ' + ' '.join(cmdargs))
            cmd = subprocess.Popen(cmdargs,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            cmd.wait()
            response = cmd.communicate()
            
            if 'enter a registration key to continue' in response[0].lower():
                hasExpired = True

        except subprocess.CalledProcessError as e:
            logging.error( 'Failed to call makemkv: ' + str(e.output) )
            sys.exit(1)
        
        return hasExpired
Пример #5
0
    def _hasMakeMkvKeyExpired():
        hasExpired = False
    
        try:
            cmdargs = [apppath.makemkvcon(),'--noscan','-r','info']
            logging.debug('Running command: ' + ' '.join(cmdargs))
            cmd = subprocess.Popen(cmdargs,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            cmd.wait()
            response = cmd.communicate()
            
            if 'enter a registration key to continue' in response[0].lower():
                hasExpired = True

        except subprocess.CalledProcessError as e:
            logging.error( 'Failed to call makemkv: ' + str(e.output) )
            sys.exit(1)
        
        return hasExpired
Пример #6
0
    def ripTracks(self,tracks,pathSave):
        didRip = True
        
        if not os.path.isdir(pathSave):
            os.makedirs(pathSave)
            
        for track in tracks:
            try:
                outputFile = os.path.join(pathSave,track.outputFileName)

                if os.path.exists(outputFile):
                    os.remove(outputFile)
                    
                ripType = 'file'

                logging.info('Started ripping track: ' + str(track))
                cmdargs = [apppath.makemkvcon(),'-r','--noscan','mkv',ripType + ':' + str(self.filePath),str(track.trackNumber),pathSave]
                logging.debug('Running command: ' + ' '.join(cmdargs))
                exitCode = subprocess.call(cmdargs)
                
                if exitCode is not 0:
                    didRip = False
                
                nfoFile = track.outputFileName.replace('.mkv','.nfo')
                
                with open(os.path.join(pathSave,nfoFile), 'w') as outfile:
                    json.dump(track.serialize(), outfile)

            except subprocess.CalledProcessError as e:
                logging.error( 'Failed to save track ' + str(track) + ', reason: **' + str(e.output) + '**' )
                didRip = False

        if didRip:
            for track in tracks:
                filePath = os.path.join(pathSave,track.outputFileName)
                track = LocalTrackMkv(filePath)
                rippedTracks.append(track)

        return rippedTracks
Пример #7
0
    def ripTracks(self,tracks,pathSave):
        didRip = True
        
        if not os.path.isdir(pathSave):
            os.makedirs(pathSave)
            
        for track in tracks:
            try:
                outputFile = os.path.join(pathSave,track.outputFileName)

                if os.path.exists(outputFile):
                    os.remove(outputFile)
                    
                ripType = 'file'

                logging.info('Started ripping track: ' + str(track))
                cmdargs = [apppath.makemkvcon(),'-r','--noscan','mkv',ripType + ':' + str(self.filePath),str(track.trackNumber),pathSave]
                logging.debug('Running command: ' + ' '.join(cmdargs))
                exitCode = subprocess.call(cmdargs)
                
                if exitCode is not 0:
                    didRip = False
                
                nfoFile = track.outputFileName.replace('.mkv','.nfo')
                
                with open(os.path.join(pathSave,nfoFile), 'w') as outfile:
                    json.dump(track.serialize(), outfile)

            except subprocess.CalledProcessError as e:
                logging.error( 'Failed to save track ' + str(track) + ', reason: **' + str(e.output) + '**' )
                didRip = False

        if didRip:
            for track in tracks:
                filePath = os.path.join(pathSave,track.outputFileName)
                track = LocalTrackMkv(filePath)
                rippedTracks.append(track)

        return rippedTracks
Пример #8
0
    def ripTracks(self,tracks,pathSave):
        didRip = True
        
        if not os.path.isdir(pathSave):
            os.makedirs(pathSave)
            
        for track in tracks:
            try:
                outputFile = os.path.join(pathSave,track.outputFileName)

                if os.path.exists(outputFile):
                    os.remove(outputFile)
                    
                ripType = 'disc'

                logging.info('Started ripping track: ' + str(track))
                cmdargs = [apppath.makemkvcon(),'-r','--noscan','mkv',ripType + ':' + str(self.driveNumber),str(track.trackNumber),pathSave]
                logging.debug('Running command: ' + ' '.join(cmdargs))
                exitCode = subprocess.call(cmdargs)
                
                if exitCode is not 0:
                    didRip = False

            except subprocess.CalledProcessError as e:
                logging.error( 'Failed to save track ' + str(track) + ', reason: **' + str(e.output) + '**' )
                didRip = False
        
        rippedTracks = []
        
        if didRip:
            for fileName in os.listdir(pathSave):
                if fileName.lower().endswith('.mkv'):
                    filePath = os.path.join(pathSave,fileName)
                    track = LocalTrackMkv(filePath)
                    rippedTracks.append(track)

        return rippedTracks
Пример #9
0
    def __init__(self,filePath):
        if MakeMKVDir._hasMakeMkvKeyExpired():
            raise Exception('MakeMKV license key has expired. Manually run makemkv to update the key. (AppPath:' + apppath.makemkvcon() +')')
    
        #TODO replace is a workaround til I figure out naming scheme for devices
        filePath = filePath.replace('/dev/disk','/dev/rdisk')
    
        self.filePath = filePath

        self.mediaDiscTracks = []
        
        logging.debug('MakeMKVDir initialized with filePath' + str(filePath))
Пример #10
0
    def __init__(self,deviceID):
        if MakeMKVDisc._hasMakeMkvKeyExpired():
            raise Exception('MakeMKV license key has expired. Manually run makemkv to update the key. (AppPath:' + apppath.makemkvcon() +')')
    
        #TODO replace is a workaround til I figure out naming scheme for devices
        deviceID = deviceID.replace('/dev/disk','/dev/rdisk')
    
        self.deviceID = deviceID
        self.discInfoRaw = MakeMKVDisc._discInfoRawFromDevice(deviceID)
        
        self.mediaDiscTracks = MakeMKVDisc._discTracksFromDictionary( MakeMKVDisc._deserializeDiscInfo(self.discInfoRaw) )
        
        driveInfo = MakeMKVDisc._driveInfoRawFromDevice(deviceID)

        self.driveNumber = MakeMKVDisc._driveNumber(driveInfo,deviceID)
        
        logging.debug('MakeMKVDisc initialized with deviceID' + str(deviceID))
Пример #11
0
    def __init__(self,filePath):
        if MakeMKVFile._hasMakeMkvKeyExpired():
            raise Exception('MakeMKV license key has expired. Manually run makemkv to update the key. (AppPath:' + apppath.makemkvcon() +')')

        self.filePath = filePath
        
        self.mediaDiscTracks = []
        
        logging.debug('MakeMKVFile initialized with deviceID' + str(filePath))
Пример #12
0
    def __init__(self,filePath):
        if MakeMKVFile._hasMakeMkvKeyExpired():
            raise Exception('MakeMKV license key has expired. Manually run makemkv to update the key. (AppPath:' + apppath.makemkvcon() +')')

        self.filePath = filePath
        
        self.mediaDiscTracks = []
        
        logging.debug('MakeMKVFile initialized with deviceID' + str(filePath))