Пример #1
0
def main():
	try:
		shortflags = 'h'
		longflags = ['help', 'consumer_key=', 'access_token=']
		opts, args = getopt.gnu_getopt(sys.argv[1:], shortflags, longflags)
	except getopt.GetoptError:
		print_usage_and_exit()

	consumer_key = None
	access_token = None

	for o, a in opts:
		if o in ('-h', '--help'):
			print_usage_and_exit()
		if o in ('--consumer_key'):
			consumer_key = a
		if o in ('--access_token'):
			access_token = a

	url = ' '.join(args)
	if not url or not consumer_key or not access_token:
		print_usage_and_exit()

	api = pocket.Api(consumer_key = consumer_key, access_token = access_token)

	try:
		item = api.add(url)
		print 'Item \'%s\' added successfuly!' % item.normal_url
	except e:
		print e
		sys.exit(2)
Пример #2
0
def main():
	try:
		shortflags = 'h'
		longflags = ['help', 'consumer_key=', 'access_token=']
		opts, args = getopt.gnu_getopt(sys.argv[1:], shortflags, longflags)
	except getopt.GetoptError:
		print_usage_and_exit()

	consumer_key = None
	access_token = None

	for o, a in opts:
		if o in ('-h', '--help'):
			print_usage_and_exit()
		if o in ('--consumer_key'):
			consumer_key = a
		if o in ('--access_token'):
			access_token = a

	actions = ' '.join(args)
	if not actions or not consumer_key or not access_token:
		print_usage_and_exit()

	api = pocket.Api(consumer_key = consumer_key, access_token = access_token)

	try:
		actionsResult = api.send(actions)
		for result in actionsResult:
			print (result),
	except Exception, e:
		print e
		sys.exit(2)
Пример #3
0
def main():
    try:
        shortflags = 'h'
        longflags = ['help', 'consumer_key=', 'access_token=']
        opts, args = getopt.gnu_getopt(sys.argv[1:], shortflags, longflags)
    except getopt.GetoptError:
        print_usage_and_exit()

    consumer_key = None
    access_token = None

    for o, a in opts:
        if o in ('-h', '--help'):
            print_usage_and_exit()
        if o in ('--consumer_key'):
            consumer_key = a
        if o in ('--access_token'):
            access_token = a

    if not consumer_key or not access_token:
        print_usage_and_exit()

    api = pocket.Api(consumer_key=consumer_key, access_token=access_token)

    try:
        favorites = api.get(favorite=1)
        for favorite in favorites:
            print("%s (%s)" % (favorite.title, favorite.resolved_url))
    except Exception, e:
        print e
        sys.exit(2)
Пример #4
0
def reading_time(minutes):
    """ Convert minutes to a nice string representing the time. """
    rounded = int(5 * round(float(minutes) / 5)) or 2

    if 2 < rounded < 50:
        return '%d minutes' % rounded
    elif 50 <= rounded < 75:
        return '1 hour'
    elif 75 <= rounded < 105:
        return '1.5 hours'
    else:
        return '2+ hours'


if __name__ == '__main__':
    api = pocket.Api(consumer_key=consumer_key, access_token=access_token)

    try:
        items = api.get(sort='newest',
                        state='unread',
                        tag='_untagged_',
                        detailType='complete')
    except AttributeError:
        items = []

    for item in items:

        item.word_count = int(item.word_count)
        item.is_article = int(item.is_article)

        if item.word_count:
Пример #5
0
import pocket
import portachiavi
api = pocket.Api(consumer_key=portachiavi.pocket_consumer_key,
                 access_token=portachiavi.pocket_access_token)
items_list = api.get()
for item in items_list:
    print "%s (%s)" % (item.title, item.resolved_url)
def addtoPocket(aToken, url):
    # sample rss parser conumerkey
    cKey = "34863-11080497bbeded19744312c9"
    api = pocket.Api(consumer_key=cKey, access_token=aToken)
    item = api.add(url)