Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

bug fixes for blogger blog id parsing #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/gdata/blogger/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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

Expand Down