Skip to content

Commit

Permalink
added support for live restart (manually right now)
Browse files Browse the repository at this point in the history
  • Loading branch information
phate89 committed Jan 5, 2020
1 parent 9e3264b commit a64d178
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 14 deletions.
1 change: 1 addition & 0 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<source>https://github.com/phate89/plugin.video.videomediaset</source>
<reuselanguageinvoker>true</reuselanguageinvoker>
<news>2.0.1
- added support for live restart (manually jump to start after you start play right now)
- added brand title in episode and clip search to have better info
- added details of live event in live channels section
- improved performance reusing python env
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[B]2.0.1[/B]
- added support for live restart (manually jump to start after you start play right now)
- added brand title in episode and clip search to have better info
- added details of live event in live channels section
- improved performance reusing python env
Expand Down
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ msgid "Mostra in guida tv anche elementi non riproducibili"
msgstr "Show in tv guide unplayable items"

msgctxt "#32005"
msgid "Separa diretta da ricomincia (permette di avere una diretta continua)"
msgstr "Split live from restart (allows to have a continuous live)"

msgctxt "#32006"
msgid "Installa widevine per i contenuti protetti"
msgstr "Install widevine CDM for protected content"

Expand Down
4 changes: 4 additions & 0 deletions resources/language/resource.language.it_it/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ msgid "Mostra in guida tv anche elementi non riproducibili"
msgstr "Mostra in guida tv anche elementi non riproducibili"

msgctxt "#32005"
msgid "Separa diretta da ricomincia (permette di avere una diretta continua)"
msgstr "Separa diretta da ricomincia (permette di avere una diretta continua)"

msgctxt "#32006"
msgid "Installa widevine per i contenuti protetti"
msgstr "Installa widevine per i contenuti protetti"

Expand Down
2 changes: 1 addition & 1 deletion resources/lib/mediaset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
self.__tracecid = ''
self.__cwid = ''
self.anonymousLogin()
super(rutils.RUtils, self).__init__()
rutils.RUtils.__init__(self)

def __getAPISession(self):
res = self.SESSION.get(
Expand Down
51 changes: 39 additions & 12 deletions resources/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ def canali_live_root(self):
if prog['startTime'] <= now <= prog['endTime']:
guid = chan['guid']
chans[guid] = {'title': '{} - {}'.format(chan['title'],
prog["mediasetlisting$epgTitle"]),
kodiutils.py2_encode(
prog["mediasetlisting$epgTitle"])),
'infos': _gather_info(prog),
'arts': _gather_art(prog),
'restartAllowed': prog['mediasetlisting$restartAllowed']}
Expand All @@ -366,11 +367,18 @@ def canali_live_root(self):
chn = chans[prog['callSign']]
if chn['arts'] == {}:
chn['arts'] = _gather_art(prog)
# if chn['restartAllowed']:
# kodiutils.addListItem(chn['title'],
# {'mode': 'live', 'guid': prog['callSign']},
# videoInfo=chn['infos'], arts=chn['arts'])
# else:
if chn['restartAllowed']:
if kodiutils.getSettingAsBool('splitlive'):
kodiutils.addListItem(chn['title'], {'mode': 'live',
'guid': prog['callSign']},
videoInfo=chn['infos'], arts=chn['arts'])
continue
vid = self.__ottieni_vid_restart(prog['callSign'])
if vid:
kodiutils.addListItem(chn['title'], {'mode': 'video', 'pid': vid},
videoInfo=chn['infos'], arts=chn['arts'],
isFolder=False)
continue
data = {'mode': 'live'}
vdata = prog['tuningInstruction']['urn:theplatform:tv:location:any']
for v in vdata:
Expand All @@ -382,8 +390,24 @@ def canali_live_root(self):
videoInfo=chn['infos'], arts=chn['arts'], isFolder=False)
kodiutils.endScript()

def __ottieni_vid_restart(self, guid):
res = self.med.OttieniLiveStream(guid)
if ('currentListing' in res[0] and
res[0]['currentListing']['mediasetlisting$restartAllowed']):
url = res[0]['currentListing']['restartUrl']
return url.rpartition('/')[-1]
return None

def canali_live_play(self, guid):
res = self.med.OttieniLiveStream(guid)
infos = {}
arts = {}
title = ''
if 'currentListing' in res[0]:
self.__imposta_tipo_media(res[0]['currentListing']['program'])
infos = _gather_info(res[0]['currentListing'])
arts = _gather_art(res[0]['currentListing']['program'])
title = ' - ' + infos['title']
if 'tuningInstruction' in res[0]:
data = {'mode': 'live'}
vdata = res[0]['tuningInstruction']['urn:theplatform:tv:location:any']
Expand All @@ -392,13 +416,14 @@ def canali_live_play(self, guid):
data['id'] = v['releasePids'][0]
else:
data['mid'] = v['releasePids'][0]
kodiutils.addListItem(kodiutils.LANGUAGE(32137), data, isFolder=False)
kodiutils.addListItem(kodiutils.LANGUAGE(32137) + title, data, videoInfo=infos,
arts=arts, isFolder=False)
if ('currentListing' in res[0] and
res[0]['currentListing']['mediasetlisting$restartAllowed']):
url = res[0]['currentListing']['restartUrl']
vid = url.rpartition('/')[-1]
kodiutils.addListItem(kodiutils.LANGUAGE(
32138), {'mode': 'video', 'pid': vid}, isFolder=False)
kodiutils.addListItem(kodiutils.LANGUAGE(32138) + title, {'mode': 'video', 'pid': vid},
videoInfo=infos, arts=arts, isFolder=False)
kodiutils.endScript()

def riproduci_guid(self, guid):
Expand All @@ -421,7 +446,9 @@ def riproduci_video(self, pid, live=False):
kodiutils.showOkDialog(kodiutils.LANGUAGE(32132), kodiutils.LANGUAGE(32133))
kodiutils.setResolvedUrl(solved=False)
return
props = {'manifest_type': 'mpd'}
headers = '&User-Agent={useragent}'.format(
useragent=self.ua)
props = {'manifest_type': 'mpd', 'stream_headers': headers}
if data['security']:
user = kodiutils.getSetting('email')
password = kodiutils.getSetting('password')
Expand All @@ -433,10 +460,10 @@ def riproduci_video(self, pid, live=False):
kodiutils.showOkDialog(kodiutils.LANGUAGE(32132), kodiutils.LANGUAGE(32135))
kodiutils.setResolvedUrl(solved=False)
return
headers += '&Accept=*/*&Content-Type='
props['license_type'] = 'com.widevine.alpha'
props['stream_headers'] = headers
url = self.med.OttieniWidevineAuthUrl(data['pid'])
headers = 'Accept=*/*&Content-Type=&User-Agent={useragent}'.format(
useragent=self.ua)
props['license_key'] = '{url}|{headers}|R{{SSM}}|'.format(url=url, headers=headers)

headers = {'user-agent': self.ua,
Expand Down
3 changes: 2 additions & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<setting label="32002" type="text" id="password" option="hidden" default=""/>
<setting label="32003" type="number" id="itemsperpage" default="500"/>
<setting label="32004" type="bool" id="fullguide" default="false"/>
<setting label="32005" type="action" action="RunScript(script.module.inputstreamhelper,widevine_install)" visible="!system.platform.android"/>
<setting label="32005" type="bool" id="splitlive" default="false"/>
<setting label="32006" type="action" action="RunScript(script.module.inputstreamhelper,widevine_install)" visible="!system.platform.android"/>
</settings>

0 comments on commit a64d178

Please sign in to comment.