summaryrefslogtreecommitdiff
path: root/plugin.video.dazn/resources/lib/items.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugin.video.dazn/resources/lib/items.py')
-rw-r--r--plugin.video.dazn/resources/lib/items.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugin.video.dazn/resources/lib/items.py b/plugin.video.dazn/resources/lib/items.py
new file mode 100644
index 0000000..9e08127
--- /dev/null
+++ b/plugin.video.dazn/resources/lib/items.py
@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+
+import xbmc
+import xbmcgui
+import xbmcplugin
+
+class Items:
+
+ def __init__(self, plugin):
+ self.cache = True
+ self.video = False
+ self.plugin = plugin
+
+ def list_items(self, focus=False, upd=False):
+ if self.video:
+ xbmcplugin.setContent(self.plugin.addon_handle, self.plugin.content)
+ xbmcplugin.endOfDirectory(self.plugin.addon_handle, cacheToDisc=self.cache, updateListing=upd)
+
+ if self.plugin.force_view:
+ xbmc.executebuiltin('Container.SetViewMode({0})'.format(self.plugin.view_id))
+
+ if focus:
+ try:
+ wnd = xbmcgui.Window(xbmcgui.getCurrentWindowId())
+ wnd.getControl(wnd.getFocusId()).selectItem(focus)
+ except:
+ pass
+
+ def add_item(self, item):
+ data = {
+ 'mode': item['mode'],
+ 'title': item['title'],
+ 'id': item.get('id', ''),
+ 'params': item.get('params','')
+ }
+
+ art = {
+ 'thumb': item.get('thumb', self.plugin.addon_icon),
+ 'poster': item.get('thumb', self.plugin.addon_icon),
+ 'fanart': item.get('fanart', self.plugin.addon_fanart)
+ }
+
+ labels = {
+ 'title': item['title'],
+ 'plot': item.get('plot', item['title']),
+ 'premiered': item.get('date', ''),
+ 'episode': item.get('episode', 0)
+ }
+
+ listitem = xbmcgui.ListItem(item['title'])
+ listitem.setArt(art)
+ listitem.setInfo(type='Video', infoLabels=labels)
+
+ if 'play' in item['mode']:
+ self.cache = False
+ self.video = True
+ folder = False
+ listitem.addStreamInfo('video', {'duration':item.get('duration', 0)})
+ listitem.setProperty('IsPlayable', 'true')
+ else:
+ folder = True
+
+ if item.get('cm', None):
+ listitem.addContextMenuItems( item['cm'] )
+
+ xbmcplugin.addDirectoryItem(self.plugin.addon_handle, self.plugin.build_url(data), listitem, folder)
+
+ def play_item(self, item, name, context):
+ path = item.ManifestUrl
+ listitem = xbmcgui.ListItem()
+ listitem.setContentLookup(False)
+ listitem.setMimeType('application/dash+xml')
+ listitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
+ listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd')
+ listitem.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha')
+ listitem.setProperty('inputstream.adaptive.license_key', item.LaUrl+'&_widevineChallenge=B{SSM}|||JBlicense')
+ if context:
+ listitem.setInfo('video', {'Title': name})
+ xbmc.Player().play(path, listitem)
+ else:
+ listitem.setPath(path)
+ xbmcplugin.setResolvedUrl(self.plugin.addon_handle, True, listitem)