예제 #1
0
 def get(self):
     from services import pocket, goodreads
     logging.debug("Running SyncReadables cron...")
     TS_KEY = 'pocket_last_timestamp'
     users = User.SyncActive(['pocket', 'goodreads'])
     user_put = []
     for user in users:
         # Pocket
         user_changes = False
         access_token = user.get_integration_prop('pocket_access_token')
         if access_token:
             success, readables, latest_timestamp = pocket.sync(user, access_token)
             logging.debug("Got %d readables from pocket" % len(readables))
             user.set_integration_prop(TS_KEY, latest_timestamp)
             user_changes = True
         success, readables = goodreads.get_books_on_shelf(user, shelf='currently-reading')
         logging.debug("Got %d readables from good reads" % len(readables))
         if user_changes:
             user_put.append(user)
     ndb.put_multi(user_put)
예제 #2
0
 def pocket_sync(self, d):
     '''
     Sync from pocket since last sync
     '''
     from services import pocket
     TS_KEY = 'pocket_last_timestamp'  # Seconds
     access_token = self.user.get_integration_prop('pocket_access_token')
     init_sync_since = tools.unixtime(datetime.now() - timedelta(days=7), ms=False)
     last_timestamp = self.user.get_integration_prop(TS_KEY, init_sync_since)
     readables = []
     if access_token:
         self.success, readables, latest_timestamp = pocket.sync(self.user, access_token, last_timestamp)
         self.user.set_integration_prop(TS_KEY, latest_timestamp)
         self.user.put()
         self.update_session_user(self.user)
     else:
         self.message = "Please link your Pocket account from the integrations page"
     self.set_response({
         'readables': [r.json() for r in readables]
     })
예제 #3
0
 def get(self):
     from services import pocket, goodreads
     logging.debug("Running SyncReadables cron...")
     TS_KEY = 'pocket_last_timestamp'
     users = User.SyncActive(['pocket', 'goodreads'])
     user_put = []
     for user in users:
         # Pocket
         user_changes = False
         access_token = user.get_integration_prop('pocket_access_token')
         if access_token:
             success, readables, latest_timestamp = pocket.sync(
                 user, access_token)
             logging.debug("Got %d readables from pocket" % len(readables))
             user.set_integration_prop(TS_KEY, latest_timestamp)
             user_changes = True
         success, readables = goodreads.get_books_on_shelf(
             user, shelf='currently-reading')
         logging.debug("Got %d readables from good reads" % len(readables))
         if user_changes:
             user_put.append(user)
     ndb.put_multi(user_put)