From e1404ec0724a0f603dfc24841eada6d284b60f0e Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Sun, 14 Jun 2015 18:35:22 -0700 Subject: [PATCH] bug fixes for blogger blog id parsing specifically: * handle new style blogger blog ids prefixed with g. details in snarfed/bridgy#168 * don't crash if blog id can't be parsed. details in bridgy/issues#147 --- src/gdata/blogger/data.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gdata/blogger/data.py b/src/gdata/blogger/data.py index 3cdaa734..e5b1f694 100644 --- a/src/gdata/blogger/data.py +++ b/src/gdata/blogger/data.py @@ -32,7 +32,7 @@ BLOG_NAME_PATTERN = re.compile('(http://)(\w*)') BLOG_ID_PATTERN = re.compile('(tag:blogger.com,1999:blog-)(\w*)') -BLOG_ID2_PATTERN = re.compile('tag:blogger.com,1999:user-(\d+)\.blog-(\d+)') +BLOG_ID2_PATTERN = re.compile('tag:blogger.com,1999:user-g?(\d+)\.blog-(\d+)') POST_ID_PATTERN = re.compile( '(tag:blogger.com,1999:blog-)(\w*)(.post-)(\w*)') PAGE_ID_PATTERN = re.compile( @@ -54,13 +54,12 @@ def get_blog_id(self): Returns: The blog's unique id as a string. """ - if self.id.text: - match = BLOG_ID_PATTERN.match(self.id.text) + if not self.id.text: + return None + for pattern in BLOG_ID_PATTERN, BLOG_ID2_PATTERN: + match = pattern.match(self.id.text) if match: return match.group(2) - else: - return BLOG_ID2_PATTERN.match(self.id.text).group(2) - return None GetBlogId = get_blog_id