def parse_title(title):
"""
Returns parsed contents of a post's title
"""
ro = re.compile(r"""
(?P<artist>.+[^- ]+) # The artist
\s*-+\s* # Skip some spaces and dashes
(?P<title>.*) # The title
\s*\[ # Skip some spaces and opening bracket
(?P<genre>.*) # The genre
\]\s*\( # Skip closing bracket, spaces and opening parenthesis
(?P<year>\d+) # The year
\) # Skip closing parenthesis
""", re.VERBOSE | re.IGNORECASE)
mo = ro.search(title)
if mo is None:
return
return {'artist': mo.group('artist'), 'title': mo.group('title'), 'genre': mo.group('genre'), 'year': mo.group(
'year')}
评论列表
文章目录