Update collect function to improve compatibility

This commit is contained in:
C5H12O5
2023-08-12 11:17:00 +08:00
parent ae53eea20d
commit 9c6df76459
2 changed files with 5 additions and 4 deletions

View File

@ -46,8 +46,8 @@
"into": {
"movie": {
"title": "xp_text: ./movie/nm",
"tagline": "xp_text: ./movie/filmAlias",
"original_title": "xp_text: ./movie/enm",
"tagline": "xp_text: ./movie/enm",
"original_title": "xp_text: ./movie/filmAlias",
"original_available": "xp_text: ./movie/pubDate",
"summary": "xp_text: ./movie/dra",
"certificate": "",

View File

@ -51,7 +51,7 @@ def collect(args: CollectArgs, context: dict) -> None:
_logger.debug("<== result: %s", context[ctxkey])
def _render(tmpl: Union[list, dict, str], source, etree=None):
def _render(tmpl: Any, source, etree=None):
"""Render a template with the given source."""
if etree is None and _need_etree(tmpl):
etree = str_to_etree(source)
@ -62,6 +62,7 @@ def _render(tmpl: Union[list, dict, str], source, etree=None):
return {k: _render(v, source, etree) for k, v in tmpl.items()}
elif isinstance(tmpl, str):
return _render_str(tmpl, source, etree)
return tmpl
def _render_str(tmpl: str, source, etree):
@ -85,7 +86,7 @@ def _render_str(tmpl: str, source, etree):
return None
def _need_etree(tmpl: Union[list, dict, str]):
def _need_etree(tmpl: Any):
"""Check if the template needs an etree."""
if isinstance(tmpl, list):
return any(_need_etree(item) for item in tmpl)