eracknaphobia / service.psvue.epg

Kodi PS Vue companion service for building playlist and epg using simple iptv pvr
GNU General Public License v2.0
0 stars 5 forks source link

Make IPTV Simple play PS Vue Stream directly #3

Closed eracknaphobia closed 6 years ago

eracknaphobia commented 6 years ago

Problem: Stream fails to play / open when directly passed Change the cherrypy.response.headers['Location'] to epg_play_stream(params) and have it return the ps vue stream url instead of the hardcoded one.

cherrypy.response.headers['Location'] = epg_play_stream(params)

https://github.com/eracknaphobia/service.psvue.epg/blob/950a555942317e8304baf8382bec4c1b590565ce/resources/lib/webservice.py#L95

snoopyjoe commented 6 years ago

I was looking at this last night. I'll play around with it.

DiR3Wolf commented 6 years ago

In my humble opinion, I found what I think it is a better/easier way to go about it, ditching cherrypy altogether. Please take a look at https://github.com/primaeval/plugin.video.pvr.plugin.player from primaeval. It allows iptv simple to play each channel directly from any installed video addon. I imported the psvue epg.xml from PSVue to test it, I was able to link PSVue addon and it works great on Kodi 18. Of course it is missing the logo, epg info etc, because it is not coded. So the idea would be to take this methology as a template, but strip it and make it work exclusively for PS Vue so it auto generates the playing link instead of asking the addon to match. I'll play around some more, but unfortunately, this is beyond my primitive python knowledge.

eracknaphobia commented 6 years ago

@DiR3Wolf Looks like that plugin does the same thing, fakes a good response with a dummy file and then starts playing the actually stream. Which would cause us to lose epg info on-screen too unfortunately.

class myHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        print 'HWA:'
        print dummy_vid_path
        f = open(dummy_vid_path, 'rb')
        self.send_response(200)
        self.send_header('Content-Type', 'video/mp4')
        self.end_headers()
        self.wfile.write(f.read())
        f.close()

        Last = int(ADDON.getSetting("LastPlay"))
        Now = int(time.time())
        if Now-Last>4:
            ADDON.setSetting("LastPlay","%d" % Now)
        else:
            return

        url = self.path[2:]
        listitem = ListItem(path=url)
        listitem.setInfo(type="Video", infoLabels={"mediatype": "movie", "title": "LiveTV"})
        xbmc.Player().play(url, listitem)
        return

I was also pointed by Lunatixz towards this pure python pvr. It may need some updates in order to work. Another option is to use the uEPG addon

DiR3Wolf commented 6 years ago

@eracknaphobia you are right, it doesn't fix the problem the underlying issue. However, it does look as it is simpler than cherrypy, doesn't it (at least performance wise)?

BTW, the code for uEPG addon seems to be missing, couldn't find it on Lunatixz's GitHub.

eracknaphobia commented 6 years ago

@DiR3Wolf Yeah, I agree it would be better to get away from cherrypy.

I see that uEPG links are dead now... not sure if that's on purpose or not?

DiR3Wolf commented 6 years ago

@eracknaphobia , if I switch the code to: cherrypy.response.headers['Location'] = epg_play_stream(params) as suggested, I can still play the stream, but I get an error dialog, which you can dismiss but it is annoying. No EPG info is passed. The Kodi player doesn't identify it as a live tv type.

eracknaphobia commented 6 years ago

Sounds like the epg_play_stream still has the xbmc.player.play() command in it. That would be the only way it is able to play. The error message is from iptv simple not being able to resolve the location into a playable stream. That's why I had to send it a dummy stream, to quite the unplayable message and then play the stream on my own behind the scences. My idea was to have epg_play_stream return a url to iptv simple and have it play, but it doesn't seem to pass on cookies and user-agent fwiw. Currently I'm in the process of replacing cherrypy with a much lighter approach. Hope to have more progress on stream-lining the play back after that.

DiR3Wolf commented 6 years ago

Got it. I also have some thoughts about EPG data gathering, but I don't want to hijack this issue thread as it is about playing the stream. Can I open an issue for discussion rather than going through the forum?

eracknaphobia commented 6 years ago

Sure, I would prefer that as we can better keep to a single topic.

eracknaphobia commented 6 years ago

Got it to redirect properly in this commit.

snoopyjoe commented 6 years ago

Finally got around to reading all your comments. Cherrypy does have a few issues especially in Kodi v18. Your new code eracknaphobia is pretty solid, but like you said if using v18 then it will not take advantage of inputstream. Though hls and ffmpeg on the latest nightlies are getting better. What other alternatives to CherryPy in Kodi are there?

DiR3Wolf commented 6 years ago

Adding to what @snoopyjoe said, it is working well so far in Kodi 18 (as far as playback and EPG staying on). Of course, no inputstream and channel playback/switching is super slow.

eracknaphobia commented 6 years ago

Yeah, that's a definite draw back to leaving the playback up to the PVR client. I'm not sure if there's a way to direct it to inputstream adaptive from a python service.

DiR3Wolf commented 6 years ago

I have tested the WIP branch (Kodi 18/Win10), and now the playback/channel switching takes about 4-5secs, so much improved. It also seems more stable.

Hope we can shave at least a couple more seconds through more optimizations. I heard from the grapevine the cookie authentication may be a performance factor. Have you try to reach FernetMenta to see what performance can be gained through optimization and inputstream handling by the PVR? I know he doesn't work on this exclusively, but I have seen he has helped the PVR and inputstream developers so he may lend some guidance. I know he submitted a FFMPEG patch to improve Kodi's handling of HLS streams, but AFAIK it still no added to the FFMEPG code.

DiR3Wolf commented 6 years ago

@eracknaphobia I wonder if this is of any relevance. It was added on inputstream 2.2.14 https://github.com/peak3d/inputstream.adaptive/commit/c90a3783a4a8022c7d0b41c4c701c44d0e2e809b

eracknaphobia commented 6 years ago

Closing as this issue seems to have been solved, for Kodi 18 anyway.