Exemplo n.º 1
0
def convert_with_handbrake(movieLocation):
    '''
        I figure you don't NEED this unless you want the compression factor.  DVD's will take a max of 9 gigs and since I am a quality w***e
        I am going to keep them as close to normal as possible.  Will leave an option for you to override if you feel like it.
    '''
    
    settings = {    'input'         :   movieLocation,
                    'output'        :   os.path.join(arconfig.CONVERT_LOCATION,os.path.split(movieLocation)[-1]),
                    'backupAudio'   :   'ac3,dts,dtshd',
                    'fallbackAudio' :   'ffac3',
                    'videoEncode'   :   'x264',
                    'videoQuality'  :   '20',
                    'advancedEncode':   'level=4.1',
                    'audioTrack'    :   '1',
                    'x264-profile'  :   'high'
               }

    
    movieTime(0)
    tmp =  subprocess.call([ arconfig.HANDBRAKE_CLI, '-i', settings['input'], '-o', settings['output'], '--markers', '--audio', settings['audioTrack'], 
                            '--aencoder', 'copy', '--audio-copy-mask', settings['backupAudio'], '--audio-fallback', settings['fallbackAudio'], 
                            '--encoder', settings['videoEncode'], '--x264-profile', settings['x264-profile'], '--two-pass', '--turbo'])
    
    if tmp == 0:
        os.remove(movieLocation)    #No need to keep the ripped version if this worked.
    else:
        dbWrite('Failed to convert via handbrake', True)
        return False
    
    movieTime(1)
    dbWrite(movieTime(2, 'handbrake'))
    
    return os.path.join(arconfig.CONVERT_LOCATION,os.path.split(movieLocation)[-1])
Exemplo n.º 2
0
def rip_with_makemkv(movieName):
    '''
        I am going to make some assumptions for round 1.  I am going to assume you want an english only disk
        without subs.  I am going to remove all 3D and special tracks.
    '''
    
    settings = {    'cache'            :    1024,
                    'minLength'        :    3601,
                    'discAccess'       :    'true'  #examples are all lowercase
                }
             
    #To get disk info
    discInfo = subprocess.check_output([ arconfig.MAKEMKVCON, '-r', 'info', 'disc:%s' % arconfig.MAKEMKV_DISC_NUM ])
    
    if re.search('"Failed to open disc"', discInfo):
        return False
    
    #To rip disk and eject once finished
    movieTime(0)
    subprocess.call([ arconfig.MAKEMKVCON, '--minlength=%d' %settings['minLength'], '-r', '--decrypt', '--directio=%s' %settings['discAccess'], 'mkv', 
                            'disc:%s' % arconfig.MAKEMKV_DISC_NUM, 'all', arconfig.RIP_LOCATION], stdout=subprocess.PIPE)
    movieTime(1)
    dbWrite(movieTime(2, 'makemkv'))
    tmp = subprocess.call([ 'eject', '-s', arconfig.BLURAY_DEVICE ])
    
    if tmp == 1:
        dbWrite('Failed to rip with makemkv', True)
        return False
        
    '''[ TO DO ] Currently I am going to assume that the first track is the track we want, I will add better control once 
    I figure out all the options to makemkvcon'''
   
    ripMovieName = glob(arconfig.RIP_LOCATION + '*t00.mkv')[0]
    
    return ripMovieName
Exemplo n.º 3
0
def cleanup_bad_jobs():
    dirsToCheck = [ arconfig.RIP_LOCATION, arconfig.CONVERT_LOCATION ] #May want to add other cleanup locations
    for directory in dirsToCheck:
        filesToDelete = [ f for f in os.listdir(directory) ]
    
        for file_name in filesToDelete:
            dbWrite('Deleting ' + directory + file_name)
            os.remove(directory + file_name)
    
    return True
Exemplo n.º 4
0
def disk_already_checked(diskLabel, checkOnly=True):
    global sqlList
    
    if diskLabel in sqlList:
        return True
    else:
        
        if not checkOnly:
            dbWrite('Adding %s to database' %diskLabel)
            sqlList.append(diskLabel)
        
        return False
Exemplo n.º 5
0
 def __init__(self):
     #To add a new item:
     # create the self.ITEM_NAME
     # Assign a new ConfigItem()
     #  - the name
     #  - value = self.iniconf.get(<section>, <item>)
     #  - validvalues = [ a list of funcs or strings to check against ]
     #  - allowlist = Can this config item contain a list of values?
     # Add the section and item to the settings.ini
     self.valid = True
     self.iniconf = INIDataSource(PATH_TO_INI)
     self.MAKEMKVCON = ConfigItem('MAKEMKVCON',
                                  self.iniconf.get('default_config', 'makemkvcon'),
                                  validvalues=[os.path.exists])
     self.HANDBRAKE_CLI = ConfigItem('HANDBRAKE_CLI',
                                     self.iniconf.get('default_config', 'handbrake_cli'),    #tested with 0.9.9
                                     validvalues=[os.path.exists])
     self.RIP_LOCATION = ConfigItem('RIP_LOCATION',
                                    self.iniconf.get('default_config', 'movies_directory'),
                                    validvalues=[dirs_check_or_create])
     self.CONVERT_LOCATION = ConfigItem('CONVERT_LOCATION',
                                        self.iniconf.get('handbrake_config', 'output_directory'),  #TODO: Why are these two the same thing?
                                        validvalues=[dirs_check_or_create])
     self.OUTPUT_MOVIE_LOCATION = ConfigItem('OUTPUT_MOVIE_LOCATION',
                                             self.iniconf.get('handbrake_config', 'output_directory'),
                                             validvalues=[dirs_check_or_create])
     self.MOVIE_LOCATION = ConfigItem('MOVIE_LOCATION',
                                      [ self.RIP_LOCATION, self.OUTPUT_MOVIE_LOCATION ],
                                      validvalues=[os.path.isdir],
                                      allowlist=True)
     self.BLURAY_DEVICE = ConfigItem('BLURAY_DEVICE',
                                     self.iniconf.get('makemkv_config', 'optical_drive'),    #This should be the default location for your bluray device
                                     validvalues=[is_blueray_device])
     self.MAKEMKV_DISC_NUM = ConfigItem('MAKEMKV_DISC_NUM',
                                        self.iniconf.get('makemkv_config', 'optical_drive_num'),
                                        validvalues=[str.isdigit])
     tmplist = glob(os.path.join(HOME,r'.xbmc/userdata/Database/MyVideos*.db'))
     if len(tmplist) > 0:
         XBMC_MOVIE_DB = tmplist[0]
     else:
         dbWrite("Could not locate XBMC Movie DB (%s)" % os.path.join(HOME,r'.xbmc/userdata/Database/MyVideos*.db'), error=True)
         XBMC_MOVIE_DB = None
         self.valid = False
     self.XBMC_MOVIE_DB = ConfigItem('XBMC_MOVIE_DB',
                                     XBMC_MOVIE_DB,
                                     validvalues=[os.path.exists])  #TODO: Check to see if its a valid database
     self.HBRAKE_QUALITY = ConfigItem('HBRAKE_QUALITY',validvalues=['low','medium','high','perfect'])
Exemplo n.º 6
0
def program_watcher(): 
    dbWrite('Starting watcher')
    cd_tray_watcher_dbus()
    loop = gobject.MainLoop()
    loop.run()
Exemplo n.º 7
0
        return
    
    print "Converting"
    moviePath = convert_with_handbrake(mkvMoviePath)
    
    if not moviePath:
        print "Converting failed"
        return
    
    print "Moving"
    getMovieName = os.path.split(moviePath)[-1]
    outputMoviePath = re.sub('_', '.', getMovieName[:-8] + 'Cr0n1c' +getMovieName[-4:])
    shutil.move(moviePath, os.path.join(arconfig.OUTPUT_MOVIE_LOCATION, outputMoviePath))
    disk_already_checked(media['label'], False)
    print "Done with %s" % getMovieName 


def program_watcher(): 
    dbWrite('Starting watcher')
    cd_tray_watcher_dbus()
    loop = gobject.MainLoop()
    loop.run()

if __name__ == '__main__':
    arconfig = AutoRipperConfig()
    if arconfig.valid:
        program_watcher()
        cleanup_bad_jobs()
    else:
        dbWrite('settings.ini failed validation.  Please fix..', True)