def _soap_request(self):

        def sub_ns(parent, tag, ns):
            return ET.SubElement(parent, (ns, tag) % "{%s}%s")

        def sub_common(parent, tag):
            return sub_ns(parent, tag, "http://schemas.itv.com/2009/05/Common")

        def sub_soap(parent, tag):
            return sub_ns(parent, tag, "http://schemas.xmlsoap.org/soap/envelope/")

        def sub_item(parent, tag):
            return sub_ns(parent, tag, "http://tempuri.org/")

        def sub_itv(parent, tag):
            return sub_ns(parent, tag, "http://schemas.datacontract.org/2004/07/Itv.BB.Mercury.Common.Types")

        production_id = self.production_id
        channel_id = self.channel_id

        ET.register_namespace("com", "http://schemas.itv.com/2009/05/Common")
        ET.register_namespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/")
        ET.register_namespace("tem", "http://tempuri.org/")
        ET.register_namespace("itv", "http://schemas.datacontract.org/2004/07/Itv.BB.Mercury.Common.Types")

        # Start of XML
        root = ET.Element("{http://schemas.xmlsoap.org/soap/envelope/}Envelope")

        sub_soap(root, "Header")
        body = sub_soap(root, "Body")

        # build request
        get_playlist = sub_item(body, "GetPlaylist")
        request = sub_item(get_playlist, "request")
        prode = sub_itv(request, "ProductionId")

        if production_id:
            # request -> ProductionId
            prode.text = production_id

        # request -> RequestGuid
        sub_itv(request, "RequestGuid").text = str(uuid4()).upper()

        vodcrid = sub_itv(request, "Vodcrid")
        # request -> Vodcrid -> Id
        vod_id = sub_common(vodcrid, "Id")
        # request -> Vodcrid -> Partition
        sub_common(vodcrid, "Partition").text = "itv.com"

        if channel_id:
            vod_id.text = "sim{0}".format(channel_id)

        # build userinfo
        userinfo = sub_item(get_playlist, "userInfo")
        sub_itv(userinfo, "Broadcaster").text = "Itv"
        sub_itv(userinfo, "RevenueScienceValue").text = "ITVPLAYER.2.14.1.+build.4a9166f0ba"
        sub_itv(userinfo, "SessionId")
        sub_itv(userinfo, "SsoToken")
        sub_itv(userinfo, "UserToken")
        # GeoLocationToken -> Token
        # sub_itv(sub_itv(userinfo, "GeoLocationToken"), "Token")


        # build siteinfo
        siteinfo = sub_item(get_playlist, "siteInfo")
        sub_itv(siteinfo, "AdvertisingRestriction").text = "None"
        sub_itv(siteinfo, "AdvertisingSite").text = "ITV"
        sub_itv(siteinfo, "AdvertisingType").text = "Any"
        sub_itv(siteinfo,
                "Area").text = "ITVPLAYER.VIDEO"  # "channels.itv{0}".format(channel_id) if channel_id else "ITVPLAYER.VIDEO"
        sub_itv(siteinfo, "Category")
        sub_itv(siteinfo, "Platform").text = "DotCom"
        sub_itv(siteinfo, "Site").text = "ItvCom"

        # build deviceInfo
        deviceinfo = sub_item(get_playlist, "deviceInfo")
        sub_itv(deviceinfo, "ScreenSize").text = "Big"

        # build playerinfo
        playerinfo = sub_item(get_playlist, "playerInfo")
        sub_itv(playerinfo, "Version").text = "2"

        return ET.tostring(root)
dataset/ETHPy150Open chrippa/livestreamer/src/livestreamer/plugins/itvplayer.py/ITVPlayer._soap_request/swapped operands of `%`