Exemple #1
0
    def start(self):
        """
        Initializes the engine
        
        Creates an Engine object and starts it.
        """
        print 'Initializing engine...'
        self.engine = Engine(self.account, self.messagehandler)
        self.engine.start()

        # Start with default filter selected
        self.filter_num = self.engine.mediainfo['statuses'][0]
        self.prompt = "{0} {1}> ".format(
            self.engine.api_info['name'],
            self.engine.mediainfo['statuses_dict'][self.filter_num])
Exemple #2
0
 def start(self):
     """
     Initializes the engine
     
     Creates an Engine object and starts it.
     """
     print 'Initializing engine...'
     self.engine = Engine(self.account, self.messagehandler)
     self.engine.start()
     
     # Start with default filter selected
     self.filter_num = self.engine.mediainfo['statuses'][0]
     self._update_prompt()
Exemple #3
0
 def start(self):
     """
     Initializes the engine
     
     Creates an Engine object and starts it.
     """
     print 'Initializing engine...'
     self.engine = Engine(self.account, self.messagehandler)
     self.engine.start()
     
     # Start with default filter selected
     self.filter_num = self.engine.mediainfo['statuses'][0]
     self.prompt = "{0} {1}> ".format(self.engine.api_info['name'], self.engine.mediainfo['statuses_dict'][self.filter_num])
Exemple #4
0
class wmal_cmd(cmd.Cmd):
    """
    Main program, inherits from the useful Cmd class
    for interactive console
    """
    engine = None
    filter_num = 1
    sort = 'title'
    completekey = 'Tab'
    cmdqueue = []
    stdout = sys.stdout
    
    __re_cmd = re.compile(r"([-\w]+|\".*\")")   # Args parser
    
    def __init__(self):
        print 'wMAL v'+utils.VERSION+'  Copyright (C) 2012  z411'
        print 'This program comes with ABSOLUTELY NO WARRANTY; for details type `info\''
        print 'This is free software, and you are welcome to redistribute it'
        print 'under certain conditions; see the file COPYING for details.'
        print

        self.accountman = wmal_accounts()
        self.account = self.accountman.select_account()

    def _update_prompt(self):
        self.prompt = "{0}({1}) {2}> ".format(self.engine.api_info['name'], self.engine.api_info['mediatype'], self.engine.mediainfo['statuses_dict'][self.filter_num])

    def start(self):
        """
        Initializes the engine
        
        Creates an Engine object and starts it.
        """
        print 'Initializing engine...'
        self.engine = Engine(self.account, self.messagehandler)
        self.engine.start()
        
        # Start with default filter selected
        self.filter_num = self.engine.mediainfo['statuses'][0]
        self._update_prompt()
    
    def do_account(self, arg):
        """
        account - Switch to a different account

        Usage: account
        """

        self.account = self.accountman.select_account()
        self.engine.reload(account=self.account)
    
    def do_filter(self, arg):
        """
        filter - Changes the filtering of list by status; call with no arguments to see available filters
        
        Usage: filter [filter type]
        """
        # Query the engine for the available statuses
        # that the user can choose
        
        if arg:
            try:
                args = self.parse_args(arg)
                self.filter_num = self._guess_status(args[0].lower())
                self._update_prompt()
            except KeyError:
                print "Invalid filter."
        else:
            print "Available filters: %s" % ', '.join( v.lower().replace(' ', '') for v in self.engine.mediainfo['statuses_dict'].values() )
    
    def do_sort(self, arg):
        """
        sort - Change sort
        
        Usage: sort <sort type>
        Available types: id, title, my_progress, total, my_score
        """
        sorts = ('id', 'title', 'my_progress', 'total', 'my_score')
        if arg in sorts:
            self.sort = arg
        else:
            print "Invalid sort."
    
    def do_mediatype(self, arg):
        """
        mediatype - Reloads engine with different mediatype; call with no arguments to see supported mediatypes
        
        Usage: mediatype [mediatype]
        """
        if arg:
            args = self.parse_args(arg)
            if args[0] in self.engine.api_info['supported_mediatypes']:
                self.engine.reload(mediatype=args[0])
            
                # Start with default filter selected
                self.filter_num = self.engine.mediainfo['statuses'][0]
                self.prompt = "{0}({1}) {1}> ".format(self.engine.api_info['name'], self.engine.api_info['mediatype'], self.engine.mediainfo['statuses_dict'][self.filter_num])
                self._update_prompt()
            else:
                print "Invalid mediatype."
        else:
            print "Supported mediatypes: %s" % ', '.join(self.engine.api_info['supported_mediatypes'])
        
    def do_list(self, arg):
        """
        list - Lists all shows available as a nice formatted list.
        """
        # Queries the engine for a list and sorts it
        # using the current sort
        showlist = self.engine.filter_list(self.filter_num)
        sortedlist = sorted(showlist, key=itemgetter(self.sort)) 
        self._make_list(sortedlist)
    
    def do_info(self, arg):
        if(arg):
            try:
                show = self.engine.get_show_info_title(arg)
                details = self.engine.get_show_details(show)
            except utils.wmalError, e:
                self.display_error(e)
                return

            print "Title: %s" % details['title']
            for line in details['extra']:
                print "%s: %s" % line
        else:
Exemple #5
0
class wmal_cmd(cmd.Cmd):
    """
    Main program, inherits from the useful Cmd class
    for interactive console
    """
    engine = None
    filter_num = 1
    sort = 'title'
    completekey = 'Tab'
    cmdqueue = []
    stdout = sys.stdout
    
    __re_cmd = re.compile(r"([-\w]+|\".*\")")   # Args parser
    
    def __init__(self):
        print 'wMAL v'+utils.VERSION+'  Copyright (C) 2012  z411'
        print 'This program comes with ABSOLUTELY NO WARRANTY; for details type `info\''
        print 'This is free software, and you are welcome to redistribute it'
        print 'under certain conditions; see the file COPYING for details.'
        print

        self.accountman = wmal_accounts()
        self.account = self.accountman.select_account()

    def start(self):
        """
        Initializes the engine
        
        Creates an Engine object and starts it.
        """
        print 'Initializing engine...'
        self.engine = Engine(self.account, self.messagehandler)
        self.engine.start()
        
        # Start with default filter selected
        self.filter_num = self.engine.mediainfo['statuses'][0]
        self.prompt = "{0} {1}> ".format(self.engine.api_info['name'], self.engine.mediainfo['statuses_dict'][self.filter_num])
    
    def do_filter(self, arg):
        """
        filter - Changes the filtering of list by status
        
        Usage: filter <filter type>
        """
        # Query the engine for the available statuses
        # that the user can choose
        
        if arg:
            try:
                self.filter_num = self._guess_status(arg)
                self.prompt = "{0} {1}> ".format(self.engine.api_info['name'], self.engine.mediainfo['statuses_dict'][self.filter_num])
            except KeyError:
                print "Invalid filter."
        else:
            print "Missing arguments."
    
    def do_sort(self, arg):
        """
        sort - Change sort
        
        Usage: sort <sort type>
        Available types: id, title, my_progress, episodes
        """
        sorts = ('id', 'title', 'my_progress', 'total')
        if arg in sorts:
            self.sort = arg
        else:
            print "Invalid sort."
    
    def do_reload(self, arg):
        """
        reload - Reloads engine with specifid API and mediatype
        
        Usage: reload <api> <mediatype>
        """
        if arg:
            args = self.parse_args(arg)
            (api, mediatype) = (args[0], args[1])
            self.engine.reload(api=api, mediatype=mediatype)
            
            # Start with default filter selected
            self.filter_num = self.engine.mediainfo['statuses'][0]
            self.prompt = "{0} {1}> ".format(self.engine.api_info['name'], self.engine.mediainfo['statuses_dict'][self.filter_num])
        
    def do_list(self, arg):
        """
        list - Lists all shows available as a nice formatted list.
        """
        # Queries the engine for a list and sorts it
        # using the current sort
        showlist = self.engine.filter_list(self.filter_num)
        sortedlist = sorted(showlist, key=itemgetter(self.sort)) 
        self._make_list(sortedlist)
    
    def do_info(self, arg):
        if(arg):
            show = self.engine.get_show_info_title(arg)
            details = self.engine.get_show_details(show)
            print "Title: %s" % details['title']
            for line in details['extra']:
                print "%s: %s" % line
        else:
            print "Missing arguments."
    
    def do_search(self, arg):
        """
        search - Does a regex search on shows and lists the matches.
        
        Usage: search <pattern>
        
        """
        if(arg):
            showlist = self.engine.regex_list(arg)
            sortedlist = sorted(showlist, key=itemgetter(self.sort)) 
            self._make_list(sortedlist)
        else:
            print "Missing arguments."
    
    def do_add(self, arg):
        """
        add - Searches for a show and adds it
        
        Usage: add <pattern>
        
        """
        if(arg):
            entries = self.engine.search(arg)
            for i, entry in enumerate(entries, start=1):
                print "%d: (%s) %s" % (i, entry['type'], entry['title'])
            do_update = raw_input("Choose show to add (blank to cancel): ")
            if do_update != '':
                try:
                    show = entries[int(do_update)-1]
                except ValueError:
                    print "Choice must be numeric."
                    return
                except IndexError:
                    print "Invalid show."
                    return
                
                # Tell the engine to add the show
                try:
                    self.engine.add_show(show)
                except utils.wmalError, e:
                    self.display_error(e)
Exemple #6
0
class wmal_cmd(cmd.Cmd):
    """
    Main program, inherits from the useful Cmd class
    for interactive console
    """
    engine = None
    filter_num = 1
    sort = 'title'
    completekey = 'Tab'
    cmdqueue = []
    stdout = sys.stdout

    __re_cmd = re.compile(r"([-\w]+|\".*\")")  # Args parser

    def __init__(self):
        print 'wMAL ' + VERSION + '  Copyright (C) 2012  z411'
        print 'This program comes with ABSOLUTELY NO WARRANTY; for details type `info\''
        print 'This is free software, and you are welcome to redistribute it'
        print 'under certain conditions; see the file COPYING for details.'
        print

        self.accountman = wmal_accounts()
        self.account = self.accountman.select_account()

    def start(self):
        """
        Initializes the engine
        
        Creates an Engine object and starts it.
        """
        print 'Initializing engine...'
        self.engine = Engine(self.account, self.messagehandler)
        self.engine.start()

        # Start with default filter selected
        self.filter_num = self.engine.mediainfo['statuses'][0]
        self.prompt = "{0} {1}> ".format(
            self.engine.api_info['name'],
            self.engine.mediainfo['statuses_dict'][self.filter_num])

    def do_filter(self, arg):
        """
        filter - Changes the filtering of list by status
        
        Usage: filter <filter type>
        """
        # Query the engine for the available statuses
        # that the user can choose

        if arg:
            try:
                self.filter_num = self._guess_status(arg)
                self.prompt = "{0} {1}> ".format(
                    self.engine.api_info['name'],
                    self.engine.mediainfo['statuses_dict'][self.filter_num])
            except KeyError:
                print "Invalid filter."
        else:
            print "Missing arguments."

    def do_sort(self, arg):
        """
        sort - Change sort
        
        Usage: sort <sort type>
        Available types: id, title, my_progress, episodes
        """
        sorts = ('id', 'title', 'my_progress', 'total')
        if arg in sorts:
            self.sort = arg
        else:
            print "Invalid sort."

    def do_reload(self, arg):
        """
        reload - Reloads engine with specifid API and mediatype
        
        Usage: reload <api> <mediatype>
        """
        if arg:
            args = self.parse_args(arg)
            (api, mediatype) = (args[0], args[1])
            self.engine.reload(api=api, mediatype=mediatype)

            # Start with default filter selected
            self.filter_num = self.engine.mediainfo['statuses'][0]
            self.prompt = "{0} {1}> ".format(
                self.engine.api_info['name'],
                self.engine.mediainfo['statuses_dict'][self.filter_num])

    def do_list(self, arg):
        """
        list - Lists all shows available as a nice formatted list.
        """
        # Queries the engine for a list and sorts it
        # using the current sort
        showlist = self.engine.filter_list(self.filter_num)
        sortedlist = sorted(showlist, key=itemgetter(self.sort))
        self._make_list(sortedlist)

    def do_info(self, arg):
        if (arg):
            show = self.engine.get_show_info(arg)
            details = self.engine.get_show_details(show)
            print "Title: %s" % details['title']
            for line in details['extra']:
                print "%s: %s" % line
        else:
            print "Missing arguments."

    def do_search(self, arg):
        """
        search - Does a regex search on shows and lists the matches.
        
        Usage: search <pattern>
        
        """
        if (arg):
            showlist = self.engine.regex_list(arg)
            sortedlist = sorted(showlist, key=itemgetter(self.sort))
            self._make_list(sortedlist)
        else:
            print "Missing arguments."

    def do_add(self, arg):
        """
        add - Searches for a show and adds it
        
        Usage: add <pattern>
        
        """
        if (arg):
            entries = self.engine.search(arg)
            for i, entry in enumerate(entries, start=1):
                print "%d: (%s) %s" % (i, entry['type'], entry['title'])
            do_update = raw_input("Choose show to add (blank to cancel): ")
            if do_update != '':
                try:
                    show = entries[int(do_update) - 1]
                except ValueError:
                    print "Choice must be numeric."
                    return
                except IndexError:
                    print "Invalid show."
                    return

                # Tell the engine to add the show
                try:
                    self.engine.add_show(show)
                except utils.wmalError, e:
                    self.display_error(e)