0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-01 23:12:40 +00:00

[utils] Fix find_xpath_attr on 2.6

This commit is contained in:
Philipp Hagemeister 2014-09-13 08:34:15 +02:00
parent 652f283135
commit 4eefbfdbfd

View file

@ -280,6 +280,11 @@ def find_xpath_attr(node, xpath, key, val):
return node.find(expr)
else:
def find_xpath_attr(node, xpath, key, val):
# Here comes the crazy part: In 2.6, if the xpath is a unicode,
# .//node does not match if a node is a direct child of . !
if isinstance(xpath, unicode):
xpath = xpath.encode('ascii')
for f in node.findall(xpath):
if f.attrib.get(key) == val:
return f