PlutoTV, USTVGO, XUMO, M3U/XMLTV, SamsungTV, Plex interfaces (appliance)

Added by G Kazaroth about 2 years ago

Cabernet for (Cable Network) version 0.9.7 (2/16/2022)
PlutoTV, USTVGO, XUMO, M3U/XMLTV, SamsungTV, Plex

Provides a configurable interface from providers to TVHeadend.

  • Direct plugin for USTVGO, PlutoTV, XUMO
  • M3U Plugin provides channels for: SamsungTVPlus, Plex, Binge, DStv, Foxtel, Kayo, Optus, PBS, Singtel, SkyGo, SkySportsNow, Stirr, and others
  • From:
  • Import your own M3U file
Working on getting a service that will take the PlutoTV or XUMO server stream, clean it and feed it into TVHeadend and other DVRs (Also tested on Emby, JellyFin and Plex). It works on the subscription and free versions. Also it runs on Linux and Windows as a service. Windows has a installer. Once installed, setup is easy with TVHeadend.
1) Setup the automatic IPTV network (recommend new URL is http://[host]:6077/PlutoTV/channels.m3u)

Make sure to set the "Maximum # input streams". PlutoTV is set to a max of 4 and tvheadend uses 2 per tuner during initial screening. Doing a force scan will create the mux and service values. Also, turn View level to Advanced and set the Re-fetch period (mins) to a very large number. TVheadend has a tenancy to cause issues when channels change (Changed Services will not be mapped to channels). The Maximum Timeout is used to wait for a reply during a Forced scan. Recommend keep this low, like 15-20 seconds. Some of the channels may fail, but it is faster than having a high setting and waiting for all channels to scan. Just individually rescan those that failed by setting each mux back to PEND from IDLE.
2) Next you can setup the grabber. I use a URL grabber written in Unix bash and is an extremely small file. It can be found in the github repo at called tv_grab_url
Place the grabber file in the same location as the other TVHeadend tv_grab* files, change the permissions to executable and restart TVHeadend. This should allow TVHeadend to pickup the new grabber. While in the grabber list, make sure and disable any OTA grabbers. Stations no longer send this information and will only cause TVHeadend to use a tuner for scanning. Displaying the log window by clicking the three ^ in the bottom right is helpful at this time.

Have the grabber run and populate the EPG data into the EPG Grabber Channels tab. The log should show a quantity of channels were detected.
Pop over to the EPG Grabber tab and disable the OTA grabber cron. Also, update/replace the Internal grabber cron schedule using something like below. The example will pull the TV guide at 6:04am and 5:52pm. Add more if you need. It is recommended to use static cron times.

4 6 * * *
52 17 * * *

3) In the Channel view, select Map all channels.

This will tie the services, EPG and channels together, automatically. After this, re-grab the EPG data. This will populate the EPG tab with shows. For TVH version 4.3, the Number column will auto-populate. For TVH 4.2, you will need to manually add channel numbers.
4) Display the TVGUIDE. This appliance has special features which maps the tvheadend genre, giving colors on tvguides. It also has enhanced guide descriptions and optional additional channel notations if you use many streams. Below is the Kodi tvguide using the pvr.hts plugin.

For Kodi, go to the settings for PVR and turn on the General setting "Use channel numbers from backend".

Replies (768)

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

Here is a video test file that has the ad followed by the actual stream. When I play on VLC, it works. When I stream it into TVHeadend, it stops after the ad plays.

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

Getting closer to the solution. My current solution is to use ffprobe to get the pts values for the packets in the current stream. If it detect a bad set of pts values, then those packets are dropped until good pts values occur. That along with using ffmpeg option -copyts seems to get rid of all the bad pts packets. More testing, but it is looking much better.

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

After testing for 4-5 hours, it seems to now work by removing the bad packets. My plan is to create a new app for TVHeadend associated with Locast. Based on tvheadend naming format for apps, my plan is to use "tvheadend-locast". Unless I hear otherwise, I will place the development in my github area. The software is based on locast2plex, so as that app is updated, those changes will be incorporated simply into the tvheadend one.

RE: Locast interface (free version) - Added by ace golfer about 2 years ago

This is a great project. Curious, what's the file size of 1 hour recording?

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

For a 720 @30FPS (which seem to be what locast down-verts to on the major channels I get 610MB per hour. From the antenna, the same channel with 1080 @30 is 4.53GB. This was the same show recording on both channels at one time through tvheadend. I have mine running as a service for about 2 weeks and has had no issues, so far.

I have a baseline set of code completed and to some degree tested. It is at
I run this in Linux. You need a config.ini file at the top folder. Mine looks like

plex_accessible_ip = 192.168.1.<###>
locast_username = <username>
locast_password = <password>
uuid = noxnkxyu
bytes_per_read = 256000
epg_update_days = 7
free_refresh_rate = 1827
servicename_suffix = L

To run, download zip from github, unzip and from the top folder run the command

To test, run the URL from a browser
http://&lt;IP ADDRESS>:6077/lineup.json
This should give you a list of locast local channels.
Run the URL
http://&lt;IP ADDRESS>:6077/channels.m3u
which you can use to import into TVHeadend and automatically populate the muxes and services.
http://&lt;IP ADDRESS>:6077/xmltv.xml
produces the xmltv.xml file that TVHeadend needs for the EPG
I am running both the antenna and locast through the tvheadend with two different xmltv.xml files. One from locast and one from zap2it. It is all working fine. Only issue that seems to appear is when locast skips 6 seconds of video, tvheadend does not like it. I may have to use a filler video for that, but have not had time.

I am working on a number of projects which are higher priority right now, but plan to get back in a couple of weeks.

RE: Locast interface (free version) - Added by Chris Hubbard about 2 years ago

I am curious, if I am a "paid" subscriber for the locast system, will your version choke when it does not see the ads, or will it "just work" when someone has donated to locast?

I am using the unmodified locast2plex, and have hacked it into my MythTV system. However I think if I am going to attempt to future-proof things this will likely be the route I head (using the tvheadend software).

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

The app is based on locast2plex. It should work with paid subscriptions since the paid tag is obtained from locast directly and then if statements are made to support the paid versus free interface. TVHeadend requires different information than what plex needs, so changes to the ffmpeg call and updates to the tv guide are needed. I have not implemented the tv guide updates, but I am aware of the changes. The project is setup to overlay the locast2plex updates easily with minimum impacts to the tvheadend source. The cool part of the product is that you can start up the service manually and then point a VLC client at it and it will play the channel using the URLs instead of using TVHeadend.

All files except those in the tvheadend-locast/lib/tvheadend/ are from locast2plex.

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

tvheadend-locast is now fully working on Linux (Ubuntu) and Windows OS. It can either play through tvheadend or play directly from a player like VLC. I have not created any installers. Just unpack and run the command "python3" after updating/creating the config.ini file. Still working on documentation and installers, but very happy with the results so far.

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

Added Windows installer for tvheadend-locast
After installing, browse to the URL
This will download a m3u file. If you have VLC installed, it should auto-populate with the channels.
I would be interested in how it went.
Next step is to create a Debian/Ubuntu installer.

RE: Locast interface (free version) - Added by Tony Wagner about 2 years ago

Thanks for sharing, I just got this working on my Raspberry Pi. Two things of note:

1. Be sure to copy the tvheadend-specific config_example.ini file to the root directory as config.ini, then edit it with your IP and account information:

cp lib/tvheadend/config_example.ini config.ini

2. After that, the program would start for me but quickly broke with this error:

Traceback (most recent call last):
File "", line 11, in <module>
File "/home/piuser/locast/lib/tvheadend/", line 130, in main
epg2xml.generate_epg_file(config, location_info.location)
File "/home/piuser/locast/lib/tvheadend/", line 122, in generate_epg_file
channel_number = str(dma_channels[sid]['channel'])
KeyError: '1595365120185'

Somehow the program was looking for an id (1595365120185) that didn't exist in my dma_channels list. I got around this by editing lib/tvheadend/ and adding a quick check if the channel exists at line 122, as follows:

sid = str(channel_item['id'])
channel = dma_channels.get(sid)
if not channel:
channel_number = str(dma_channels[sid]['channel'])

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

First, thank you for running the test; it is very much appreciated. The windows installer (and the debian installer I am working on), will do the config.ini copy for you. As for the IP address, I changed the code so you can use "" for the IP address. Standard socket libraries will open a port against all IP addresses on your box using that IP. (It takes can of people looking for an IP and works with WiFi and electrical connections together.) All the installer does to the config.ini is set the user/password; the rest of the config_example.ini file in lib/tvheadend/ should be fine for starters.

As for the issue you found. I believe I understand. The Kodi version shows that the Locast EPG can have more channels than those listed in the station list. I believe a filter is needed like you mentioned to filter out any channel IDs that are not in the station list. The interesting part is that the other channels are, many times, duplicates running at a different resolution. Like NBC is at 720p, but the other EPG channel for NBC runs at 1080. For now, I am ignoring these other channels. If you want to check the lists, here is how. In the .\cache\*epg\ folder there are json files with dates. Throw one of these files into your favorite browser and it should organize the epg data. You can then see how many channels it is reporting and the SIDs. Then there is the .\cache\stations\*station.json which has the list of official SIDs and channels.

Oh, your Raspberry Pi. I am not an expert on Raspberry Pis... What OS is it running? I am assuming a Debian version. Is this correct?
Thank you again.

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

Fix implemented and released as 0.7.2.

RE: Locast interface (free version) - Added by Tony Wagner about 2 years ago

Thanks! I just updated and the EPG error is now gone. And yes, my Pi is running Raspbian, based on Debian.

One more issue: if I leave the IP address set to, the stream URLs in channels.m3u and lineup.json all point to no matter what computer makes the request. Not a problem for TVHeadend on the same machine, but those stream URLs obviously won't play on other computers on the network unless I change the IP.

Can channels.m3u and lineup.json just return relative stream URLs? Or if they have to be absolute, they could get the IP/domain specified in the request, as use that to build the stream URLs.

RE: Locast interface (free version) - Added by G Kazaroth about 2 years ago

I also noticed it that seemed to get the localhost address instead of the network IP. It is suppose to be caused by the /etc/hosts file setup with the primary hostname. I have researched and made changes to the code to pull the network IP. The channels.m3u must have absolute URLs, sorry. I have been testing most of the day on both unix and windows and it looks like it is fixed.

The latest is RC2.

RE: Locast interface (appliance) - Added by G Kazaroth almost 2 years ago

Released 0.7.3-RC2

RE: Locast interface (appliance) - Added by Alistair Ruckus almost 2 years ago

this works perfectly. i'm a paid subscriber of locast and was looking for something exactly like this to get locast into tvh.

thank you for your hard work!

RE: Locast interface (appliance) - Added by G Kazaroth almost 2 years ago

Released 0.7.4
- Now fully works with Plex and Emby using config updates
- Removes ffmpeg requirements by default (can still add them back in)
- Added ability to use ffmpeg, internal proxy or redirect m3u8
- Moved stream port to 5004, like HDHR. web admin port is still 6077, by default
- Removed config_example.ini from locast2plex area which was causing confusion.

Fairly happy with the product at this point. No changes are expected although working on the next project. Recommend the update as the removal of ffmpeg seems to make the product smoother and uses less CPU.

RE: Locast interface (appliance) - Added by Tony Wagner almost 2 years ago

I just had a chance to try your updates on my Raspberry Pi.

First off, if there are comments on the same line as a variable in the config.ini file, it includes the comment in the variable value, and thus the script fails as soon as it tries to use that value somewhere:

ValueError: invalid literal for int() with base 10: '5004  # streaming port'

That's an easy fix -- just remove the comments from config.ini, or at least move them to their own line.

Unfortunately, even after doing that, starting the latest version of the script still fails around the "get_fcc_stations" function call in lib/tvheadend/

$ python3
Loading Configuration File: /home/pi/locast/tvheadend-locast-main/config.ini
Tuner count set to 3
Server is set to run on
UUID set to: 6B1437AC-8737-11EB-A3A7-DCA6324EAF1D...
Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/", line 297, in _bootstrap
  File "/usr/lib/python3.7/multiprocessing/", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/locast/tvheadend-locast-main/lib/tvheadend/", line 36, in stations_process
  File "/home/pi/locast/tvheadend-locast-main/lib/tvheadend/", line 55, in refresh_dma_stations_and_channels
    fcc_stations = get_fcc_stations(config)
NameError: name 'get_fcc_stations' is not defined

And nothing beyond the web interface home page will load after that, since it apparently can't get any station data.

If I jump back one commit, to 29352c3f1c99e141d879c2688f0edea208e841f5, and remove the comment from the lib/tvheadend/config_example.ini file before using it, all works as expected.

I'm using Python 3.7.3, which is the latest version from the default Raspian Buster armv7l apt repository. Let me know if you need me to do any further troubleshooting or testing.

RE: Locast interface (appliance) - Added by C Island almost 2 years ago

I also ran into the same problems. I fixed them as best I could and submitted a PR. It works for me but hopefully it works for others as well.

Here are my notes on my changes:

Updated lib/tvheadend/ to fully qualify variables and function names in the Stations class. The unqualified names were causing exceptions.

Updated lib/tvheadend/ and lib/ to use plex_accessable_port instead of bind_port. This was to fix failure to bind to port errors.
Updated lib/tvheadend/ to use web_admin_port instead of bind_port. This was to fix failure to bind to port errors.

I wanted to use cryptography and docker so I created Dockerfiles that include cryptography.

Dockerfile_tvh_crypt.slim-buster (my preferred: debian does not require full build of cryptography and is same size as alpine)
Dockerfile_tvh_crypt.alpine (in case you like alpine: alpine requires the full build/compile of cyrptography)

RE: Locast interface (appliance) - Added by G Kazaroth almost 2 years ago

Merged the changes, but have not released a new version. Next version plans to configure 3 ways: using ffmpeg, not using ffmpeg and m3u-redirect. Not using ffmpeg works much cleaner with tvheadend. Also, working on significant HTML GUI updates and cleaner EPG updates. Hope to have it out within a week.

Thank you for your support.

RE: Locast interface (appliance) - Added by G Kazaroth almost 2 years ago

Released 0.7.5 (Base app is now called cabernet for Cable Network)
  • Overhauled web pages
  • Created base GUI architecture
  • Added themes to GUI
  • Established app icon and name
  • Significant upgrade to config editor
  • Updated code to python standards
  • Fixed bugs: port and classes (thank you cookieisland)
  • internalproxy: Added service name to stream (ATSC protocol updates)
  • user_config: Added configuration definition json file for better config management
  • Updated bug with locast service on Debian/Ubuntu
  • Fixed bug skipping streams with free account

Home page is at http://[ip]:6077/
Note the web page is in work; however, Home, XML/JSON Links and Settings are working. More to come.

RE: Locast interface (appliance) - Added by Sean Micklem almost 2 years ago

I just came across this project and am confused by a couple of things. First, I see that people are using this in Ubuntu and even on a Raspberry Pi, but in searching through this thread and the project page I cannot for the life of me find any clear instructions for installation. For example, when you install Tvheadend on Ubuntu you can go to and it more or less walks you through the process of installing Tvheadend. Is there anything similar for this software? Because right now I'm totally clueless as to how you install and configure it. I see in the top post how you configure Tvheadend once you have it installed , but I am not clear on how you get it installed in the first place.

Second, assuming that one can get this software installed, is there a way to test it with a demo account (one you have not donated for) - that would be important to me because I have no confidence in my ability to get this working, but I would have no interest at all in Locast if I can't PVR shows to watch later (which I think is the whole point of using it with Tvheadend in the first place - if all you ever wanted to do is watch live, you could do that on a Roku). So I would not want to donate unless and until I am absolutely certain that I can get the software installed and configured to the point that the channels would be viewable in Tvheadend. If it stops after 15 minutes or whatever with a demo account that's fine, I would not be doing any extended watching or recording on a demo account. But on the other hand if I just can't make it work at all, there is no point in donating, and unless there are some installation instructions that I'm just not seeing then there is probably not much hope of me getting it to work.

RE: Locast interface (appliance) - Added by G Kazaroth almost 2 years ago

The answers are yes and yes. This project is early on and the installer for debian has been put on hold with other upgrades in work, sorry. First, to install on debian,

NOTE: You do not have to have a subscription, but need to be in an area locast provides service. Just create the free account and enter the data in the config.ini

  1. Grab the source zip file for the release
  2. Unzip it in a folder of your choosing
  3. Take the config_example.ini at the location ./lib/tvheadend/ and place it in the top level folder renamed to config.ini
  4. Edit the config.ini and and update the username and password lines with the login you created at
  5. Before creating a service, try starting the app from the command line. It should run as a normal user. Type "python3" from the top level folder.
  6. Start a browser on your network and hit the URL http://[IP]:6077/ That should bring up the website for the app.
  7. Click on XML/JSON Links
  8. This brings up the list of URLs available. If you have something like VLC installed, then clicking on the /playlist link should launch VLC with the list of channels you can play. You should be able to just click on one of the channels in VLC to get it to play.
  9. To make a service, go to ./lib/tvheadend/service/Unix/ Read the top of the locast.service file and follow the instructions.

This is a VERY active project and will have much more to come. Sorry about no install instructions for unix. Hopefully, these will suffice for now. For windows, it works very well. If you want to just try it out, give the windows installer a shot. One note is that ffmpeg is no longer required during the install, so you can skip that. Once installed, the service will be installed into the Windows OS, but not running. You can go into Windows Services and find TVHeadend-Locast service and start it.

One other note. If you get the username/password messed up and it does not log in, the software places a "login_invalid" marker in the config.ini. This prevents the app from locking your account out of the locast server for an hour. By removing that line, it will retry.

It will also play with Windows Media Player and other MS Windows media apps, but VLC is the cleanest and most automated.

RE: Locast interface (appliance) - Added by Alistair Ruckus almost 2 years ago

i love this, i'm using it with tvheadend server with kodi (coreelec) client.

It does have it's issues though, it sometimes goes out of sync or freezes on various channels but I do understand this is a work-in-progress.

thank you for your hard work.

RE: Locast interface (appliance) - Added by K Shea almost 2 years ago

Thanks, got it working in Ubuntu Server following the Debian instructions (already had this Ubuntu Server instance running for another project), but when I start it from the command line the first thing I see is this:

Unable to load cryptography module, will not encrypt passwords
Unable to load pip module to install upgrades
Unable to load cryptography module, will not encrypt passwords

It still works, but does that mean there is something else that needs to be installed?