- ns_map = {
- 'soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
- 'tem': 'http://tempuri.org/',
- 'itv': 'http://schemas.datacontract.org/2004/07/Itv.BB.Mercury.Common.Types',
- 'com': 'http://schemas.itv.com/2009/05/Common',
- }
- for ns, full_ns in ns_map.items():
- compat_etree_register_namespace(ns, full_ns)
-
- def _add_ns(name):
- return xpath_with_ns(name, ns_map)
-
- def _add_sub_element(element, name):
- return etree.SubElement(element, _add_ns(name))
-
- production_id = (
- params.get('data-video-autoplay-id')
- or '%s#001' % (
- params.get('data-video-episode-id')
- or video_id.replace('a', '/')))
-
- req_env = etree.Element(_add_ns('soapenv:Envelope'))
- _add_sub_element(req_env, 'soapenv:Header')
- body = _add_sub_element(req_env, 'soapenv:Body')
- get_playlist = _add_sub_element(body, ('tem:GetPlaylist'))
- request = _add_sub_element(get_playlist, 'tem:request')
- _add_sub_element(request, 'itv:ProductionId').text = production_id
- _add_sub_element(request, 'itv:RequestGuid').text = compat_str(uuid.uuid4()).upper()
- vodcrid = _add_sub_element(request, 'itv:Vodcrid')
- _add_sub_element(vodcrid, 'com:Id')
- _add_sub_element(request, 'itv:Partition')
- user_info = _add_sub_element(get_playlist, 'tem:userInfo')
- _add_sub_element(user_info, 'itv:Broadcaster').text = 'Itv'
- _add_sub_element(user_info, 'itv:DM')
- _add_sub_element(user_info, 'itv:RevenueScienceValue')
- _add_sub_element(user_info, 'itv:SessionId')
- _add_sub_element(user_info, 'itv:SsoToken')
- _add_sub_element(user_info, 'itv:UserToken')
- site_info = _add_sub_element(get_playlist, 'tem:siteInfo')
- _add_sub_element(site_info, 'itv:AdvertisingRestriction').text = 'None'
- _add_sub_element(site_info, 'itv:AdvertisingSite').text = 'ITV'
- _add_sub_element(site_info, 'itv:AdvertisingType').text = 'Any'
- _add_sub_element(site_info, 'itv:Area').text = 'ITVPLAYER.VIDEO'
- _add_sub_element(site_info, 'itv:Category')
- _add_sub_element(site_info, 'itv:Platform').text = 'DotCom'
- _add_sub_element(site_info, 'itv:Site').text = 'ItvCom'
- device_info = _add_sub_element(get_playlist, 'tem:deviceInfo')
- _add_sub_element(device_info, 'itv:ScreenSize').text = 'Big'
- player_info = _add_sub_element(get_playlist, 'tem:playerInfo')
- _add_sub_element(player_info, 'itv:Version').text = '2'
-