Esempio n. 1
0
#!/usr/bin/env python

# the script connects to daemonology and parses the links of the latest day
# and sends them to Readability
import os, sys, readability
from modules import parser

# get the API Keys
keysFile = "data/apikeys.json"
keys = parser.getSettings(keysFile)
if keys == False:
	print ("No developer keys existing in apikeys.json. Please contact Readability to get your own developer keys.")
	sys.exit(0)

# load settings
settingsFile = "data/settings.json"
settings = parser.getSettings(settingsFile) 
if settings == False or not settings['token1'] or not settings['token2']:
	print ("No Readability credentials existing. Please run ./setup.py")
	sys.exit(0)	

# do a connection test with the tokens
print ("Connecting to Readability to verify your token...")
token = (settings["token1"], settings["token2"])
connected = False
try:
	rdd = readability.oauth(keys["consumerKey"], keys["consumerSecret"], token=token)
	me = rdd.get_me()
	connected = True
except:
	pass
Esempio n. 2
0
# setup asks for the input of user credentials 
# to set the XAuth tokens

import os, sys, readability
from modules import parser

# ask for developer credentials
print ("***************************")
print	("Welcome to HN2Readability. ")
print ("***************************")
print ("Please enter your Readability developer API credentials.")

# get the API Keys
api_file = "data/apikeys.json"
keys = parser.getSettings(api_file)
if keys == False or not keys['consumerKey'] or not keys['consumerSecret']:
		# input of key and secret
		inp_key= "";
		while len(inp_key) < 2:
			inp_key = raw_input("Your Readability developer API key: ")
			
		inp_secret = "";
		while len(inp_secret) < 2:
			inp_secret = raw_input("Your Readability developer API secret: ")
	
		keys = {}
		keys["consumerKey"] = inp_key
		keys["consumerSecret"] = inp_secret
 	
		parser.saveSettings(keys, api_file)