def addNextButton(self, **kwargs): log("(%s) Adding item 'Show more'" % self.interfaceName) item = { "label": __addon__.getLocalizedString(30000), "icon": os.path.join(_settings.resources_path, 'media', self.mediaSettings.mediaType, 'more.png'), "thumbnail": os.path.join(_settings.resources_path, 'media', self.mediaSettings.mediaType, 'more_thumbnail.png'), "replace_context_menu": True, "context_menu": [self.getOpenSettings()], "properties": { "fanart_image": _settings.fanart } } item.setdefault('properties').update( dict((key, str(value)) for key, value in kwargs.items() if value)) xbmcplugin.addDirectoryItem( _settings.handle, "%s?%s" % (_settings.base_url, _settings.cur_uri), xbmcItem(**item), True)
def addItem(self, item, path, isFolder=True): log("(%s) Adding item '%s'" %(self.interfaceName, item["label"])) # Ensure fanart if not item.setdefault("properties", {}).get("fanart_image"): item["properties"]["fanart_image"] = _settings.fanart xbmcplugin.addDirectoryItem(_settings.handle, path, xbmcItem(**item), isFolder)
def addItem(self, item, path, isFolder=True): log("(%s) Adding item '%s'" % (self.interfaceName, item["label"])) # Ensure fanart if not item.setdefault("properties", {}).get("fanart_image"): item["properties"]["fanart_image"] = _settings.fanart xbmcplugin.addDirectoryItem(_settings.handle, path, xbmcItem(**item), isFolder)
def playTorrentFile(self, mediaSettings, magnet, item, subtitleURL=None): with TorrentEngine(mediaSettings, magnet) as _TorrentEngine: # Loading log('(Torrent Player) Loading', LOGLEVEL.INFO) with closing(SafeDialogProgress()) as dialog: dialog.create(item['info']['title']) dialog.update(0, __addon__.getLocalizedString(30031), ' ', ' ') # Update progress dialog dialog.set_mentions((101+bool(subtitleURL))) def on_update(state, progressValue): if state == Loader.PRELOADING: dialog.update(progressValue, *self._get_status_lines(_TorrentEngine.status())) elif state == Loader.CHECKING_DATA: dialog.update(progressValue, __addon__.getLocalizedString(30037), ' ', ' ') elif state == Loader.WAITING_FOR_PLAY_FILE: dialog.update(progressValue, __addon__.getLocalizedString(30016), ' ', ' ') elif state == Loader.DOWNLOADING_SUBTITLE: dialog.update(progressValue, __addon__.getLocalizedString(30019), ' ', ' ') elif state == Loader.FINISHED: dialog.update(progressValue, __addon__.getLocalizedString(30020), ' ', ' ') with Loader(mediaSettings, _TorrentEngine, item, subtitleURL, on_update) as _loader: while not _loader.is_done(0.100): if xbmc.abortRequested or dialog.iscanceled(): raise Abort() # Starts the playback log('(Torrent Player) Start the playback', LOGLEVEL.INFO) self.play(Loader.url, xbmcItem(**item)) # Waiting for playback to start log('(Torrent Player) Waiting for playback to start') for _ in xrange(300): if self.isPlaying(): break time.sleep(0.100) else: raise Error('Playback is terminated due to timeout', 30318) if Loader.subtitle: log('(Torrent Player) Add subtitle to the playback') self.setSubtitles(Loader.subtitle) with OverlayText() as self._overlay: while not xbmc.abortRequested and self.isPlaying(): if self._overlay.isShowing(): self._overlay.setText("\n".join(self._get_status_lines(_TorrentEngine.status()))) time.sleep(0.100) continue time.sleep(0.250) log('(Torrent Player) The playback has stop')
def addNextButton(self, **kwargs): log("(%s) Adding item 'Show more'" %self.interfaceName) item = { "label": __addon__.getLocalizedString(30000), "icon": os.path.join(_settings.resources_path, 'media', self.mediaSettings.mediaType, 'more.png'), "thumbnail": os.path.join(_settings.resources_path, 'media', self.mediaSettings.mediaType, 'more_thumbnail.png'), "replace_context_menu": True, "context_menu": [self.getOpenSettings()], "properties": { "fanart_image": _settings.fanart } } item.setdefault('properties').update(dict((key, str(value)) for key, value in kwargs.items() if value)) xbmcplugin.addDirectoryItem(_settings.handle, "%s?%s" %(_settings.base_url, _settings.cur_uri), xbmcItem(**item), True)