Merge pull request 'fix(jellyfin): anchor the provider-key write on the file’s real root' (#121) from chore/jellyfin-tvdb-key into main
This commit was merged in pull request #121.
This commit is contained in:
commit
4a33898a6c
2 files changed
+50
-4
No files matched your search
@@ -135,7 +135,18 @@ text = escape(val)
|
||||
if pat.search(src):
|
||||
out = pat.sub(lambda m: f"{m.group(1)}<{elem}>{text}</{elem}>", src, count=1)
|
||||
else:
|
||||
out = src.replace("</Configuration>", f" <{elem}>{text}</{elem}>\n</Configuration>", 1)
|
||||
# The plugin owns this file and writes it under ITS OWN root element
|
||||
# (TheTVDB's is <PluginConfiguration>), and its serializer omits a
|
||||
# null-valued setting entirely — so the element being filled can be
|
||||
# absent outright, and a hardcoded </Configuration> anchor then matches
|
||||
# nothing. Anchor on the document's real root instead.
|
||||
out = src
|
||||
root = re.search(r"<([A-Za-z_][\w.:-]*)[^>]*>", src)
|
||||
if root and ("</%s>" % root.group(1)) in src:
|
||||
name = root.group(1)
|
||||
out = src.replace(
|
||||
"</%s>" % name, f" <{elem}>{text}</{elem}>\n</{name}>", 1
|
||||
)
|
||||
if out == src:
|
||||
raise SystemExit(f"{xml_path}: no place to write <{elem}>")
|
||||
|
||||
|
||||
Reference in new issue
Block a user