tgorgdotcom / locast2plex

A very simple script to connect locast to Plex's live tv/dvr feature.
MIT License
232 stars 43 forks source link

With some tweaks this works for MythTV as well.. #158

Open Guyverix opened 3 years ago

Guyverix commented 3 years ago

Dont worry not a bug!

Did not know if you were interested in supporting MythTV as well, since it would take a minor route add for the generated 3mu file to work out of the box. I was able to add locast2plex by changing the m3u to look like this:

1) had to remove the xml stuff from the EXT3MU 2) has to make a "tuner","channel number" in the EXTINF line.

I did not add the MythTV stuff for the XMLID, since going this route would allow MythTV versions for the last 8 years to work with your code, and multiple vars would not need to be supported long term. MythTV does NOT support the logo ingestion in the way given here, so that will not "update" the mythtv system.

`

EXTM3U

EXTINF:1,1 channelID="1572389490750" tvg-num="4.1" tvg-name="ABC" tvg-id="1572389490750" tvg-logo="https://static.locastnet.org/roku/Seattle/ABC.png" group-title="Locast2Plex",KOMODT

http://192.168.15.132:6077/watch/1572389490750 `

tgorgdotcom commented 3 years ago

Hmmm, this is pretty cool. I would need to test to see if the changes would affect other media servers. At the very least though, I could make this an option in the config.

twin19 commented 3 years ago

Have you given any more thought to this? This would be a great thing to add since mythtv is free out of the box.

Guyverix, what exactly did you have to do to get it working with mythtv?

Guyverix commented 3 years ago

I am still using V0.29, not latest so there may be some differences, but attaching screenshots of what I am messing with..

Stream is slow to start, but DOES start, I do have some choppy video issues, and recordings are unstable and fail at odd times. Suspect the buffer needs increased so that Myth does not choke on it

Selection_018 Selection_019 Selection_020

ecowitness commented 3 years ago

I also use locast2plex with mythtv. I am on version 31. I have run mythtv in one form or another for almost 20 years.

I recently moved 1050 miles and cannot see any broadcast antenna from my new house. I did without TV reception for a while. Then I found locast. Then I found locast2plex.

I had used several silicondust hdhomerun receivers at my previous house. Mythtv worked well with them. I liked the idea of the silicondust interface in locast2plex. I wasn't happy with how it worked.

I didn't want to clutter up mythtv with a lot of locast specific information, like SID, a seemingly random string of digits. I preferred the silicondust manner of v2.1 for a virtual channel. I have modified the code in tuner_interface.py at contentPath.startswith('/auto/v') to accept 2.1 and transform that into a SID for further internal use. The "auto" means "pick a tuner" to the silicondust. The protocol also allows a specific tuner. Specifying a tuner to locast2plex would be dangerous.

With this new format, I can easily put a network stream into VLC or some other player without trying to remember a SID. I will add that I was using VLC before I got my mythtv working. The local TV guide in the newspaper has virtual channels and we used that for quite a while until I got mythtv configured to use schedulesdirect again.

Those who are not familiar with mythtv must understand that it is a large and somewhat awkward software. It requires a LOT of configuration and the doc is better than it was, but is far from perfect. To get it to work with locast2plex is not trivial.

Because I was in a hurry at the time, I used the mythexternrecorder interface rather than the IPTV recorder. One advantage to the mythexternrecorder is that it uses a flat file for configuration. A big disadvantage is that you only seem to get one of these types of recorders, meaning you can't record more than one program at a time.

I would be interested in discussing mythtv and locast2plex with other users. Please post back if you find a medium for conversation.

dkropman-Slalom commented 3 years ago

I am also looking for how to get locast to work with mythtv. Currently using plex to record and then mythfrontend to play. But would like to remove plex.

ecowitness commented 3 years ago

Mythtv is a cantankerous bit of software. The reason that I use it is that we have used it at our home for over 17 years. There is an acceptance factor here and familiarity with the keyboard commands in order to watch what has been recorded. We have a large collection of recorded video that is available anywhere on our lan. If I were to do it over, I might look at something newer. I installed Plex, looked at it, and then turned it off. I have gone off to work on other projects that needed attention and have not come back to this one.

I was using HdHomeRun (HDHR) with mythtv 29 before I moved. I had multiple antennas and HDHR boxes. Now I have neither and cannot see an antenna over the mountains. The appeal of using locast2plex (L2P) as an HDHR emulator got me started. I was using L2P with VLC before I got mythtv 31 up and running. The changes to 31 discouraged me and I almost gave up.

First, my implementation depends upon L2P. I have modified L2P to:

  1. use a virtual channel number (i.e., 2.1) instead of the sid that locast prefers. This is only a few lines of python code. The mod simply goes thru the locast channels until it finds the virtual channel and then uses matching sid instead. I made this mod because the HDHR interface manual described /auto/v2.1, where auto was the selection of the tuner. This removes any knowledge of the sid (and therefore locast) from mythtv. They stand alone. It is also much easier to type the /auto/v2.1 into VLC than try to type in that longish sid. Plus, before I had mythtv 31 running, I was relying upon the tv listings in the newspaper. which only have virtual channels.

  2. implemented a new command to return the absolute variant playlist URL. It was my plan to revisit this and get the locast stream directly within mythtv, rather than via a stream from L2P. Then L2P would do logon and L2P specific interaction, like obtain the master playlist, while the program stream would be handled somehow by mythtv. This also would allow direct control of when to end the stream with locast and avoid the stream hanging issue. This is my work in progress.

The concept of a "tuner" in L2P is a more or less random choice of a processing thread. When any http request comes to get a stream from locast, a "tuner" is marked busy, the master playlist is acquired for the appropriate sid, L2P looks at the playlist to determine which variant playlist to use and then starts ffmpeg up to get the stream from locast and pipe it into a transport stream sent back to the caller. The stream continues until the pipe breaks. Then the "tuner" is freed. The "tuner" exists, more or less, to keep you from starting too many streams with locast.

I was in a hurry to get mythtv to work and ended up using the external recorder. I couldn't get the HDHR interface to work to my liking. This external recorder is not straightforward. It requires a configuration file of its own. There is also a limit of one recording at a time. It works. L2P gets the stream from locast, sends it to the external recorder, which in turn sends it into mythtv where it is written to disk. The stream is "tired" before it gets written to disk. There is also an issue with mythtv starting the external recorder twice to record a program, once to sample it for acceptability and the second to do the recording.

I use schedules direct for my program guide rather than the one provided by locast. The method to load the program guide into mythtv involves some extra work. I'm not sure how much of this was due to changes between 29 and 31. I did not look at how to get the locast guide into mythtv.

I had to go thru a manual effort to create a mapping between the virtual channel, the sid, and the xmltvid. I did this in a spreadsheet once , then used the spreadsheet to update mythtv and create the files that it needed. This involved a side by side comparison of the locast channel lineup and the lineup provided by schedules direct.

Do you still think that you would like to change to mythtv? The other method in this thread may be easier for you to implement. Are you already running L2P? What version of mythtv are you running? How do you have Plex and mythtvfrontend connected? So many questions.