- object_str = object_str.replace(u'<--', u'<!--')
-
- object_doc = xml.etree.ElementTree.fromstring(object_str)
- assert u'BrightcoveExperience' in object_doc.attrib['class']
- params = {'flashID': object_doc.attrib['id'],
- 'playerID': find_xpath_attr(object_doc, './param', 'name', 'playerID').attrib['value'],
- }
- playerKey = find_xpath_attr(object_doc, './param', 'name', 'playerKey')
+ object_str = object_str.replace('<--', '<!--')
+ object_str = fix_xml_ampersands(object_str)
+
+ object_doc = xml.etree.ElementTree.fromstring(object_str.encode('utf-8'))
+
+ fv_el = find_xpath_attr(object_doc, './param', 'name', 'flashVars')
+ if fv_el is not None:
+ flashvars = dict(
+ (k, v[0])
+ for k, v in compat_parse_qs(fv_el.attrib['value']).items())
+ else:
+ flashvars = {}
+
+ def find_param(name):
+ if name in flashvars:
+ return flashvars[name]
+ node = find_xpath_attr(object_doc, './param', 'name', name)
+ if node is not None:
+ return node.attrib['value']
+ return None
+
+ params = {}
+
+ playerID = find_param('playerID')
+ if playerID is None:
+ raise ExtractorError('Cannot find player ID')
+ params['playerID'] = playerID
+
+ playerKey = find_param('playerKey')