|
@ -243,10 +243,11 @@ def process_content(content, config=None): |
|
|
plugins = config.get('_content_plugins', {}) |
|
|
plugins = config.get('_content_plugins', {}) |
|
|
keyword_re = re.compile(r'^ *(?P<keyword>[\w\*]*) *(\((?P<argument>.*)\))? *$') |
|
|
keyword_re = re.compile(r'^ *(?P<keyword>[\w\*]*) *(\((?P<argument>.*)\))? *$') |
|
|
if not content: |
|
|
if not content: |
|
|
content = [["song"]] |
|
|
content = [ { 'song': None} ] |
|
|
for elem in content: |
|
|
for elem in content: |
|
|
|
|
|
if isinstance(elem, str): |
|
|
|
|
|
elem = { 'song': [elem] } |
|
|
if isinstance(elem, dict): |
|
|
if isinstance(elem, dict): |
|
|
# new way |
|
|
|
|
|
for keyword, argument in elem.items(): |
|
|
for keyword, argument in elem.items(): |
|
|
if keyword not in plugins: |
|
|
if keyword not in plugins: |
|
|
contentlist.append_error(ContentError(keyword, "Unknown content type.")) |
|
|
contentlist.append_error(ContentError(keyword, "Unknown content type.")) |
|
@ -257,22 +258,5 @@ def process_content(content, config=None): |
|
|
config=config, |
|
|
config=config, |
|
|
)) |
|
|
)) |
|
|
else: |
|
|
else: |
|
|
# old way |
|
|
contentlist.append_error(ContentError(elem, "Unknown content type.")) |
|
|
if isinstance(elem, str): |
|
|
|
|
|
elem = ["song", elem] |
|
|
|
|
|
try: |
|
|
|
|
|
match = keyword_re.match(elem[0]).groupdict() |
|
|
|
|
|
except AttributeError: |
|
|
|
|
|
contentlist.append_error(ContentError(elem[0], "Cannot parse content type.")) |
|
|
|
|
|
continue |
|
|
|
|
|
(keyword, argument) = (match['keyword'], match['argument']) |
|
|
|
|
|
if keyword not in plugins: |
|
|
|
|
|
contentlist.append_error(ContentError(keyword, "Unknown content type.")) |
|
|
|
|
|
continue |
|
|
|
|
|
contentlist.extend(plugins[keyword]( |
|
|
|
|
|
keyword, |
|
|
|
|
|
argument=argument, |
|
|
|
|
|
contentlist=elem[1:], |
|
|
|
|
|
config=config, |
|
|
|
|
|
)) |
|
|
|
|
|
return contentlist |
|
|
return contentlist |
|
|