Skip to content

Commit

Permalink
Merge pull request #8 from cache-sk/master
Browse files Browse the repository at this point in the history
Hotfix pre Kodi 18 Leia
  • Loading branch information
mx3L authored Apr 13, 2019
2 parents 557611b + 69d20dc commit 07c8227
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 7 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<addon id="plugin.video.rtvs.sk" name="rtvs.sk" provider-name="Maros Ondrasek" version="1.0.8">
<addon id="plugin.video.rtvs.sk" name="rtvs.sk" provider-name="Maros Ondrasek" version="1.8.0">
<requires>
<import addon="xbmc.python" version="2.1.0" />
<import addon="script.module.stream.resolver" version="1.6.13" />
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[B]1.8.0:[/B]
- Kodi 18 Leia update
- streams from archive was stuttering due ffmpeg bug, solved with InputStream Adaptive
[B]1.0.8:[/B]
- ???
[B]1.0.7:[/B]
- added all live streams
- default quality option is set back to always ask
Expand Down
6 changes: 6 additions & 0 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def play(self, item):
stream['url'] += '|%s=%s' % (header, stream['headers'][header])
print 'Sending %s to player' % stream['url']
li = xbmcgui.ListItem(path=stream['url'], iconImage='DefaulVideo.png')
if stream['quality'] == 'adaptive':
li.setProperty('inputstreamaddon','inputstream.adaptive')
li.setProperty('inputstream.adaptive.manifest_type','hls')
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
xbmcutil.load_subtitles(stream['subs'])

Expand All @@ -63,6 +66,9 @@ def select_cb(resolved):
stream_parts = []
stream_parts_dict = {}

if len(resolved) == 1 and resolved[0]['quality'] == 'adaptive':
return resolved[0]

for stream in resolved:
if stream['surl'] not in stream_parts_dict:
stream_parts_dict[stream['surl']] = []
Expand Down
5 changes: 5 additions & 0 deletions resources/language/Czech/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@
<string id="30061">Nejsledovanější</string>
<string id="30070">Podobná videa</string>
<string id="31000">Data o použití jsou zaslána pouze v okamžiku, kdy spustíte přehrávání nebo stahování videa doplňkem.</string>

<string id="31010">Kodi 18 Leia</string>
<string id="31011">Používáte Leiu, která má problém se skákáním videa z archivu.</string>
<string id="31012">Prosím, nainstalujte / aktivujte si InputStream Adaptive plugin z oficiálního repozitáře a nastavte si ho.</string>
<string id="31013">Po instalaci / aktivaci je nutný restart Kodi.</string>
</strings>
5 changes: 5 additions & 0 deletions resources/language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@
<string id="30061">Most watched</string>
<string id="30070">Related videos</string>
<string id="31000">Usage of plugin is tracked whenever you play or download video.</string>

<string id="31010">Kodi 18 Leia</string>
<string id="31011">You are using Leia, which have problems with video stuttering from archive.</string>
<string id="31012">Please install / activate InputStream Adaptive plugin from official repo and configure it.</string>
<string id="31013">Kodi restart is required after installation / activation.</string>
</strings>
5 changes: 5 additions & 0 deletions resources/language/Slovak/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@
<string id="30061">Najsledovanejšie</string>
<string id="30070">Podobné videá</string>
<string id="31000">Dáta o použití sú zasláné len v okamžiku, keď spustíte prehrávánie alebo sťahovanie videa doplnkom.</string>

<string id="31010">Kodi 18 Leia</string>
<string id="31011">Používate Leiu, ktorá má problém so skákaním videa z archívu.</string>
<string id="31012">Prosím, nainštalujte / aktivujte si InputStream Adaptive plugin z oficiálneho repozitára a nastavte si ho.</string>
<string id="31013">Po inštalácii / aktivácii je potrebný reštart Kodi.</string>
</strings>
54 changes: 48 additions & 6 deletions resources/lib/rtvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
import util
from provider import ContentProvider

import json
import xbmc, xbmcaddon, xbmcgui

START_TOP = '<h2 class="nadpis">Najsledovanejšie</h2>'
END_TOP = '<h2 class="nadpis">Najnovšie</h2>'
TOP_ITER_RE = '<li(.+?)<a title=\"(?P<title>[^"]+)\"(.+?)href=\"(?P<url>[^"]+)\"(.+?)<img src=\"(?P<img>[^"]+)\"(.+?)<p class=\"day\">(?P<date>[^<]+)<\/p>(.+?)<span class=\"programmeTime\">(?P<time>[^<]+)(.+?)<\/li>'
Expand Down Expand Up @@ -84,6 +87,25 @@ def get_streams_from_manifest_url(url):
result.sort(key=lambda x:x['bandwidth'], reverse=True)
return result

def is_kodi_leia():
version = xbmc.getInfoLabel('System.BuildVersion').split(' ')[0]
if (float(version) >= 18):
#chceck if is inputstream.adaptive present
payload = {'jsonrpc': '2.0','id': 1,'method': 'Addons.GetAddonDetails','params': {'addonid': 'inputstream.adaptive','properties': ['enabled']}}
response = xbmc.executeJSONRPC(json.dumps(payload))
data = json.loads(response)
print(data)
if ('error' not in data.keys() and
'result' in data.keys() and
'addon' in data['result'].keys() and
'enabled' in data['result']['addon'].keys() and
data['result']['addon']['enabled']):
return True
else:
scriptid = 'plugin.video.rtvs.sk'
addon = xbmcaddon.Addon(id=scriptid)
xbmcgui.Dialog().ok(addon.getLocalizedString(31010), addon.getLocalizedString(31011), addon.getLocalizedString(31012), addon.getLocalizedString(31013))
return False

class RtvsContentProvider(ContentProvider):

Expand Down Expand Up @@ -276,13 +298,23 @@ def resolve(self, item, captcha_cb=None, select_cb=None):
channel_id = item['url'].split('.')[1]
data = util.request("http://www.rtvs.sk/json/live5.json?c=%s&b=mozilla&p=linux&v=47&f=1&d=1"%(channel_id))
videodata = util.json.loads(data)[0]
for stream in get_streams_from_manifest_url(videodata['sources'][0]['file']):
if is_kodi_leia():
#return playlist with adaptive flag
item = self.video_item()
item['title'] = videodata.get('title','')
item['url'] = stream['url']
item['quality'] = stream['quality']
item['url'] = videodata['sources'][0]['file']
item['quality'] = 'adaptive'
item['img'] = videodata.get('image','')
result.append(item)
else:
#process m3u8 playlist
for stream in get_streams_from_manifest_url(videodata['sources'][0]['file']):
item = self.video_item()
item['title'] = videodata.get('title','')
item['url'] = stream['url']
item['quality'] = stream['quality']
item['img'] = videodata.get('image','')
result.append(item)
else:
video_id = item['url'].split('/')[-1]
self.info("<resolve> videoid: %s" % video_id)
Expand All @@ -291,13 +323,23 @@ def resolve(self, item, captcha_cb=None, select_cb=None):
url = "%s/%s" % (v['baseUrl'], v['url'].replace('.f4m', '.m3u8'))
#http://cdn.srv.rtvs.sk:1935/vod/_definst_//smil:fZGAj3tv0QN4WtoHawjZnKy35t7dUaoB.smil/manifest.m3u8
if '/smil:' in url:
for stream in get_streams_from_manifest_url(url):
if is_kodi_leia():
#return playlist with adaptive flag
item = self.video_item()
item['title'] = v['details']['name']
item['surl'] = item['title']
item['url'] = stream['url']
item['quality'] = stream['quality']
item['quality'] = 'adaptive'
item['url'] = url
result.append(item)
else:
#process m3u8 playlist
for stream in get_streams_from_manifest_url(url):
item = self.video_item()
item['title'] = v['details']['name']
item['surl'] = item['title']
item['url'] = stream['url']
item['quality'] = stream['quality']
result.append(item)
else:
item = self.video_item()
item['title'] = v['details']['name']
Expand Down

0 comments on commit 07c8227

Please sign in to comment.