Recent Changes - Search:

LiveStreamsPro

PmWiki

pmwiki.org

edit SideBar

F4M

F4M proxy with support for HDS streams

To play HDS but also m3u/hls streams you can call the F4Mproxy via the f4mtester plugin as in following example. If your url requires headers to be sent use | (pipe) and URL-encode the url.

<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&amp;password=UswG3exEgX&amp;type=m3u&amp;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&amp;name=[makelist.param1]&amp;url=$doregex[encodedurl]</link>
<thumbnail>NA</thumbnail>
]]></listrepeat>
<expres>#EXTINF:-1.*,(.*?)\n.*(http.*m3u8)</expres>
<page>http://myiptvurl.com/get.php?username=myusn&amp;password=mypass&amp;type=m3u&amp;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.

Version 2.6.1 of f4mproxy and tester now support callbackparam and callbackpath. Callbackparam is string that the callback function will recieve. Callbackpath is the full file path of the python file containing the callback function, i have made the callback function static, it should be defined as:

def f4mcallback(param, type, error, Cookie_Jar, url, headers):
    ...

where:

  • param is the callbackparam you will receive back.
  • type is 1 for time being.
  • error is the error object for m3u8 file (for example 403).
  • CookieJar is the cookies
  • url is the old url the player was playing and headers are the headers it was using.


For time being, the callback function will only be used in situation where server returns 403 (due to cookie expiry or Url expiry for example filmon hd urls which are valid for 45 seconds or little more). The return value of callback function should be new url and the cookies.

Here is an example of filmon high quality stream playing more than its allowed to.

def f4mcallback(param, type, error, Cookie_Jar, url, headers):
<item>
<title>TEST | BBC News - FILMON</title>
<link>plugin://plugin.video.f4mTester/?streamtype=HLSRETRY&amp;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.

Edit - History - Print - Recent Changes - Search
Page last modified on October 06, 2016, at 04:57 PM
Free Web Hosting