2018-10-23, 07:24 AM
Hi Devs. I was doing some IPTV testing and wanted to use my OTA tuner via NPVR as my source. Naturally I saw that http://127.0.0.1:8866/channels creates a functional .m3u8 playlist of known channels... BUT it is missing the crucial "tvg-id" element used to reference epg data in most IPTV apps.
So in an attempt to automate I tinkered with v4.1.1 and found you can easily alter the code base to dynamically create a proper M3U8 playlist AND XMLTV files with matching epg data from the tuner. Much like NPVR does already with json just using a slightly different format.
To make NextPVR output both web-accessible IPTV files (playlist.m3u8 and latest epg.xml in xmltv format) I did this:
1) Copy IPTVServiceController.cs (attached file) to C:\Users\Public\NPVR\web\App_Code\
2) Manually add web routes to "LoadGuideService()" method within the C:\Users\Public\NPVR\web\App_Code\Routes.cs text file to point to your new IPTV Service Controller.
3) That's it, restart the nextpvr service.
Now you can use your favourite IPTV app to stream OTA channels from nextpvr (no transcoding) as if it were an IPTV server AND gather 72 hours of epg data in proper xmltv format.
http://192.168.0.100:8866/public/m3u
returns dynamically populated m3u file loaded with whatever host was requested:
http://127.0.0.1:8866/public/epg
returns dynamically populated XMLTV file from internal EPG data:
NOTE: there is no tvg-group element. Sources appear under one group called "Tuner" the rest are "Recordings". Hopefully this helps someone in the same boat I was in.
I'm still fairly new to NextPVR and loving the many use cases for it. Obviously this is experimental and unsupported although this little hack has worked perfect so far as there is hardly any new code.
If more experienced devs think a full compiled plugin would be simpler or better could you please advise how to go about that.
So in an attempt to automate I tinkered with v4.1.1 and found you can easily alter the code base to dynamically create a proper M3U8 playlist AND XMLTV files with matching epg data from the tuner. Much like NPVR does already with json just using a slightly different format.
To make NextPVR output both web-accessible IPTV files (playlist.m3u8 and latest epg.xml in xmltv format) I did this:
1) Copy IPTVServiceController.cs (attached file) to C:\Users\Public\NPVR\web\App_Code\
2) Manually add web routes to "LoadGuideService()" method within the C:\Users\Public\NPVR\web\App_Code\Routes.cs text file to point to your new IPTV Service Controller.
Code:
Logger.Debug("\n\n$$$$$$$$$$$$$$$$\n"+"Setting IPTV Service Controller for dynamic M3U");
RouteTable.Routes.MapHttpRoute(
"IPTVServiceGetChannelsM3U",
"public/m3u", new { Controller = "IPTVService", Action = "GetChannelsM3U" }, new { httpMethod = new HttpMethodConstraint("Get")
//IMPORTANT: a folder separator is required to allow autologin feature to work, there must be a folder before /public/file.m3u
});
Logger.Debug("\n\n$$$$$$$$$$$$$$$$\n"+"Setting IPTV Service Controller for dynamic XMLTV");
RouteTable.Routes.MapHttpRoute(
"IPTVServiceGetGuideXML",
"public/epg", new { Controller = "IPTVService", Action = "GetGuideXML" }, new { httpMethod = new HttpMethodConstraint("Get")
});
3) That's it, restart the nextpvr service.
Now you can use your favourite IPTV app to stream OTA channels from nextpvr (no transcoding) as if it were an IPTV server AND gather 72 hours of epg data in proper xmltv format.
http://192.168.0.100:8866/public/m3u
returns dynamically populated m3u file loaded with whatever host was requested:
Code:
#EXTM3U
#EXTINF:0 tvg-id="7168", 91 - ABC HD
http://192.168.0.100:8866/live?channel=91
http://127.0.0.1:8866/public/epg
returns dynamically populated XMLTV file from internal EPG data:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE DocType>
<tv source-info-name="NEXTPVR">
<channel id="7168">
<display-name>ABC HD</display-name>
</channel>
<programme id="1075182" start="20180501120500 +0100" stop="20180501130500 +0100" channel="7168">
<title>Beauty And The Beach</title>
<desc>Meagan was bullied as a child, and has low self-esteem about her breasts since giving birth. Ginger is unhappy with her body since the birth of her son. But will the culture shock of Phuket put them too far out of their comfor..</desc>
</programme>
</tv>
NOTE: there is no tvg-group element. Sources appear under one group called "Tuner" the rest are "Recordings". Hopefully this helps someone in the same boat I was in.
I'm still fairly new to NextPVR and loving the many use cases for it. Obviously this is experimental and unsupported although this little hack has worked perfect so far as there is hardly any new code.
If more experienced devs think a full compiled plugin would be simpler or better could you please advise how to go about that.