|
F4MF4M proxy with support for HDS streams
<item> <title>bbc outside uk</title> <link>plugin://plugin.video.f4mTester/?url=http%3A%2F%2Fzaphod-live.bbc.co.uk.edgesuite.net%2Fhds-live%2Flivepkgr%2F_definst_%2Fbbc1%2Fbbc1_1500.f4m%7CX-Forwarded-For%3D212.58.241.131</link> </item> There are other optional parameters if you want to include using & , like name, and maxbitrate etc. Also, you can now pass two more params, one is proxy "iport" format for example 108.163.254.214:7808 and other is proxy_for_chunks which is True/False. Some server only check at the manifest level (.f4m link) to make sure they are from their region (in this example US) but when you pass that block using their region proxy, then rest is open, so pass the US proxy and set the proxy_for_chunks to false. This way, it will get the manifest via proxy but rest will be as fast as your network could stream. LSPRO allows the use of $$TSDOWNLOADER$$ parameter in m3u url. If present, the .ts entries will be executed with f4mtester. <item> <title>test-123</title> <link>http://Ignoreme</link> <thumbnail></thumbnail> <externallink>http://mainstream.dyndns.tv:8000/get.php?username=oADdzK6f4W&password=UswG3exEgX&type=m3u&output=mpegts$$TSDOWNLOADER$$</externallink> </item> With LSPro version 2.6.7 and f4mproxy version 2.5.9, now we support $$HLSRETRY$$ (HLS retry) for streams which support hls (.m3u8) but disconnects users after sometime. This is same as $$TSDOWNLOADER$$ but works with .m3u8 files. You need to make sure that your urls should be .m3u8. $$HLSRETRY$$ is used when you want to load the m3u8 which contains other m3u8 and you want to list and play with f4m. When using f4mtester plugin syntax then you simply usestreamtype=HLSRETRY (just like you call for HLS OR HDS it's a new type). Example: <item> <title> IPTV Makelist</title> <link>$doregex[makelist]</link> <regex> <name>makelist</name> <listrepeat><![CDATA[ <title>[makelist.param1]</title> <link>plugin://plugin.video.f4mTester/?streamtype=HLSRETRY&name=[makelist.param1]&url=$doregex[encodedurl]</link> <thumbnail>NA</thumbnail> ]]></listrepeat> <expres>#EXTINF:-1.*,(.*?)\n.*(http.*m3u8)</expres> <page>http://myiptvurl.com/get.php?username=myusn&password=mypass&type=m3u&output=HLS</page> <referer>http://myiptvurl.com/live/myusn/mypass</referer> <x-forward></x-forward> <agent>Kodi/15.2</agent> </regex> <regex> <name>encodedurl</name> <expres>$pyFunction:urllib.quote_plus('[makelist.param2]')<expres> <page></page> </regex> </item> Courtesy of moshoodo123.
def f4mcallback(param, type, error, Cookie_Jar, url, headers): ... where:
def f4mcallback(param, type, error, Cookie_Jar, url, headers): <item> <title>TEST | BBC News - FILMON</title> <link>plugin://plugin.video.f4mTester/?streamtype=HLSRETRY&url=$doregex[get-url]</link> <regex> <name>get-url</name> <expres><![CDATA[#$pyFunction def getCookiesString(cookieJar): try: cookieString="" for index, cookie in enumerate(cookieJar): cookieString+=cookie.name + "=" + cookie.value +";" except: pass #print 'cookieString',cookieString return cookieString def f4mcallback(param, type, error, Cookie_Jar, url, headers): if type==1: newurl=getUrl(param,Cookie_Jar) oldservername=url.split('/')[2] newserver=newurl.split('/') newserver[2]=oldservername newurl='/'.join(newserver) return newurl,Cookie_Jar else: return '',None def getUrl(param, Cookie_Jar): import requests, re, urllib, inspect headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36'} url = 'http://www.filmon.com/tv/channel/export?channel_id='+param session = requests.session() session.cookies = Cookie_Jar source= session.get(url, headers = headers) swf = re.findall('streamer":"(.*?)"', source.text)[0] cleanswf = swf.replace('\\/','/') referer = 'http://www.filmon.com' + cleanswf headers1 = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36', 'Referer': url, 'X-Requested-With': 'XMLHttpRequest'} url2 = 'http://www.filmon.com/api-v2/channel/%s?protocol=hls'%param source1= session.get(url2, headers = headers1) getHD = re.findall('"high","url":"([^"]+)"', source1.text)[0] return getHD def GetLSProData(page_data,Cookie_Jar,m): import os,urllib callbackfunction=os.path.realpath(__file__) callbackparam='27' url=getUrl('27',Cookie_Jar) referer = 'http://www.filmon.com/' print 'url',url return urllib.quote_plus (url + '|Referer=' + referer+'&cookie='+getCookiesString(Cookie_Jar)+'&User-Agent=Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36') +'&callbackpath='+urllib.quote_plus(callbackfunction)+'&callbackparam='+urllib.quote_plus(callbackparam) ]]></expres> <page></page> <cookieJar></cookieJar> <thumbnail>http://obamapacman.com/wp-content/uploads/2011/06/BBC-Logo-iPad.jpg</thumbnail> </item> here you can see f4mcallback function reusing the same function which created the url, however since film returns different server address which runs different stream numbers, i am reusing the old server name so that the video could be stitched without any hitch. |