blob: e7a553c65f7df9c92742aed06bacd84fe1354480 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!/usr/bin/env python3
import html
import sys
import xml.etree.ElementTree as ET
text_input = sys.stdin.read()
root = ET.fromstring(text_input)
# RSS 2.0: <channel><item><title>
for item in root.findall(".//item"):
title = item.find("title")
if title is not None and title.text:
title.text = html.unescape(title.text)
# re-serialize
sys.stdout.buffer.write(ET.tostring(root, encoding="utf-8", xml_declaration=True))
|