def do_obtain_new_books(cpus, account, notification=lambda x, y:x): print "do_obtain_new_books in jobs.py" print "Account is: %s" % (account) # This server is an arbitrary_n job, so there is a notifier available. # Set the % complete to a small number to avoid the 'unavailable' indicator notification(0.01, "Starting up...") from calibre.library import db from calibre.utils.config import prefs prefs.refresh() db = db(read_only=False) print "DB is: %s" % (db) prefs = PrefsFacade(db) print "Prefs are: %s" % (prefs) print "Library id is (%s)" % (prefs.get_library_uuid()) reporter = ConsoleReporter() downloader = BeamEbooksDownloader(prefs, caller = reporter) print "-- LALA -- Downloader is: %s" % (downloader) if account[prefs.ENABLED]: downloader.login(account) if downloader.successful_login == False: notification(1.00, "Failed to log in...") else: notification(0.05, "Parsing document tree now...") downloadable_ebooks = downloader.recursive_descent(norms(prefs[prefs.URLBASE])) notification(0.50, "Loaded OPDS pages") reporter.notify(downloadable_ebooks) # # Now, download the obtained ebooks... notification(1.00, "Done...") adder = EBookAdder(prefs, "beam-ebooks") adder.load_books() new_ebooks = [] for entry in downloadable_ebooks: beamebooks_id = entry['id'] book = adder.books_of_this_shop.get(beamebooks_id) if book is None: new_ebooks.append(entry) result = (new_ebooks) return result
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