|
PythonCodeblockPython code block is pure python code enclosed in a CDATA section and that has to follow a certain syntax As we are able to write python code in <expres> tag and it works well on single functions/statements but when you need to perform multiple steps or concatenate multiple outputs, we end up writing two regex etc. <expres><![CDATA[#$pyFunction and end with Code: ]]></expres> It must contain a function named as GetLSProData with params for page data , cookie jar , regex call and any parameter you want to send it. Parameters can be in the form of param='myStringLiteral', param='[makelist.param#]' or param='$doregex[myregex]'. <item> <title>Test Function call</title> <link>$doregex[get-url]</link> <regex> <name>get-url</name> <expres><![CDATA[#$pyFunction import time def getMyCode2(dummyParam): return str(int(time.time())) def getMyCode(dummyParam): return str(int(time.time()*1000)) def GetLSProData(page_data,Cookie_Jar,m,param='Param1Value'): return 'http://Somewebsite.com/video/'+getMyCode(param) + '/' +getMyCode2(param) ]]></expres> <page></page> <cookieJar></cookieJar> </regex> </item> Example2: <item> <title> lb1.itcons.net.ua</title> <link>$doregex[get-url]</link> <regex> <name>get-url</name> <expres><![CDATA[#$pyFunction import urllib2 location = urllib2.urlopen('http://lb1.itcons.net.ua:1935/inters/redirect .hls?smil:inter.smil') print 'Location', location.geturl() ]]></expres> <page></page> <connection>Keep-Alive</connection> </regex> </item> |