def test_subscribe_unsubscribe(self): ca = ClientAuthMethod(username,password) reader = GoogleReader(ca) slashdot = 'feed/http://rss.slashdot.org/Slashdot/slashdot' #unsubscribe always return true; revert feedlist state self.assertTrue(reader.unsubscribe(slashdot)) # now subscribe self.assertTrue(reader.subscribe(slashdot)) # wait for server to update time.sleep(1) reader.buildSubscriptionList() # test subscribe successful self.assertIn(slashdot, [x.id for x in reader.getSubscriptionList()])
def test_subscribe_unsubscribe(self): ca = ClientAuthMethod(username, password) reader = GoogleReader(ca) slashdot = 'feed/http://rss.slashdot.org/Slashdot/slashdot' #unsubscribe always return true; revert feedlist state self.assertTrue(reader.unsubscribe(slashdot)) # now subscribe self.assertTrue(reader.subscribe(slashdot)) # wait for server to update time.sleep(1) reader.buildSubscriptionList() # test subscribe successful self.assertIn(slashdot, [x.id for x in reader.getSubscriptionList()])
def test_oauth_subscribe(self): auth = OAuth2Method(client_id, client_secret) auth.setRedirectUri(redirect_url) url = auth.buildAuthUrl() token = automated_oauth2_approval(url) auth.code = token auth.setAccessToken() auth.setActionToken() reader = GoogleReader(auth) slashdot = 'feed/http://rss.slashdot.org/Slashdot/slashdot' #unsubscribe always return true; revert feedlist state self.assertTrue(reader.unsubscribe(slashdot)) # now subscribe self.assertTrue(reader.subscribe(slashdot)) # wait for server to update import time time.sleep(1) reader.buildSubscriptionList() # test subscribe successful self.assertIn(slashdot, [x.id for x in reader.getSubscriptionList()])
def main(): if len(sys.argv) <= 1 or len(sys.argv) > 3: print("Usage: %s username [password]" % (sys.argv[0])) return 1 username = sys.argv[1] if len(sys.argv) == 2: sys.stderr.write('Password for %s: ' % username) password = raw_input() else: password = sys.argv[2] auth = ClientAuthMethod(username, password) reader = GoogleReader(auth) root = ET.Element('opml') head = ET.SubElement(root, 'head') ET.SubElement(head, 'title').text = \ '%s subscriptions in Google Reader' % username body = ET.SubElement(root, 'body') category_els = {} reader.buildSubscriptionList() for feed in reader.getSubscriptionList(): if feed.getCategories(): for category in feed.getCategories(): # Create category element if not category.id in category_els: category_el = ET.SubElement(body, 'outline') category_el.set('text', category.label) category_el.set('title', category.label) category_els[category.id] = category_el make_feed_el(feed, category_els[category.id]) else: make_feed_el(feed, body) tree = ET.ElementTree(root) tree.write(sys.stdout, xml_declaration=True)
def test_oauth_subscribe(self): auth = OAuth2Method(client_id, client_secret) auth.setRedirectUri(redirect_url) url = auth.buildAuthUrl() token = automated_oauth2_approval(url) auth.code = token auth.setAccessToken() auth.setActionToken() reader = GoogleReader(auth) slashdot = 'feed/http://rss.slashdot.org/Slashdot/slashdot' #unsubscribe always return true; revert feedlist state self.assertTrue(reader.unsubscribe(slashdot)) # now subscribe self.assertTrue(reader.subscribe(slashdot)) # wait for server to update import time time.sleep(1) reader.buildSubscriptionList() # test subscribe successful self.assertIn(slashdot, [x.id for x in reader.getSubscriptionList()])
def main(): if len(sys.argv) <= 1 or len(sys.argv) > 3: print ("Usage: %s username [password]" % (sys.argv[0])) return 1 username = sys.argv[1] if len(sys.argv) == 2: sys.stderr.write("Password for %s: " % username) password = raw_input() else: password = sys.argv[2] auth = ClientAuthMethod(username, password) reader = GoogleReader(auth) root = ET.Element("opml") head = ET.SubElement(root, "head") ET.SubElement(head, "title").text = "%s subscriptions in Google Reader" % username body = ET.SubElement(root, "body") category_els = {} reader.buildSubscriptionList() for feed in reader.getSubscriptionList(): if feed.getCategories(): for category in feed.getCategories(): # Create category element if not category.id in category_els: category_el = ET.SubElement(body, "outline") category_el.set("text", category.label) category_el.set("title", category.label) category_els[category.id] = category_el make_feed_el(feed, category_els[category.id]) else: make_feed_el(feed, body) tree = ET.ElementTree(root) tree.write(sys.stdout, xml_declaration=True)
logging.warning(sys.exc_info()[0]) print "Continuing..." sys.exc_clear() loadMoreUntilSuccessful(subscription, load) couch = couchdb.Server('http://localhost:5984') try: db = couch[db_name] except Exception: db = couch.create(db_name) auth = ClientAuthMethod(username, password) reader = GoogleReader(auth) ll = 100 reader.buildSubscriptionList() l = reader.getSubscriptionList() for li in l: print li.title.encode('ascii', 'xmlcharrefreplace') loadUntilSuccessful(li, ll) while li.lastLoadLength > 0: bulk_upload = [] for i in li.getItems(): doc = {} doc = i.data if len(li.categories) > 0: doc["label"] = li.categories[0].label bulk_upload.append(doc) db.update(bulk_upload) loadMoreUntilSuccessful(li, ll)