diff --git a/docs/importer.rst b/docs/importer.rst index 7b839d305..997a46323 100644 --- a/docs/importer.rst +++ b/docs/importer.rst @@ -11,7 +11,6 @@ software to reStructuredText or Markdown. The supported import formats are: - Blogger XML export - Dotclear export -- Posterous API - Tumblr API - WordPress XML export - RSS/Atom feed @@ -48,16 +47,15 @@ Usage :: - pelican-import [-h] [--blogger] [--dotclear] [--posterous] [--tumblr] [--wpfile] [--feed] + pelican-import [-h] [--blogger] [--dotclear] [--tumblr] [--wpfile] [--feed] [-o OUTPUT] [-m MARKUP] [--dir-cat] [--dir-page] [--strip-raw] [--wp-custpost] - [--wp-attach] [--disable-slugs] [-e EMAIL] [-p PASSWORD] [-b BLOGNAME] - input|api_token|api_key + [--wp-attach] [--disable-slugs] [-b BLOGNAME] + input|api_key Positional arguments -------------------- ============= ============================================================================ ``input`` The input file to read - ``api_token`` (Posterous only) api_token can be obtained from http://posterous.com/api/ ``api_key`` (Tumblr only) api_key can be obtained from https://www.tumblr.com/oauth/apps ============= ============================================================================ @@ -67,7 +65,6 @@ Optional arguments -h, --help Show this help message and exit --blogger Blogger XML export (default: False) --dotclear Dotclear export (default: False) - --posterous Posterous API (default: False) --tumblr Tumblr API (default: False) --wpfile WordPress XML export (default: False) --feed Feed to parse (default: False) @@ -101,10 +98,6 @@ Optional arguments output. With this disabled, your Pelican URLs may not be consistent with your original posts. (default: False) - -e EMAIL, --email=EMAIL - Email used to authenticate Posterous API - -p PASSWORD, --password=PASSWORD - Password used to authenticate Posterous API -b BLOGNAME, --blogname=BLOGNAME Blog name used in Tumblr API @@ -120,13 +113,9 @@ For Dotclear:: $ pelican-import --dotclear -o ~/output ~/backup.txt -for Posterous:: - - $ pelican-import --posterous -o ~/output --email= --password= - For Tumblr:: - $ pelican-import --tumblr -o ~/output --blogname= + $ pelican-import --tumblr -o ~/output --blogname= For WordPress:: diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py index b426de9c2..cd643ec62 100755 --- a/pelican/tools/pelican_import.py +++ b/pelican/tools/pelican_import.py @@ -390,51 +390,6 @@ def dc2fields(file): post_format) -def posterous2fields(api_token, email, password): - """Imports posterous posts""" - import base64 - from datetime import timedelta - import json - import urllib.request as urllib_request - - def get_posterous_posts(api_token, email, password, page=1): - base64string = base64.encodestring( - ("{}:{}".format(email, password)).encode('utf-8')).replace('\n', '') - url = ("http://posterous.com/api/v2/users/me/sites/primary/" - "posts?api_token=%s&page=%d") % (api_token, page) - request = urllib_request.Request(url) - request.add_header('Authorization', 'Basic %s' % base64string.decode()) - handle = urllib_request.urlopen(request) - posts = json.loads(handle.read().decode('utf-8')) - return posts - - page = 1 - posts = get_posterous_posts(api_token, email, password, page) - subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS'] - while len(posts) > 0: - posts = get_posterous_posts(api_token, email, password, page) - page += 1 - - for post in posts: - slug = post.get('slug') - if not slug: - slug = slugify(post.get('title'), regex_subs=subs) - tags = [tag.get('name') for tag in post.get('tags')] - raw_date = post.get('display_date') - date_object = SafeDatetime.strptime( - raw_date[:-6], '%Y/%m/%d %H:%M:%S') - offset = int(raw_date[-5:]) - delta = timedelta(hours=(offset / 100)) - date_object -= delta - date = date_object.strftime('%Y-%m-%d %H:%M') - kind = 'article' # TODO: Recognise pages - status = 'published' # TODO: Find a way for draft posts - - yield (post.get('title'), post.get('body_cleaned'), - slug, date, post.get('user').get('display_name'), - [], tags, status, kind, 'html') - - def tumblr2fields(api_key, blogname): """ Imports Tumblr posts (API v2)""" import json @@ -893,7 +848,7 @@ def fields2pelican( def main(): parser = argparse.ArgumentParser( - description="Transform feed, Blogger, Dotclear, Posterous, Tumblr, or " + description="Transform feed, Blogger, Dotclear, Tumblr, or " "WordPress files into reST (rst) or Markdown (md) files. " "Be sure to have pandoc installed.", formatter_class=argparse.ArgumentDefaultsHelpFormatter) @@ -906,9 +861,6 @@ def main(): parser.add_argument( '--dotclear', action='store_true', dest='dotclear', help='Dotclear export') - parser.add_argument( - '--posterous', action='store_true', dest='posterous', - help='Posterous export') parser.add_argument( '--tumblr', action='store_true', dest='tumblr', help='Tumblr export') @@ -959,12 +911,6 @@ def main(): help='Disable storing slugs from imported posts within output. ' 'With this disabled, your Pelican URLs may not be consistent ' 'with your original posts.') - parser.add_argument( - '-e', '--email', dest='email', - help="Email address (posterous import only)") - parser.add_argument( - '-p', '--password', dest='password', - help="Password (posterous import only)") parser.add_argument( '-b', '--blogname', dest='blogname', help="Blog name (Tumblr import only)") @@ -976,8 +922,6 @@ def main(): input_type = 'blogger' elif args.dotclear: input_type = 'dotclear' - elif args.posterous: - input_type = 'posterous' elif args.tumblr: input_type = 'tumblr' elif args.wpfile: @@ -986,7 +930,7 @@ def main(): input_type = 'feed' else: error = ('You must provide either --blogger, --dotclear, ' - '--posterous, --tumblr, --wpfile or --feed options') + '--tumblr, --wpfile or --feed options') exit(error) if not os.path.exists(args.output): @@ -1005,8 +949,6 @@ def main(): fields = blogger2fields(args.input) elif input_type == 'dotclear': fields = dc2fields(args.input) - elif input_type == 'posterous': - fields = posterous2fields(args.input, args.email, args.password) elif input_type == 'tumblr': fields = tumblr2fields(args.input, args.blogname) elif input_type == 'wordpress':