[Solved] Pluto TV on Myth

For discussion related to MythTV which doesn't belong in another forum.

Moderator: Forum Moderators

Kneel
Newcomer
Posts: 5
Joined: Thu Jul 12, 2018 11:59 pm
Australia

[Solved] Pluto TV on Myth

Post by Kneel »

Hi all,

Fairly recent "noobie", so please forgive me if this has been asked before (can't find it though...)

My setup is a celeron 3150 (4 cores, 4 threads) 4G RAM, 64G flash and 1TB HDD. Flash is mounted RO and holds all the code, HDD holds recordings, config files that might need to change etc. So it's more an appliance than a HTPC, meaning the WAF/GAF is a high bar. I have an individual tuner for each multiplex in my area ( 5 muxes, about 37 channels all up), with a mumudvb instance for each one, streaming to http unicast on the loopback adaptor. This is all good, other than the known 28/fixes issue with IPTV stream FE channel change crashing the BE, but I have found the patch for this, and am happy to attempt a build on patched sources, or even install 29 if I must.

Now the background is done...

I have a Pluto TV account I am using on a Roku - all fine and dandy.
I want this to be available as a "standard" channel in MythTV backend, so view/record/epg etc etc just like anything else I get (FTA).

EPG part is done - this is no particular problem for me, just a little fiddly because of several things about the Pluto EPG, such as bad start/stop times in the listings (so need to keep a running start/stop time list and add duration etc etc - nasty, but more tedious than hard). I even added external EPG data where Pluto points to a HLS m3u(8) at a third party server (eg RT USA) and just lists "Live program" in every timeslot. So that is fixed (although I may need to modify for start/stop correct times due to the odd timezone they use)

Problem is this: not all "channels" on Pluto TV are "endless" m3u(8) playlists - some are (like RT USA), but most are playlists for an individual show, together with a list of streams for the ads and when to show them. So you can't just point at a single m38(u), you need to download the EPG, find the playlist corresponding to the show on the channel you want to watch, and start THAT. Then, when that ends, you have to "rinse and repeat" so the next program on the channel starts at the time the EPG says it should - perhaps needing to add "filler" content.

This will need to be a daemon I think - listen on network for "channel change" commands (send by record_start/stop external scripts of MythTV), start/stop VLC instances as appropriate, update the playlist when a vlc instance hits end of stream, maybe add some "fill in" streams to cover for the ads and the timing issues that introduces etc.

I am NOT using VLM to do this because it doesn't play nice with https m3u(8) stream uris. So I am starting an instance of vlc when a channel is "tuned", sending a unicast http mpeg/ts stream to a loopback network port (based on channel number, so m3u for Myth is static), keeping a count of how many "listeners" want the channel and stopping the vlc streamer when the last "listener" goes away (recording-start/stop event scripts). I have tested this works and it does, so just the "channel management" or "stream management" bit to do.

Two reasons for the post:

1) does this already exist? (no point in re-inventing the wheel)
2) is anyone else interested in this, especially as a dev and/or tester?

I can do this on my own (and will), but it will take a while to get right, so any helpers/testers would be appreciated.

I would also be very happy to hear of something similar that I can re-jig to suit, or any ideas on how to manage the "channels" - it seems like a bit of a headache to get set-up, but I am determined to get it working. As above, the basics are there, and I can get the streams, just need to make it all transparent to the (l)user.
Tips?
Help?

Anyone? Bueller...
Kneel
Newcomer
Posts: 5
Joined: Thu Jul 12, 2018 11:59 pm
Australia

Re: Pluto TV on Myth

Post by Kneel »

Quick follow-up that might generate some interest :-)

Once I get this working (the Pluto TV stuff), I intend to move on to creating something similar, but with some of the VoD stuff available on a Roku.
Intent is a similar setup to Pluto - that is, grab available streams, fake up an EPG and so on. This will obviously be considerably more complex, but would let you do things like record all episodes of "Arrow" that appear on TheCW for instance.

Hope that whets your appetite as a tester... :-)
ibedonc
Junior
Posts: 50
Joined: Wed Dec 14, 2016 3:54 pm
United States of America

Re: Pluto TV on Myth

Post by ibedonc »

you get anywhere with this ?
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: Pluto TV on Myth

Post by wesnewell »

Just found pluto.tv. All I can say is wow. Hundreds of free channels and on demand. Would be great to integrate this into mythtv for recording.
Last edited by wesnewell on Sun Mar 24, 2019 4:55 pm, edited 1 time in total.
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
urbnsr
Junior
Posts: 39
Joined: Wed Oct 22, 2014 11:50 am
United States of America

Re: Pluto TV on Myth

Post by urbnsr »

Anybody have any info on this site? I can seem to pull out stream addresses from a current browser's code to play in VLC, but those addresses are only temporary plus a user interface would still be needed. Quality looks good!
User avatar
paulh
Developer
Posts: 909
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Pluto TV on Myth

Post by paulh »

Pluto TV looks interesting but at least when looking at the web site here in the UK it is very light on information, no way to even see what programs are on each channel, and very slow to load which doesn't give me much confidence they are here to stay. In any case most people use MythTV to get away from the linear TV dictated by broadcasters so when they say "Pluto TV brings back the linear TV you love." that's not what most MythTV users want.
healthydoctor
Newcomer
Posts: 1
Joined: Tue Mar 26, 2019 2:14 am
Greenland

Re: Pluto TV on Myth

Post by healthydoctor »

I was always using MythTV, and have been using Pluto TV in apknite for a month now. it's not much to compare between the two, because it depends on individual to judge and would say most of the people having tried pluto will stick with it as pluto offers more than 100 channels and saying the adv is not so many to be bothered. so personally i pick pluto
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: Pluto TV on Myth

Post by wesnewell »

If I had to choose, I'd stick with mythtv simply because I get 115 free channels ota here, and I can record them, play them when I want , FF, skip commercials, etc., etc., etc. Can't even pause plutotv afaik, can't get captions to work, or record it, or any of the things you can do with mythtv. But if I lived somewhere was there wasn't a lot of ota stations, it would be an option.
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
urbnsr
Junior
Posts: 39
Joined: Wed Oct 22, 2014 11:50 am
United States of America

Re: Pluto TV on Myth

Post by urbnsr »

I was hoping to use Pluto TV within MythTV avoiding a choice. I can't find a native Pluto TV user interface for a Linux box. I can't get the Windows version to play nice using Wine, so that seems out.
mitchd123
Newcomer
Posts: 7
Joined: Wed Apr 03, 2019 8:44 pm
United States of America

Re: Pluto TV on Myth

Post by mitchd123 »

There's a nice plugin for Kodi to watch PTV. There is no plug-in to Myth that I'm aware of at the moment, and how I landed on this thread. The pluggin for Kodi has a rather long load time, and the content is someone different than what I see on Android, but it works remarkably well. The channel guide will show chunks of movies/shows on each channel. So when you start, you start at the beginning. Commercials are injected. I'd love to find a Myth connector to time-shift. Currently I used Kodi as my frontend at the TV, and myth as my backend.
urbnsr
Junior
Posts: 39
Joined: Wed Oct 22, 2014 11:50 am
United States of America

Re: Pluto TV on Myth

Post by urbnsr »

Does the Kodi plugin have access to the full list of Pluto TV channels or just a subset? On-Demand access?
Does the plugin reveal the address to the channel's stream? I'm not looking to find a way to block their commercials, but just more content availability.
User avatar
paulh
Developer
Posts: 909
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Pluto TV on Myth

Post by paulh »

I tried it here in the UK and didn't get any channels at all but I don't have a Pluto account and connected as a guest. Do you need to sign in to get the channels? Same thing for the EPG nothing found. Did get some on demand content, only tried to play one item which despite the English title turned out to be some obscure Japanese comedy :roll: . I could be wrong but kind of looks like they are just aggregating content already available on YouTube and Vimeo etc. Maybe there is more stuff available in the US?
Gnicko
Newcomer
Posts: 9
Joined: Sat Nov 01, 2014 2:11 am
United States of America

Re: Pluto TV on Myth

Post by Gnicko »

wesnewell wrote:
Tue Mar 26, 2019 7:11 am
If I had to choose, I'd stick with mythtv simply because I get 115 free channels ota here, and I can record them, play them when I want , FF, skip commercials, etc., etc., etc. Can't even pause plutotv afaik, can't get captions to work, or record it, or any of the things you can do with mythtv. But if I lived somewhere was there wasn't a lot of ota stations, it would be an option.
I think that's the whole point. He wants to set up Pluto within Myth to add all those capabilities to the Pluto content, and add programming content for someone who maybe only gets a few channels OTA...

A worthwhile project I'd imagine....
urbnsr
Junior
Posts: 39
Joined: Wed Oct 22, 2014 11:50 am
United States of America

Re: Pluto TV on Myth

Post by urbnsr »

I did kind of come up with work-around:

viewtopic.php?f=2&t=3509

I don't really use it anymore, but someone may find it useful.
Kneel
Newcomer
Posts: 5
Joined: Thu Jul 12, 2018 11:59 pm
Australia

Re: Pluto TV on Myth

Post by Kneel »

[SOLVED]

Since my original post, several things have changed.

First, my original backend/frontend machine died due to hardware failure - a dead power supply destroyed the internals.
The replacement is an industrial, fanless core i3/@2.3GHz/4G RAM/64G mSATA SSD/2T HDD, 5 X USB SDR-based tuners (I have 5 transponders "in view").
Runs Ubuntu 18.04 LTS (updates and crash reporting turned off)
In the process of re-creating the backend, I re-investigated Pluto TV and found...

Secondly, Pluto changed their API and playlist arrangement, which - once I figured it out - is much nicer.
In the old Pluto API/Playlist arrangement, the guide gave you a static M3U and a list of ads for each program, the player itself had to insert the ads. In this arrangement, you would need a "manager" program to add each new program to the M3U you are streaming. Ugly.
In the new API/Playlist arrangement, there is a dynamic M3U that always plays the Pluto live "Channel".
The only trick with this is to use a "Device" type other than "web" - the web device uses encrypted M3U's that vlc chokes on when you hit an advertisment. Fortunately, I found a Samsung Smart TV device type/M3U playlist URI that "by-passes" that encryption.

So this is what I set up:
Each SDR has a Mumudvb instance running that de-muxes each transponder into streams, and makes them available via HTTP on the local loopback network adapter.
Mytth backend uses a freebox "card", with an M3U file listing the (local) URI for each channel.
Guide data comes from an external source run on a cron job.
I'm in Australia, so I use shepherd for this and have a getflix geo-unblocker for pluto access.

Because I wanted to avoid any possible channel number "clashes" between PlutoTV and my FTA channels, I added 1,000 to each Pluto TV Channel number, so for example PlutoTV channel 75 is channel 1075 on my backend/guide. This is "taken care of" by my event script, that simply looks for channel numbers over 1000, and then calls the pluto script below with 1000 subtracted from the channel number it got.

It might seem that you can simply add the Pluto M3U location for each Pluto channel, and while I haven't tried this, I'm sure it would work.
Instead, what I do is use VLC to re-stream each channel on the backend local loopback adapter, the same as the FTA channels. I have a couple of scripts to "connect" these and start/stop VLC instances "on demand", which are triggered by the backend "Record start" and "record stop" events. Guide data comes from an external script, again on a cron job.

As a bit of an aside, I also created a set of "quick and dirty" scripts that are called by the backend, and which then call every script/program in a specified directory in standard alpha-numeric sort order - I have added a single version, which should be easy enough for you to modify if you want.

So what's in the attachment?

These are perl scripts. You may find missing library errors, in which case you can simply add them with the cpan command - if it complains about "Data::Dumper" not found, then "cpan Data::Dumper" will fix that, for example.

There may also be some hard-coded paths to a directory you likely don't have on your system - /usr/local/mythbin and (without checking) perhaps also my home directory.
Because I want an "appliance" for the "girlfriend acceptance factor" to be high, I run my root filesystem (on the mSATA SSD) read only, and link this directory to a partition on a "real" (ie magnetic spinning storage) HDD. I also have such links for /tmp and /var. You may want to modify these hard-coded paths, or just add a soft link to somewhere else to "get around" this issue.

RECORD_STARTED: This is the above-mentioned script to call an entire directory of scripts from a single MythTV event - in this case, the "recording started" event. It expects to be called with %CARDID% %CHANNELID% and %SECS%, which it then passes to each script when it runs it. The logic is fairly strightforward, and I think anyone contemplating getting PlutoTV working based on my uploads would have no trouble modifying this to call different directories etc and/or making multiple copies for different events.

get_pluto_icons: downloads a channel icon for each Pluto TV channel into the current directory. Each icon is named the name of the channel as per the Pluto guide data, with spaces changed to underscores. These are PNG files.

pluto: you can call this from both the recording start and recording stop events.
Syntax: pluto <start|stop|status> <pluto channel number>
it forks off a vlc instance that restreams the selected Pluto channel to http://127.0.0.1 on port 9000+pluto channel number (so pluto channel number 601 on port 9601, pluto channel 1001 on port 10001)
You can call it multiple times to start the same channel, it will only ever run one instance per channel (handy when you have recording "overlap" on consecutive programs on a channel - only stream it once!). It keeps a count of "requests" for each channel, and when the count drops to zero, kills the vlc instance. It also checks that the vlc instance is actually still running and if it's called with start and thinks there should already be a running vlc, but theres not, it will start one and "correct" it's view of how many "requests" it has (so, no issue with a power interruption, for example)
Call it with "start" on record start event, and "stop" on record stop event.
Call it from a shell with "status" to see how many clients "want" this channel, and the PID of any vlc running for that channel.

pluto_start_channel: actually starts the vlc instance for a pluto channel. Called by "pluto" script.

grab.pluto: gets pluto guide data and outputs an xmltv format file you can pass to mythfilldatabase. Due to Pluto guide data only having reliable data for about 2 hours, I run this every 15 minutes as a cron job to keep Myth guide data up to date.

pluto_make_m3u: creates an M3U file of Pluto TV channels designed to work with the above vlc restreaming. This is a "stand-alone" M3U, which I then manually "marge" with my FTA list.

***NOTE***
the make_m3u and grab scripts use my above noted "pluto+1000" for channel numbers.

***NOTE***
PlutoTV is NOT a "static" channel arrangement - they add and remove channels "on a whim", as well as re-arranging them (moving channel numbers and changing their name and/or content). I haven't yet "hit" an issue with this, but it may bite me (and you, if you use this) at some point.
If, as and when this happens, I may re-visit the coding in these scripts to allow for "re-mapping" channels "auto-magic-ally" based on channel name.
Attachments
Pluto.tar
(60 KiB) Downloaded 122 times
Post Reply