Add stream info for direct playing in Kodi 19 (#30)

This commit is contained in:
Michaël Arnauts 2020-06-02 22:55:50 +02:00 committed by GitHub
parent c8781424c1
commit 3902a93aa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,7 +30,7 @@ class IPTVManager:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', self.port)) sock.connect(('127.0.0.1', self.port))
try: try:
sock.send(json.dumps(func())) # pylint: disable=not-callable sock.send(json.dumps(func()).encode()) # pylint: disable=not-callable
finally: finally:
sock.close() sock.close()
@ -44,7 +44,8 @@ class IPTVManager:
item = dict( item = dict(
id=channel.get('iptv_id'), id=channel.get('iptv_id'),
name=channel.get('name'), name=channel.get('name'),
logo='special://home/addons/{addon}/resources/logos/{logo}'.format(addon=kodiutils.addon_id(), logo=channel.get('logo')), logo='special://home/addons/{addon}/resources/logos/{logo}'.format(addon=kodiutils.addon_id(),
logo=channel.get('logo')),
preset=channel.get('iptv_preset'), preset=channel.get('iptv_preset'),
stream='plugin://plugin.video.viervijfzes/play/live/{channel}'.format(channel=key), stream='plugin://plugin.video.viervijfzes/play/live/{channel}'.format(channel=key),
vod='plugin://plugin.video.viervijfzes/play/epg/{channel}/{{date}}'.format(channel=key) vod='plugin://plugin.video.viervijfzes/play/epg/{channel}/{{date}}'.format(channel=key)
@ -59,6 +60,11 @@ class IPTVManager:
"""Return JSON-EPG formatted information to IPTV Manager""" """Return JSON-EPG formatted information to IPTV Manager"""
epg_api = EpgApi() epg_api = EpgApi()
try: # Python 3
from urllib.parse import quote
except ImportError: # Python 2
from urllib import quote
results = dict() results = dict()
for key, channel in CHANNELS.items(): for key, channel in CHANNELS.items():
iptv_id = channel.get('iptv_id') iptv_id = channel.get('iptv_id')
@ -74,7 +80,9 @@ class IPTVManager:
title=program.program_title, title=program.program_title,
description=program.description, description=program.description,
image=program.cover, image=program.cover,
available=bool(program.video_url)) stream=kodiutils.url_for('play_from_page',
channel=key,
page=quote(program.video_url, safe='')) if program.video_url else None)
for program in epg if program.duration for program in epg if program.duration
]) ])