def fillRelated(self, has_prev=False): items = [] idx = 0 if not self.show_.related: self.relatedListControl.reset() return has_prev self.setProperty('divider.{0}'.format(self.RELATED_LIST_ID), has_prev and '1' or '') for rel in self.show_.related()[0].items: mli = kodigui.ManagedListItem( rel.title or '', thumbnailImage=rel.defaultThumb.asTranscodedImageURL(*self.RELATED_DIM), data_source=rel ) if mli: mli.setProperty('thumb.fallback', 'script.plex/thumb_fallbacks/{0}.png'.format(rel.type in ('show', 'season', 'episode') and 'show' or 'movie')) mli.setProperty('index', str(idx)) if not mli.dataSource.isWatched: mli.setProperty('unwatched.count', str(mli.dataSource.unViewedLeafCount)) mli.setProperty('progress', util.getProgressImage(mli.dataSource)) items.append(mli) idx += 1 self.relatedListControl.reset() self.relatedListControl.addItems(items) return True
def _showHub(self, hub, hubitems=None, index=None, with_progress=False, with_art=False, ar16x9=False, text2lines=False, **kwargs): control = self.hubControls[index] control.dataSource = hub if not hub.items and not hubitems: control.reset() return if not hubitems: hub.reset() self.setProperty('hub.4{0:02d}'.format(index), hub.title or kwargs.get('title')) self.setProperty('hub.text2lines.4{0:02d}'.format(index), text2lines and '1' or '') items = [] for obj in hubitems or hub.items: if not self.backgroundSet: self.backgroundSet = True self.setProperty( 'background', obj.art.asTranscodedImageURL(self.width, self.height, blur=128, opacity=60, background=colors.noAlpha.Background) ) mli = self.createListItem(obj, wide=with_art) if mli: items.append(mli) if with_progress: for mli in items: mli.setProperty('progress', util.getProgressImage(mli.dataSource)) if with_art: for mli in items: mli.setThumbnailImage(mli.dataSource.art.asTranscodedImageURL(*self.THUMB_AR16X9_DIM)) mli.setProperty('thumb.fallback', 'script.plex/thumb_fallbacks/movie16x9.png') if ar16x9: for mli in items: mli.setProperty('thumb.fallback', 'script.plex/thumb_fallbacks/movie16x9.png') if hub.more.asBool(): end = kodigui.ManagedListItem('') end.setBoolProperty('is.end', True) items.append(end) if hubitems: end = control.size() - 1 control.replaceItem(end, items[0]) control.addItems(items[1:]) control.selectItem(end) else: control.replaceItems(items)
def updateRelated(self): """ Update item watched/progress states dynamically :return: """ if not self.show_.related: return False states = {} for rel in self.show_.related()[0].items: states[rel.ratingKey] = { "unwatched.count": str(rel.unViewedLeafCount) if not rel.isWatched else '', "progress": util.getProgressImage(rel) } for mli in self.relatedListControl: stateInfo = states.get(mli.dataSource.ratingKey) if stateInfo: for fillProperty in ("unwatched.count", "progress"): if mli.getProperty(fillProperty) != stateInfo[fillProperty]: mli.setProperty(fillProperty, stateInfo[fillProperty])