Exemplo n.º 1
0
    def cli_main(self, argv):
        from calibre.utils.config import prefs as calibre_prefs
        from optparse import OptionParser

        from calibre_plugins.beam_ebooks_downloader.prefs import PrefsFacade

        my_db = db(path=None, read_only=False)

        # print 'Database is (%s)' % (prefs._get_db())
        print 'Database is (%s)' % (my_db)

        prefs = PrefsFacade(my_db)

        print 'My Prefs are (%s)' % (prefs)
        print '    methods are (%s)' % (dir(prefs))
        print '    library id is (%s)' % (prefs.get_library_uuid())

        print 'Calibre Prefs are (%s)' % (calibre_prefs)
        print '    methods are (%s)' % (dir(calibre_prefs))

        downloader = BeamEbooksDownloader(prefs, self.version, caller=self)

        # Loop over all accounts until we have support for selection
        for account_id in prefs[prefs.ACCOUNTS]:
            account = prefs[prefs.ACCOUNTS][account_id]
            account[prefs.ACCOUNT_ID] = account_id
            print "Account: '%s'" % account

            if account[prefs.ENABLED]:
                downloader.login(account)

                if downloader.successful_login == False:
                    print "Failed to log in..."
                else:
                    print "Parsing document tree now..."
                    # Temporarily...
                    # downloader.recursive_descent(prefs[prefs.URLBASE] + "/aldiko/bibuebersicht.php5?user="******"/aldiko/pakete.php5?user="******"/kunden/abos.php5")
                    downloader.download_ebooks()

        pass