Skip to content
Permalink
Browse files
[blogger] Post type not always be the first tag
  • Loading branch information
punchagan committed Jul 22, 2016
1 parent b1fcefb commit 769a1f39b48ae7d5a05fb5418c49e569a52b039a
Showing with 20 additions and 19 deletions.
  1. +20 −19 v7/import_blogger/import_blogger.py
@@ -201,27 +201,28 @@ def import_item(self, item, out_folder=None):
LOGGER.warn('Not going to import "{0}" because it seems to contain'
' no content.'.format(title))

POST_TYPE_SCHEMAS = {
'http://schemas.google.com/blogger/2008/kind#post': 'posts',
'http://schemas.google.com/blogger/2008/kind#page': 'stories',
'http://schemas.google.com/blogger/2008/kind#settings': '',
'http://schemas.google.com/blogger/2008/kind#template': '',
'http://schemas.google.com/blogger/2008/kind#comment': '',
}

def process_item(self, item):
post_type = item.tags[0].term

if post_type == 'http://schemas.google.com/blogger/2008/kind#post':
self.import_item(item, 'posts')
elif post_type == 'http://schemas.google.com/blogger/2008/kind#page':
self.import_item(item, 'stories')
elif post_type == ('http://schemas.google.com/blogger/2008/kind'
'#settings'):
# Ignore settings
pass
elif post_type == ('http://schemas.google.com/blogger/2008/kind'
'#template'):
# Ignore template
pass
elif post_type == ('http://schemas.google.com/blogger/2008/kind'
'#comment'):
# FIXME: not importing comments. Does blogger support "pages"?
pass
terms = set([tag.term for tag in item.tags])
post_types = terms & set(self.POST_TYPE_SCHEMAS.keys())

if not post_types:
LOGGER.warn("Unknown post_type for {0}".format(item.title))

elif len(post_types) == 1:
out_folder = self.POST_TYPE_SCHEMAS[post_types.pop()]
if out_folder:
self.import_item(item, out_folder)

else:
LOGGER.warn("Unknown post_type:", post_type)
LOGGER.warn("Too many post_types for {0}".format(item.title))

def import_posts(self, channel):
for item in channel.entries:

0 comments on commit 769a1f3

Please sign in to comment.