Skip to content

Commit 91db93a

Browse files
authored
Merge pull request #15 from snarfed/blogger_id_parsing
bug fixes for blogger blog id parsing
2 parents 2b5efc2 + ccae64c commit 91db93a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/gdata/blogger/data.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
BLOG_NAME_PATTERN = re.compile('(http://)(\w*)')
2323
BLOG_ID_PATTERN = re.compile('(tag:blogger.com,1999:blog-)(\w*)')
24-
BLOG_ID2_PATTERN = re.compile('tag:blogger.com,1999:user-(\d+)\.blog-(\d+)')
24+
BLOG_ID2_PATTERN = re.compile('tag:blogger.com,1999:user-g?(\d+)\.blog-(\d+)')
2525
POST_ID_PATTERN = re.compile(
2626
'(tag:blogger.com,1999:blog-)(\w*)(.post-)(\w*)')
2727
PAGE_ID_PATTERN = re.compile(
@@ -43,13 +43,12 @@ def get_blog_id(self):
4343
Returns:
4444
The blog's unique id as a string.
4545
"""
46-
if self.id.text:
47-
match = BLOG_ID_PATTERN.match(self.id.text)
46+
if not self.id.text:
47+
return None
48+
for pattern in BLOG_ID_PATTERN, BLOG_ID2_PATTERN:
49+
match = pattern.match(self.id.text)
4850
if match:
4951
return match.group(2)
50-
else:
51-
return BLOG_ID2_PATTERN.match(self.id.text).group(2)
52-
return None
5352

5453
GetBlogId = get_blog_id
5554

0 commit comments

Comments
 (0)