def init(): # Read credentials from Credentials.ini file configParser = ConfigParser.RawConfigParser() configParser.read('Credentials.ini') key = configParser.get('Instapaper', 'INSTAPAPER_KEY') secret = configParser.get('Instapaper', 'INSTAPAPER_SECRET') login = configParser.get('Login', 'INSTAPAPER_LOGIN') password = configParser.get('Login', 'INSTAPAPER_PASSWORD') # Create instance of Instapaper using the OAth credentials instapaper = Instapaper(key, secret) # Login with user and password instapaper.login(login, password) return instapaper
def generate_output(self, writer): # Using https://github.com/rsgalloway/instapaper # Alternatives: # - https://github.com/mrtazz/InstapaperLibrary # - https://github.com/mdorn/pyinstapaper from instapaper import Instapaper try: ip = Instapaper(self.settings["INSTAPAPER_KEY"], self.settings["INSTAPAPER_SECRET"]) ip.login(self.settings["INSTAPAPER_USER"], self.settings["INSTAPAPER_PASSWORD"]) # DEBUG simply print the list of folders content = repr(ip.folders()) # TODO retrieve the contents of the 'archive' folders # TODO sort and group bookmarks # TODO format bookmarks except Exception: return template = self.get_template("page") page = { "title": "Instapaper", "content": content, } writer.write_file( "instapaper_list.html", template, self.context, page=page, relative_urls=self.settings["RELATIVE_URLS"], )
if ( blogger_email == "" or blogger_password == "" or insta_user == "" or insta_password == "" or mailchimp_user == "" or mailchimp_password == "" ): print ( "python NewLetterUtil.py --blogger_email [blogger_email] --blogger_password [blogger_password] --insta_user [insta_user] --insta_password [insta_password] --mailchimp_user [mailchimp_user] --mailchimp_password [mailchimp_password] --postdir [postdir] --create_newsletter [create_newsletter] " ) sys.exit(2) dumpFile = "instapaper.pickle" ip = Instapaper(dumpfile, insta_user, insta_password) cache = BookMarkCache(dumpFile) bookMarkList = ip.getAllBookMarks() print bookMarkList for b in bookMarkList: bmk = BookMark(b) cache[bmk] = {"bookmark_id": b["bookmark_id"], "hashval": b["hashval"]} entry = cache.get(b["bookmark_id"]) ip.run() ip.save_pickle("instapaper.pickle") url = "http://localhost/newsletter.php" webbrowser.open_new(url)
def index(self, conf): i = Instapaper(conf['instapaper_key'], conf['instapaper_secret']) i.login(conf['username'], conf['password']) for bookmark in i.bookmarks(limit=99999): yield InstapaperBookmark(bookmark)
self.description = description self.url= url self.title = title self.category = category blg.doBloggerActivity( self.title.replace("\"", "") ,self.description.replace("\"", "") + ' ' + urllib.unquote_plus(self.url).replace("\"", "") , 'Kabir Seth' ,self.category ) twt.sendTweet( self.title.replace("\"", "") + ' ' + self.description.replace("\"", "") + ' ' + urllib.unquote_plus(self.url).replace("\"", "")) , 'Kabir Seth' , self.category def __str__(self): return 'BookMark ID : %s, Bookmark Hashval :%s , desc : %s , url: %s ,Title : %s , Category : %s ' % (self.bookmark_id, self.description , self.url , self.title , self.category, self.hashval) def __getitem__(self, bookmark_id): try : return[{ 'selected' : False , 'bookmark_id' : entry['bookmark_id'] , 'category' : entry['category'] , 'hashval' : entry['hashval'] , 'description' : entry['description'] , 'title' : entry['title'] , 'url' : entry['url'] } for entry in cache.listBookMark if entry['bookmark_id'] == bookmark_id ][0] except : return None out =[] ip = Instapaper('instapaper', insta_user ,insta_password) listBookMark = ip.getAllBookMarks() print listBookMark print len(listBookMark) try: import simplejson as json except: import json out =[{'selected' : False , 'bookmark_id' : entry['bookmark_id'] or "" , 'category' : entry['category'] or "" , 'hashval' : entry['hashval'] , 'description' : entry['description'] or "" , 'title' : entry['title'] or "" , 'url' : entry['url'] or "" } for entry in listBookMark ] print listBookMark print json.dumps(out) templatepath ="c:/xampp/htdocs/newsletter" html = file('%s/preheader.htm'%templatepath, 'r').read() html = html + file('%s/header.htm'%templatepath, 'r').read() html = html + """<table width="500" class='out' border="1" data-dynamic="%s">""" % json.dumps(out)
mailchimp_password = a if o == "--create_newsletter": create_newsletter = a if verbose > 0: print AGENTNAME, "version", __version__ print " Blogger Email : %s \n Blogger Password : %s \n Insta User : %s \n Insta password %s \n Mailchimp User : %s \n Mailchimp password : %s \n Create_NewsLetter : %s \n" % ( blogger_email, blogger_password, insta_user, insta_password, mailchimp_user, mailchimp_password, create_newsletter) if blogger_email == '' or blogger_password == '' or insta_user == '' or insta_password == '' or mailchimp_user == '' or mailchimp_password == '': print( 'python NewLetterUtil.py --blogger_email [blogger_email] --blogger_password [blogger_password] --insta_user [insta_user] --insta_password [insta_password] --mailchimp_user [mailchimp_user] --mailchimp_password [mailchimp_password] --postdir [postdir] --create_newsletter [create_newsletter] ' ) sys.exit(2) dumpFile = "instapaper.pickle" ip = Instapaper(dumpfile, insta_user, insta_password) cache = BookMarkCache(dumpFile) bookMarkList = ip.getAllBookMarks() print bookMarkList for b in bookMarkList: bmk = BookMark(b) cache[bmk] = {'bookmark_id': b['bookmark_id'], 'hashval': b['hashval']} entry = cache.get(b['bookmark_id']) ip.run() ip.save_pickle('instapaper.pickle') url = 'http://localhost/newsletter.php' webbrowser.open_new(url)