<commit_before>#!/usr/bin/env python

# Requires https://github.com/samuelkordik/pocketlib

from readinglistlib import ReadingListReader
from pocketlib import Pocket


import argparse
import sys

# Configure and consume command line arguments.
ap = argparse.ArgumentParser(description='This script adds your Safari Reading List articles to Pocket.')
ap.add_argument('-v', '--verbose', action='store_true', help='Print article URLs as they are added.')
args = ap.parse_args()

# Initialize Pocket API
pocket = Pocket()

if pocket.is_authed() is False:
    print 'You need to authorize this script through Pocket before using it'
    print 'Follow these steps:'
    pocket.auth()

# Get the Reading List items
rlr = ReadingListReader()
articles = rlr.read()

for article in articles:

    (add_status, add_message) = pocket.add_item(article['url'].encode('utf-8'), title=article['title'].encode('utf-8'))
    if 200 == add_status:
        if args.verbose:
            print article['url'].encode('utf-8')
    else:
        print >> sys.stderr, add_message
        ap.exit(-1)<commit_msg>Changed readinglist2pocket script to only add read items and to add a Pocket tag for 'reading_list'<commit_after>#!/usr/bin/env python

# Requires https://github.com/samuelkordik/pocketlib

from readinglistlib import ReadingListReader
from pocketlib import Pocket


import argparse
import sys

# Configure and consume command line arguments.
ap = argparse.ArgumentParser(description='This script adds your Safari Reading List articles to Pocket.')
ap.add_argument('-v', '--verbose', action='store_true', help='Print article URLs as they are added.')
args = ap.parse_args()

# Initialize Pocket API
pocket = Pocket()

if pocket.is_authed() is False:
    print 'You need to authorize this script through Pocket before using it'
    print 'Follow these steps:'
    pocket.auth()

# Get the Reading List items
rlr = ReadingListReader()
articles = rlr.read(show="unread")

for article in articles:
    (add_status, add_message) = pocket.add_item(article['url'].encode('utf-8'), title=article['title'].encode('utf-8'), tags='reading_list')
    if 200 == add_status:
        if args.verbose:
            print article['url'].encode('utf-8')
    else:
        print >> sys.stderr, add_message
        ap.exit(-1)
{'fraction_non_alphanumeric': 0.11489733508082133, 'fraction_numerical': 0.00655307994757536, 'mean_word_length': 4.204545454545454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2186819', 'n_tokens_mistral': 691, 'n_tokens_neox': 663, 'n_words': 215}