Exemplo n.º 1
0
def getDiscName(profiledict):
    makemkvpath = profiledict['makemkvpath']
    drive_id = int(profiledict['driveid'])
    command = '"{makemkvpath}" info list -r'.format(makemkvpath=makemkvpath)
    try:
        if sys.version_info[:2] == (2,7):
            output = subprocess.check_output(
                    command, stderr=subprocess.STDOUT, shell=True)
        elif sys.version_info[:2] == (2,6):
            output = utils.check_output(
                    command, stderr=subprocess.STDOUT, shell=True)
    except subprocess.CalledProcessError, e:
        output = e.output
Exemplo n.º 2
0
def main(argv):

    params = getParams(argv)

    defaultsettings = getDefaults()

    if 'profile' in params:
        profilenum = params['profile']
    else:
        profilenum = ''

    profiledict = getProfile(defaultsettings, profilenum)

    verifyProfile(profiledict)

    # Let's see if we just want to show the commands in a Kodi
    # notification. This is useful if you want to verify settings or
    # cron them up manually.
    if 'getcommand' in params:
        if params['getcommand'] == 'makemkvcon':
            utils.showOK(buildMakeMKVConCommand(profiledict))
            return 0
        elif params['getcommand'] == 'handbrakecli':
            utils.showOK(buildHandBrakeCLICommand(
                    profiledict, profiledict['tempfolder']))
            return 0

    utils.logDebug(profiledict)
    command = buildMakeMKVConCommand(profiledict)

    # TODO (??) user might want to specify a disc name in case the disc name
    # is shortened or changed in a way that metadata libraries don't understand 
    # what movie this is. many times though, the below will give you what you want
    discName = getDiscName(profiledict)

    # Beginning Rip. Command:
    utils.log('{beginning} {rip}. {commandstr}: {command}'.format(
            beginning = utils.getString(30070),
            rip = utils.getString(30027),
            commandstr = utils.getString(30071),
            command = command))
    try:
        if sys.version_info[:2] == (2,7):
            ripoutput = subprocess.check_output(
                    command, stderr=subprocess.STDOUT, shell=True)
        elif sys.version_info[:2] == (2,6):
            ripoutput = utils.check_output(
                    command, stderr=subprocess.STDOUT, shell=True)
    # For some reason, it seems that this always exits with a non-zero
    # status, so I'm just checking the output for success.
    except subprocess.CalledProcessError, e:
        if 'Copy complete.' in e.output:
            # We'll check for an error which denote using FAT32 for the temp
            # filesystem.
            fatcheck = re.search( r"The size of output file '(.*)' may reach "
                    "as much as (.*) while target filesystem has a file size "
                    "limit of (.*)", output)
            if fatcheck:
                # 30083 = Temp folder cannot handle large files
                # 30084 = This is usually caused by using FAT32 for storage.
                utils.exitFailed(utils.getstring(30083),
                        utils.getString(30083) + ' ' + utils.getString(30084))
            if ('The source file' in e.output and
                    ' is corrupt or invalid at offset' in e.output and
                    ', attempting to work around' in e.output):
                # 30087 = MakeMKV Had Trouble Reading the Disc. Try Cleaning it
                # if the Correct Title Wasn't Ripped.
                utils.log(utils.getString(30087))
        else:
            if 'Your temporary key has expired and was removed' in e.output:
                # 30074 = Your temporary MakeMKV key has expired. Please update
                # it
                utils.exitFailed(utils.getString(30074),
                        utils.getString(30074))
            if 'This application version is too old' in e.output:
                # 30075 = Your version of MakeMKV is too old. Please update it.
                utils.exitFailed(utils.getString(30075),
                        utils.getString(30075))
            if 'Failed to open disc' in e.output:
                # 30085 = Failed to Open Disc
                utils.exitFailed(utils.getString(30085),
                        utils.getString(30085))
            if ('The source file' in e.output and
                    ' is corrupt or invalid at offset' in e.output and
                    ', attempting to work around' in e.output):
                # 30086 = MakeMKV Had Trouble Reading the Disc. Try Cleaning it
                utils.exitFailed(utils.getString(30086),
                        utils.getString(30086))
            utils.exitFailed('MakeMKV {failed}'.format(
                    failed = utils.getString(30059)), e.output)
Exemplo n.º 3
0
def main(argv):

    params = getParams(argv)

    defaultsettings = getDefaults()

    if 'profile' in params:
        profilenum = params['profile']
    else:
        profilenum = ''

    profiledict = getProfile(defaultsettings, profilenum)

    verifyProfile(profiledict)

    # Let's see if we just want to show the commands in a Kodi
    # notification. This is useful if you want to verify settings or
    # cron them up manually.
    if 'getcommand' in params:
        if params['getcommand'] == 'makemkvcon':
            utils.showOK(buildMakeMKVConCommand(profiledict))
            return 0
        elif params['getcommand'] == 'handbrakecli':
            utils.showOK(buildHandBrakeCLICommand(
                    profiledict, profiledict['tempfolder']))
            return 0

    utils.logDebug(profiledict)
    command = buildMakeMKVConCommand(profiledict)

    # Beginning Rip. Command:
    utils.log('{beginning} {rip}. {commandstr}: {command}'.format(
            beginning = utils.getString(30070),
            rip = utils.getString(30027),
            commandstr = utils.getString(30071),
            command = command))
    try:
        if sys.version_info[:2] == (2,7):
            ripoutput = subprocess.check_output(
                    command, stderr=subprocess.STDOUT, shell=True)
        elif sys.version_info[:2] == (2,6):
            ripoutput = utils.check_output(
                    command, stderr=subprocess.STDOUT, shell=True)
    # For some reason, it seems that this always exits with a non-zero
    # status, so I'm just checking the output for success.
    except subprocess.CalledProcessError, e:
        if 'Copy complete.' in e.output:
            # We'll check for an error which denote using FAT32 for the temp
            # filesystem.
            fatcheck = re.search( r"The size of output file '(.*)' may reach "
                    "as much as (.*) while target filesystem has a file size "
                    "limit of (.*)", output)
            if fatcheck:
                # 30083 = Temp folder cannot handle large files
                # 30084 = This is usually caused by using FAT32 for storage.
                utils.exitFailed(utils.getstring(30083),
                        utils.getString(30083) + ' ' + utils.getString(30084))
            if ('The source file' in e.output and
                    ' is corrupt or invalid at offset' in e.output and
                    ', attempting to work around' in e.output):
                # 30087 = MakeMKV Had Trouble Reading the Disc. Try Cleaning it
                # if the Correct Title Wasn't Ripped.
                utils.log(utils.getString(30087))
        else:
            if 'Your temporary key has expired and was removed' in e.output:
                # 30074 = Your temporary MakeMKV key has expired. Please update
                # it
                utils.exitFailed(utils.getString(30074),
                        utils.getString(30074))
            if 'This application version is too old' in e.output:
                # 30075 = Your version of MakeMKV is too old. Please update it.
                utils.exitFailed(utils.getString(30075),
                        utils.getString(30075))
            if 'Failed to open disc' in e.output:
                # 30085 = Failed to Open Disc
                utils.exitFailed(utils.getString(30085),
                        utils.getString(30085))
            if ('The source file' in e.output and
                    ' is corrupt or invalid at offset' in e.output and
                    ', attempting to work around' in e.output):
                # 30086 = MakeMKV Had Trouble Reading the Disc. Try Cleaning it
                utils.exitFailed(utils.getString(30086),
                        utils.getString(30086))
            utils.exitFailed('MakeMKV {failed}'.format(
                    failed = utils.getString(30059)), e.output)
Exemplo n.º 4
0
    filestoencode = glob.glob(os.path.join(profiledict['tempfolder'], '*.mkv'))
    for f in filestoencode:
        # makemkvcon doesn't allow to customize the output filename
        # but handbrake does, so pass it in to customize output filename option
        command = buildHandBrakeCLICommand(profiledict, f, discName)
        utils.log('{beginning} {encode}. {commandstr}: {command}'.format(
                beginning = utils.getString(30070),
                encode = utils.getString(30028),
                commandstr = utils.getString(30071),
                command = command))
        try:
            if sys.version_info[:2] == (2,7):
                encodeoutput = subprocess.check_output(
                        command, stderr=subprocess.STDOUT, shell=True)
            elif sys.version_info[:2] == (2,6):
                encodeoutput = utils.check_output(
                        command, stderr=subprocess.STDOUT, shell=True)
        except subprocess.CalledProcessError, e:
            if 'Encode done!' not in e.output:
                utils.exitFailed('HandBrake {failed}'.format(
                        failed = utils.getString(30059)), e.output)
        utils.logDebug(encodeoutput)
        if profiledict['cleanuptempdir'] == 'true':
            os.remove(f)

    # 30028 == Encode
    if profiledict['ejectafter'] == utils.getStringLow(30028):
        xbmc.executebuiltin('EjectTray()')

    # 30065 == Notification
    if profiledict['notifyafterencode'] == utils.getStringLow(30065):
        utils.showNotification('{encode} {completedsuccessfully}'.format(
Exemplo n.º 5
0
        return 0

    filestoencode = glob.glob(os.path.join(profiledict['tempfolder'], '*.mkv'))
    for f in filestoencode:
        command = buildHandBrakeCLICommand(profiledict, f)
        utils.log('{beginning} {encode}. {commandstr}: {command}'.format(
                beginning = utils.getString(30070),
                encode = utils.getString(30028),
                commandstr = utils.getString(30071),
                command = command))
        try:
            if sys.version_info[:2] == (2,7):
                encodeoutput = subprocess.check_output(
                        command, stderr=subprocess.STDOUT, shell=True)
            elif sys.version_info[:2] == (2,6):
                encodeoutput = utils.check_output(
                        command, stderr=subprocess.STDOUT, shell=True)
        except subprocess.CalledProcessError, e:
            if 'Encode done!' not in e.output:
                utils.exitFailed('HandBrake {failed}'.format(
                        failed = utils.getString(30059)), e.output)
        utils.logDebug(encodeoutput)
        if profiledict['cleanuptempdir'] == 'true':
            os.remove(f)

    # 30028 == Encode
    if profiledict['ejectafter'] == utils.getStringLow(30028):
        xbmc.executebuiltin('EjectTray()')

    # 30065 == Notification
    if profiledict['notifyafterencode'] == utils.getStringLow(30065):
        utils.showNotification('{encode} {completedsuccessfully}'.format(