def setEnd(self, value=None): if value == None: choice = self.getPaddingOption() if not choice: return label = choice[0] self.endPadding = choice[1] if self.rule: self.rule.endPadding = choice[1] else: label = value and util.durationToShortText( value) or self.PADDING_OPTIONS[0][0] self.endPadding = value self.getControl(self.END_BUTTON).setLabel(label)
def onInit(self): BaseWindow.onInit(self) self.setProperty('loading', '1') self._winID = xbmcgui.getCurrentWindowId() self.pushList = self.getControl(101) token = util.getSetting('pb_access_token') if not token: return loadVideoThumbs = util.getSetting('load_video_thumbs', False) kodiDevice = devices.getDefaultKodiDevice( util.getSetting('pb_client_iden'), util.getSetting('pb_client_nickname')) if not kodiDevice: return self.pushes = [] pushes = self.client.pushes() if not pushes: return items = [] cacheIDs = [] self.pushes = [] for p in pushes: #Keep all IDs cached so that we don't cause a delay when changing view if p.get('active'): cacheIDs.append(p.get('iden')) if self.viewMode == 'SELF': self.pushes = [ p for p in pushes if p.get('active') and p.get('target_device_iden') == kodiDevice.ID ] elif self.viewMode == 'ALL': self.pushes = [p for p in pushes if p.get('active')] elif self.viewMode: self.pushes = [ p for p in pushes if p.get('active') and p.get('target_device_iden') == self.viewMode ] for push in self.pushes: iden = push.get('iden') title = push.get('title', push.get('name', push.get('file_name', ''))) bg = push.get('image_url', '') info = push.get('url', '') mediaIcon = '' media = '' if push.get('type') == 'address': bg = maps.Maps().getMap(urllib.quote(push.get('address', '')), 'None', marker=True, return_url_only=True) elif push.get('type') == 'link': url = push.get('url') if StreamExtractor.mightHaveVideo(url): media = 'video' if loadVideoThumbs: bg = getCachedData(iden) if not bg: bg = StreamExtractor.getVideoInfo(url).thumbnail cacheData(iden, bg) else: media = pushhandler.getURLMediaType(url) if not title: title = url.rsplit('/', 1)[-1] elif push.get('type') == 'file': info = urllib.unquote(push.get('file_url', '')) if push.get('file_type', '').startswith('image/'): media = 'image' elif push.get('file_type', '').startswith('audio/'): media = 'music' elif push.get('file_type', '').startswith('video/'): media = 'video' if media: mediaIcon = 'service-pushbullet-com-icon_{0}.png'.format(media) item = xbmcgui.ListItem( title, iconImage='service-pushbullet-com-{0}.png'.format( push.get('type', ''))) desc = push.get('body', push.get('address', '')) if push.get('type') == 'list': li = [] ct = 0 for i in push.get('items', []): li.append(i.get('text', '')) ct += 1 if ct > 50: break desc = ', '.join(li) desc = '[CR]'.join(desc.splitlines()[:4]) item.setProperty('description', desc) item.setProperty('info', info) item.setProperty( 'sender', push.get('sender_name', push.get('sender_email', ''))) item.setProperty('media_icon', mediaIcon) item.setProperty('background', bg) #item.setProperty('date',time.strftime('%m-%d-%Y %H:%M',time.localtime(push.get('created',0)))) item.setProperty( 'date', '{0} {1}'.format( util.durationToShortText(time.time() - push.get('created', 0)), T(32053))) items.append(item) self.setProperty('loading', '0') self.pushList.reset() self.pushList.addItems(items) if items: self.setFocusId(101) self.reSelect() cleanCache(cacheIDs)
def onInit(self): BaseWindow.onInit(self) self.setProperty('loading','1') self._winID = xbmcgui.getCurrentWindowId() self.pushList = self.getControl(101) token = util.getSetting('token') if not token: return loadVideoThumbs = util.getSetting('load_video_thumbs',False) kodiDevice = devices.getDefaultKodiDevice(util.getSetting('device_iden'),util.getSetting('device_name')) if not kodiDevice: return self.pushes = [] pushes = self.client.pushes() if not pushes: return items = [] cacheIDs = [] self.pushes = [] for p in pushes: #Keep all IDs cached so that we don't cause a delay when changing view if p.get('active'): cacheIDs.append(p.get('iden')) if self.viewMode == 'SELF': self.pushes = [p for p in pushes if p.get('active') and p.get('target_device_iden') == kodiDevice.ID] elif self.viewMode == 'ALL': self.pushes = [p for p in pushes if p.get('active')] elif self.viewMode: self.pushes = [p for p in pushes if p.get('active') and p.get('target_device_iden') == self.viewMode] for push in self.pushes: iden = push.get('iden') title = push.get('title',push.get('name',push.get('file_name',''))) bg = push.get('image_url','') info = push.get('url','') mediaIcon = '' media = '' if push.get('type') == 'address': bg = maps.Maps().getMap(urllib.quote(push.get('address','')),'None',marker=True,return_url_only=True) elif push.get('type') == 'link': url = push.get('url') if StreamExtractor.mightHaveVideo(url): media = 'video' if loadVideoThumbs: bg = getCachedData(iden) if not bg: bg = StreamExtractor.getVideoInfo(url).thumbnail cacheData(iden,bg) else: media = pushhandler.getURLMediaType(url) if not title: title = url.rsplit('/',1)[-1] elif push.get('type') == 'file': info = urllib.unquote(push.get('file_url','')) if push.get('file_type','').startswith('image/'): media = 'image' elif push.get('file_type','').startswith('audio/'): media = 'music' elif push.get('file_type','').startswith('video/'): media = 'video' if media: mediaIcon = 'service-pushbullet-com-icon_{0}.png'.format(media) item = xbmcgui.ListItem(title,iconImage='service-pushbullet-com-{0}.png'.format(push.get('type',''))) desc = push.get('body',push.get('address','')) if push.get('type') == 'list': li = [] ct = 0 for i in push.get('items',[]): li.append(i.get('text','')) ct+=1 if ct > 50: break desc = ', '.join(li) desc = '[CR]'.join(desc.splitlines()[:4]) item.setProperty('description',desc) item.setProperty('info',info) item.setProperty('sender', push.get('sender_email','')) item.setProperty('media_icon',mediaIcon) item.setProperty('background',bg) #item.setProperty('date',time.strftime('%m-%d-%Y %H:%M',time.localtime(push.get('created',0)))) item.setProperty('date','{0} {1}'.format(util.durationToShortText(time.time() - push.get('created',0)),T(32053))) items.append(item) self.setProperty('loading','0') self.pushList.reset() self.pushList.addItems(items) if items: self.setFocusId(101) self.reSelect() cleanCache(cacheIDs)
def onInit(self): BaseWindow.onInit(self) self.setProperty("loading", "1") self._winID = xbmcgui.getCurrentWindowId() self.pushList = self.getControl(101) token = util.getSetting("pb_access_token") if not token: return loadVideoThumbs = util.getSetting("load_video_thumbs", False) kodiDevice = devices.getDefaultKodiDevice( util.getSetting("pb_client_iden"), util.getSetting("pb_client_nickname") ) if not kodiDevice: return self.pushes = [] pushes = self.client.pushes() if not pushes: return items = [] cacheIDs = [] self.pushes = [] for p in pushes: # Keep all IDs cached so that we don't cause a delay when changing view if p.get("active"): cacheIDs.append(p.get("iden")) if self.viewMode == "SELF": self.pushes = [p for p in pushes if p.get("active") and p.get("target_device_iden") == kodiDevice.ID] elif self.viewMode == "ALL": self.pushes = [p for p in pushes if p.get("active")] elif self.viewMode: self.pushes = [p for p in pushes if p.get("active") and p.get("target_device_iden") == self.viewMode] for push in self.pushes: iden = push.get("iden") title = push.get("title", push.get("name", push.get("file_name", ""))) bg = push.get("image_url", "") info = push.get("url", "") mediaIcon = "" media = "" if push.get("type") == "address": bg = maps.Maps().getMap( urllib.quote(push.get("address", "")), "None", marker=True, return_url_only=True ) elif push.get("type") == "link": url = push.get("url") if StreamExtractor.mightHaveVideo(url): media = "video" if loadVideoThumbs: bg = getCachedData(iden) if not bg: bg = StreamExtractor.getVideoInfo(url).thumbnail cacheData(iden, bg) else: media = pushhandler.getURLMediaType(url) if not title: title = url.rsplit("/", 1)[-1] elif push.get("type") == "file": info = urllib.unquote(push.get("file_url", "")) if push.get("file_type", "").startswith("image/"): media = "image" elif push.get("file_type", "").startswith("audio/"): media = "music" elif push.get("file_type", "").startswith("video/"): media = "video" if media: mediaIcon = "service-pushbullet-com-icon_{0}.png".format(media) item = xbmcgui.ListItem(title, iconImage="service-pushbullet-com-{0}.png".format(push.get("type", ""))) desc = push.get("body", push.get("address", "")) if push.get("type") == "list": li = [] ct = 0 for i in push.get("items", []): li.append(i.get("text", "")) ct += 1 if ct > 50: break desc = ", ".join(li) desc = "[CR]".join(desc.splitlines()[:4]) item.setProperty("description", desc) item.setProperty("info", info) item.setProperty("sender", push.get("sender_name", push.get("sender_email", ""))) item.setProperty("media_icon", mediaIcon) item.setProperty("background", bg) # item.setProperty('date',time.strftime('%m-%d-%Y %H:%M',time.localtime(push.get('created',0)))) item.setProperty( "date", "{0} {1}".format(util.durationToShortText(time.time() - push.get("created", 0)), T(32053)) ) items.append(item) self.setProperty("loading", "0") self.pushList.reset() self.pushList.addItems(items) if items: self.setFocusId(101) self.reSelect() cleanCache(cacheIDs)