Example #1
0
    def parse_arguments(self, arguments):
        """--inject <TITLE> [URL] [ACCEPTED] [IMMORTAL]"""
        options = {}
        for index, arg in enumerate(arguments):
            if index == 0:
                options['entry'] = {'title': arg}
            elif index == 1:
                options['entry']['url'] = arg
            elif '=' in arg:
                field, val = arg.split('=')
                options['entry'][field] = yaml.load(val)
            elif index == 2:
                if arg.lower() == 'accept':
                    options['accept'] = True
                else:
                    options['accept'] = str_to_boolean(arg)
            elif index == 3:
                if arg.lower() == 'force':
                    options['entry']['immortal'] = True
                else:
                    options['entry']['immortal'] = str_to_boolean(arg)
            else:
                log.critical('Unknown --inject parameter %s' % arg)

        return options
Example #2
0
 def optik_series(option, opt, value, parser):
     """--inject <TITLE> [URL] [ACCEPTED] [IMMORTAL]"""
     #InputInject.options
     index = 0
     for arg in parser.rargs[:]:
         if arg.startswith('-'):
             break
         index += 1
         if index == 1:
             InputInject.options['entry'] = {'title': arg}
         elif index == 2:
             InputInject.options['entry']['url'] = arg
         elif '=' in arg:
             field, val = arg.split('=')
             InputInject.options['entry'][field] = yaml.load(val)
         elif index == 3:
             if arg.lower() == 'accept':
                 InputInject.options['accept'] = True
             else:
                 InputInject.options['accept'] = str_to_boolean(arg)
         elif index == 4:
             if arg.lower() == 'force':
                 InputInject.options['entry']['immortal'] = True
             else:
                 InputInject.options['entry']['immortal'] = str_to_boolean(arg)
         else:
             log.critical('Unknown --inject parameter %s' % arg)
Example #3
0
    def parse_arguments(self, arguments):
        """--inject <TITLE> [URL] [ACCEPTED] [IMMORTAL]"""
        options = {}
        for index, arg in enumerate(arguments):
            if index == 0:
                options['entry'] = {'title': arg}
            elif index == 1:
                options['entry']['url'] = arg
            elif '=' in arg:
                field, val = arg.split('=')
                options['entry'][field] = yaml.load(val)
            elif index == 2:
                if arg.lower() == 'accept':
                    options['accept'] = True
                else:
                    options['accept'] = str_to_boolean(arg)
            elif index == 3:
                if arg.lower() == 'force':
                    options['entry']['immortal'] = True
                else:
                    options['entry']['immortal'] = str_to_boolean(arg)
            else:
                log.critical('Unknown --inject parameter %s' % arg)

        return options
Example #4
0
    def optik_movie_queue(option, opt, value, parser):
        """Callback for Optik, parses --movie-queue options and populates movie_queue options value"""
        options = {}
        usage_error = OptionValueError("Usage: " + USAGE)
        if not parser.rargs:
            raise usage_error

        options["action"] = parser.rargs[0].lower()
        if options["action"] not in ("add", "del", "forget", "list", "downloaded", "clear"):
            raise usage_error

        if len(parser.rargs) == 1:
            if options["action"] not in ("list", "downloaded", "clear"):
                raise usage_error

        # 2, args is the minimum allowed (operation + item) for actions other than list
        if len(parser.rargs) >= 2:
            options["what"] = parser.rargs[1]

        # 3, quality
        if len(parser.rargs) >= 3:
            options["quality"] = parser.rargs[2]
        else:
            options["quality"] = "ANY"
            # TODO: Get default from config somehow?
            # why not use the quality user has queued most, ie option called 'auto' ?
            # and if none is queued default to something good like '720p bluray'

        # 4, force download
        if len(parser.rargs) >= 4:
            options["force"] = str_to_boolean(parser.rargs[3])
        else:
            options["force"] = True

        parser.values.movie_queue = options
Example #5
0
def archive_inject(option, opt, value, parser):
    """Option parser function"""

    if not parser.rargs:
        console('Usage: --archive-inject ID [IMMORTAL]')
        import sys
        sys.exit(1)

    parser.values.archive_inject_id = parser.rargs[0]

    if len(parser.rargs) >= 2:
        from flexget.utils.tools import str_to_boolean
        parser.values.archive_inject_immortal = str_to_boolean(parser.rargs[1])
Example #6
0
    def __call__(self, parser, namespace, values, option_string=None):
        options = namespace.movie_queue = {}

        # Assume 'list' if no action was given
        if not values:
            values = ['list']

        if values[0].lower() not in ACTIONS:
            raise ArgumentError(
                self,
                '`%s` is not a valid action.\nUsage: ' % values[0] + USAGE)
        options['action'] = values[0].lower()

        if len(values) == 1:
            if options['action'] not in ('list', 'downloaded', 'clear'):
                raise ArgumentError(
                    self, 'You must specify the movie.\nUsage: ' + USAGE)

        # 2, args is the minimum allowed (operation + item) for actions other than list
        if len(values) >= 2:
            options['what'] = values[1]

        # 3, quality
        if len(values) >= 3:
            try:
                options['quality'] = qualities.Requirements(values[2])
            except ValueError as e:
                raise ArgumentError(
                    self, '`%s` is an invalid quality requirement string: %s' %
                    (values[2], e.message))
        else:
            options['quality'] = qualities.Requirements('any')
            # TODO: Get default from config somehow?
            # why not use the quality user has queued most, ie option called 'auto' ?
            # and if none is queued default to something good like '720p bluray'

        # 4, force download
        if len(values) >= 4:
            options['force'] = str_to_boolean(values[3])
        else:
            options['force'] = True

        if len(values) > 4:
            raise ArgumentError(self,
                                'Too many arguments passed.\nUsage: ' + USAGE)
Example #7
0
    def __call__(self, parser, namespace, values, option_string=None):
        options = namespace.movie_queue = {}

        # Assume 'list' if no action was given
        if not values:
            values = ['list']

        if values[0].lower() not in ACTIONS:
            raise ArgumentError(self, '`%s` is not a valid action.\nUsage: ' % values[0] + USAGE)
        options['action'] = values[0].lower()

        if len(values) == 1:
            if options['action'] not in ('list', 'downloaded', 'clear'):
                raise ArgumentError(self, 'You must specify the movie.\nUsage: ' + USAGE)

        # 2, args is the minimum allowed (operation + item) for actions other than list
        if len(values) >= 2:
            options['what'] = values[1]

        # 3, quality
        if len(values) >= 3:
            try:
                options['quality'] = qualities.Requirements(values[2])
            except ValueError as e:
                raise ArgumentError(self, '`%s` is an invalid quality requirement string: %s' %
                                    (values[2], e.message))
        else:
            options['quality'] = qualities.Requirements('any')
            # TODO: Get default from config somehow?
            # why not use the quality user has queued most, ie option called 'auto' ?
            # and if none is queued default to something good like '720p bluray'

        # 4, force download
        if len(values) >= 4:
            options['force'] = str_to_boolean(values[3])
        else:
            options['force'] = True

        if len(values) > 4:
            raise ArgumentError(self, 'Too many arguments passed.\nUsage: ' + USAGE)
Example #8
0
    def optik_imdb_queue(option, opt, value, parser):
        """
        Callback for Optik
        --imdb-queue (add|del|list) [IMDB_URL|NAME] [quality]
        """
        options = {}
        usage_error = OptionValueError(
            'Usage: --movie-queue (add|del|list) [IMDB_URL|NAME] [QUALITY] [FORCE]'
        )
        if not parser.rargs:
            raise usage_error

        options['action'] = parser.rargs[0].lower()
        if options['action'] not in ['add', 'del', 'list']:
            raise usage_error

        if len(parser.rargs) == 1:
            if options['action'] != 'list':
                raise usage_error

        # 2 args is the minimum allowed (operation + item) for actions other than list
        if len(parser.rargs) >= 2:
            options['what'] = parser.rargs[1]

        # 3, quality
        if len(parser.rargs) >= 3:
            options['quality'] = parser.rargs[2]
        else:
            options[
                'quality'] = 'ANY'  # TODO: Get default from config somehow?

        # 4, force download
        if len(parser.rargs) >= 4:
            options['force'] = str_to_boolean(parser.rargs[3])
        else:
            options['force'] = True

        parser.values.movie_queue = options
Example #9
0
        # 2, args is the minimum allowed (operation + item) for actions other than list
        if len(values) >= 2:
            options['what'] = values[1]

        # 3, quality
        if len(values) >= 3:
            try:
                options['quality'] = qualities.Requirements(values[2])
            except ValueError, e:
                raise ArgumentError(self, '`%s` is an invalid quality requirement string: %s' %
                                       (values[2], e.message))
        else:
            options['quality'] = qualities.Requirements('any')
            # TODO: Get default from config somehow?
            # why not use the quality user has queued most, ie option called 'auto' ?
            # and if none is queued default to something good like '720p bluray'

        # 4, force download
        if len(values) >= 4:
            options['force'] = str_to_boolean(values[3])
        else:
            options['force'] = True

        if len(values) > 4:
            raise ArgumentError(self, 'Too many arguments passed.\nUsage: ' + USAGE)


register_plugin(MovieQueueManager, 'movie_queue_manager', builtin=True)
register_parser_option('--movie-queue', nargs='*', metavar=('ACTION', 'TITLE'),
                       action=MovieQueueAction, help=USAGE)