def _inside(self, num): if num == -1: self._inside_root(select=self.insideIndex) return with self.lock: source, links = self.items[num] if len(links) == 1: self.selection = links[0] self.close() return self.list.reset() for item in links: listitem = control.item(item['label']) #listitem.setProperty("Path", item['path']) try: #pluginid = item['path'].split("/")[2] icon = control.addonInfo('icon') listitem.setIconImage(icon) except: pass self.list.addItem(listitem) self.insideIndex = num
def addDirectoryItem(self, name, query, thumb, icon, context=None, isAction=True, isFolder=True): try: name = control.lang(name).encode('utf-8') except: pass url = '%s?action=%s&name=%s' % (sysaddon, query, name) if isAction == True else query if not 'http' in thumb: thumb = os.path.join(artPath, thumb) if not artPath == None else icon cm = [] if not context == None: cm.append((control.lang(context[0]).encode('utf-8'), 'RunPlugin(%s?action=%s)' % (sysaddon, context[1]))) item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems(cm) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder)
def addDirectory(self, items): if items == None or len(items) == 0: return addonFanart = control.addonFanart() addonThumb = control.addonThumb() artPath = control.artPath() for i in items: try: try: name = control.lang(i['name']).encode('utf-8') except: name = i['name'] if i['image'].startswith('http://'): thumb = i['image'] elif not artPath == None: thumb = os.path.join(artPath, i['image']) else: thumb = addonThumb url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass cm = [] item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems(cm) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except Exception as e: logger.error(e, __name__) pass viewMode = 'mediainfo1' views.setView( 'tvshows', { 'skin.confluence': control.viewMode['confluence'][viewMode], 'skin.estuary': control.viewMode['esturary'][viewMode] }) control.directory(syshandle, cacheToDisc=True)
def _inside_root(self, select=-1): with self.lock: self.list.reset() for source, links in self.items: if len(links) > 1: source += " >>" listitem = control.item(source) try: #icon = xbmcaddon.Addon(id=links[0]['path'].split("/")[2]).getAddonInfo('icon') icon = control.addonInfo('icon') listitem.setIconImage(icon) except: pass self.list.addItem(listitem) if select >= 0: self.list.selectItem(select) self.insideIndex = -1
def addDirectory(self, items): if items == None or len(items) == 0: return addonFanart = control.addonFanart() addonThumb = control.addonThumb() artPath = control.artPath() for i in items: try: try: name = control.lang(i['name']).encode('utf-8') except: name = i['name'] if not artPath == None: thumb = os.path.join(artPath, i['image']) else: thumb = addonThumb url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([]) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.directory(syshandle, cacheToDisc=True)
def addItem(self, title, content): try: control.playlist.clear() items = control.window.getProperty(self.itemProperty) items = json.loads(items) if items == []: raise Exception() meta = control.window.getProperty(self.metaProperty) meta = json.loads(meta) infoMenu = control.lang(30502).encode('utf-8') downloads = True if control.setting( 'downloads') == 'true' and not control.setting( 'movie.download.path') == '' else False #if 'tvshowtitle' in meta and 'season' in meta and 'episode' in meta: # name = '%s S%02dE%02d' % (title, int(meta['season']), int(meta['episode'])) #el if 'year' in meta: name = '%s (%s)' % (title, meta['year']) else: name = title systitle = urllib.quote_plus(title.encode('utf-8')) sysname = urllib.quote_plus(name.encode('utf-8')) poster = meta['poster'] if 'poster' in meta else '0' banner = meta['banner'] if 'banner' in meta else '0' thumb = meta['thumb'] if 'thumb' in meta else poster fanart = meta['fanart'] if 'fanart' in meta else '0' if poster == '0': poster = control.addonPoster() if banner == '0' and poster == '0': banner = control.addonBanner() elif banner == '0': banner = poster if thumb == '0' and fanart == '0': thumb = control.addonFanart() elif thumb == '0': thumb = fanart if control.setting('fanart') == 'true' and not fanart == '0': pass else: fanart = control.addonFanart() for i in range(len(items)): try: parts = int(items[i]['parts']) except: parts = 1 label = items[i]['label'] syssource = urllib.quote_plus(json.dumps([items[i]])) sysurl = '%s?action=playItem&title=%s&source=%s&content=%s' % ( sysaddon, systitle, syssource, content) item = control.item(label=label) cm = [] cm.append((control.lang(30504).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) if content != 'live': if downloads == True and parts <= 1: sysimage = urllib.quote_plus(poster.encode('utf-8')) cm.append((control.lang(30505).encode( 'utf-8' ), 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)' % (sysaddon, systitle, sysimage, syssource))) item.setArt({ 'icon': thumb, 'thumb': thumb, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner }) if not fanart == None: item.setProperty('Fanart_Image', fanart) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels=meta) control.addItem(handle=syshandle, url=sysurl, listitem=item, isFolder=False) control.directory(syshandle, cacheToDisc=True) except Exception as e: logger.error(e.message) control.infoDialog(control.lang(30501).encode('utf-8'))
def playItem(self, content, title, source): try: self.isRegistered() control.resolve(syshandle, True, control.item(path='')) control.execute('Dialog.Close(okdialog)') next = [] prev = [] total = [] meta = control.window.getProperty(self.metaProperty) #meta = self.metaProperty meta = json.loads(meta) year = meta['year'] if 'year' in meta else None imdb = meta['imdb'] if 'imdb' in meta else None tvdb = meta['tvdb'] if 'tvdb' in meta else None for i in range(1, 10000): try: u = control.infoLabel('ListItem(%s).FolderPath' % str(i)) if u in total: raise Exception() total.append(u) u = dict(urlparse.parse_qsl(u.replace('?', ''))) if 'meta' in u: meta = u['meta'] u = json.loads(u['source'])[0] next.append(u) except: break for i in range(-10000, 0)[::-1]: try: u = control.infoLabel('ListItem(%s).FolderPath' % str(i)) if u in total: raise Exception() total.append(u) u = dict(urlparse.parse_qsl(u.replace('?', ''))) if 'meta' in u: meta = u['meta'] u = json.loads(u['source'])[0] prev.append(u) except: break items = json.loads(source) items = [i for i in items + next + prev][:40] self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0) block = None for i in range(len(items)): try: self.progressDialog.update( int((100 / float(len(items))) * i), str(items[i]['label']), str(' ')) if items[i]['source'] == block: raise Exception() w = workers.Thread(self.sourcesResolve, items[i]) w.start() m = '' for x in range(3600): if self.progressDialog.iscanceled(): return self.progressDialog.close() if xbmc.abortRequested == True: return sys.exit() k = control.condVisibility( 'Window.IsActive(virtualkeyboard)') if k: m += '1' m = m[-1] if (w.is_alive() == False or x > 30) and not k: break time.sleep(1.0) for x in range(3600): if m == '': break if self.progressDialog.iscanceled(): return self.progressDialog.close() if xbmc.abortRequested == True: return sys.exit() if w.is_alive() == False: break time.sleep(1.0) if w.is_alive() == True: block = items[i]['source'] if self.url == None: raise Exception() try: self.progressDialog.close() except: pass control.sleep(200) if control.setting('playback_info') == 'true': control.infoDialog(items[i]['label']) player().run(content, title, self.url, year, imdb, tvdb, meta) return self.url except Exception as e: logger.error(e, __name__) pass try: self.progressDialog.close() except: pass raise Exception() except Exception as e: logger.error(e.message) control.infoDialog(control.lang(30501).encode('utf-8')) pass
def play(self, name, title, year, imdb, tvdb, season, episode, tvshowtitle, date, meta, url, select=None): try: if not control.infoLabel('Container.FolderPath').startswith( 'plugin://'): control.playlist.clear() control.resolve(syshandle, True, control.item(path='')) control.execute('Dialog.Close(okdialog)') if imdb == '0': imdb = '0000000' imdb = 'tt' + re.sub('[^0-9]', '', str(imdb)) content = 'movie' if tvshowtitle == None else 'episode' self.srcs = self.getSources(name, title, year, imdb, tvdb, season, episode, tvshowtitle, date, meta) items = self.sourcesFilter() if len(items) > 0: try: select = control.setting( 'host_select') if select == None else select except: pass if select == '1' and 'plugin' in control.infoLabel( 'Container.PluginName'): logger.debug('INSIDE select=1', __name__) control.window.clearProperty(self.itemProperty) control.window.setProperty(self.itemProperty, json.dumps(items)) control.window.clearProperty(self.metaProperty) control.window.setProperty(self.metaProperty, meta) control.sleep(200) return control.execute( 'Container.Update(%s?action=addItem&title=%s&content=%s)' % (sysaddon, urllib.quote_plus( title.encode('utf-8')), content)) elif select == '0' or select == '1': url = self.sourcesDialog(items) else: url = self.sourcesDirect(items) if url == None: raise Exception() if url == 'close://': return if control.setting('playback_info') == 'true': control.infoDialog(self.selectedSource, heading=name) control.sleep(200) player().run(content, name, url, year, imdb, tvdb, meta) return url except Exception as e: logger.error(e.message) control.infoDialog(control.lang(30501).encode('utf-8'))
def movieDirectory(self, items, lang=None): if items == None or len(items) == 0: control.infoDialog(control.lang(30518).encode('utf-8')) return indicators = playcount.getMovieIndicators() isPlayable = 'true' if not 'plugin' in control.infoLabel( 'Container.PluginName') else 'false' playbackMenu = control.lang(30204).encode('utf-8') if control.setting( 'host_select') == '2' else control.lang(30203).encode('utf-8') cacheToDisc = False if not action == 'movieSearch' else True addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting( 'fanart') for i in items: try: label = '%s (%s)' % (i['title'], i['year']) imdb, title, year, trailer = i['imdb'], i['title'], i[ 'year'], i.get('trailer') sysname = urllib.quote_plus('%s (%s)' % (title, year)) systitle = urllib.quote_plus(title) poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster meta = dict((k, v) for k, v in i.iteritems() if not v == '0') meta.update({ 'trailer': '%s?action=trailer&name=%s&url=%s' % (sysaddon, sysname, trailer) }) if i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % ( sysaddon, sysname, systitle, year, imdb, sysmeta, self.systime) sysurl = urllib.quote_plus(url) cm = [] cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) # AUTOPLAY cm.append((control.lang(30214).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s&url=%s)' % (sysaddon, sysname, trailer))) # TRAILER cm.append((control.lang(30205).encode('utf-8'), 'Action(Info)')) # MOVIEINFORMATION cm.append((control.lang(30212).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon)) # SET MOVIES VIEW try: overlay = int(playcount.getMovieOverlay(indicators, imdb)) #logger.debug('imdb : %s Overlay : %s' % (imdb, overlay), __name__) if overlay == 7: cm.append((control.lang(30206).encode( 'utf-8' ), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb))) meta.update({'playcount': 1, 'overlay': 7}) else: cm.append((control.lang(30207).encode( 'utf-8' ), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb))) meta.update({'playcount': 0, 'overlay': 6}) except Exception as e: logger.error(e, __name__) pass item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'banner': banner}) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels=meta) item.setProperty('Video', 'true') item.setProperty('IsPlayable', isPlayable) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except Exception as e: logger.error(e, __name__) pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=movies&url=%s' % (sysaddon, urllib.quote_plus(url)) addonNext = control.addonNext() item = control.item(label=control.lang(30213).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([]) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except Exception as e: logger.error(e, __name__) pass content = 'movies' control.content(syshandle, content) control.directory(syshandle, cacheToDisc=cacheToDisc) views.setView( content, { 'skin.confluence': control.viewMode['confluence']['thumbnails'], 'skin.estuary': control.viewMode['esturary']['list'] })
def episodeDirectory(self, items, provider=None, confViewMode='list', estViewMode='widelist'): if items == None or len(items) == 0: return isFolder = True if control.setting('host_select') == '1' else False isPlayable = 'true' if not 'plugin' in control.infoLabel( 'Container.PluginName') else 'false' playbackMenu = control.lang(30271).encode('utf-8') if control.setting( 'host_select') == '2' else control.lang(30270).encode('utf-8') cacheToDisc = False addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting( 'fanart') indicators = playcount.getTVShowIndicators(refresh=True) try: multi = [i['tvshowtitle'] for i in items] except Exception as e: logger.error(e) multi = [] multi = len([x for y, x in enumerate(multi) if x not in multi[:y]]) multi = True if multi > 1 else False sysaction = '' if items[0].get('action') == None else items[0].get( 'action') for i in items: try: try: if i['title'] == '0': label = '%sx%02d . %s %s' % (i['season'], int(i['episode']), 'Episode', i['episode']) elif i['season'] == '0': label = '%s' % (i['episode']) else: label = '%sx%02d . %s' % (i['season'], int( i['episode']), i['title']) except: label = i['title'] if multi == True: label = '%s - %s' % (i['tvshowtitle'], label) systitle = sysname = urllib.quote_plus( i['tvshowtitle'].encode('utf-8')) episodetitle, episodename = urllib.quote_plus( i['title'].encode('utf-8'), safe=':/'), urllib.quote_plus(i['name'].encode('utf-8'), safe=':/') syspremiered = urllib.quote_plus(i['premiered']) imdb, tvdb, year, season, episode = i['imdb'], i['tvdb'], i[ 'year'], i['season'], i['episode'] poster, banner, fanart, thumb = i['poster'], i['banner'], i[ 'fanart'], i['thumb'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster if thumb == '0' and fanart == '0': thumb = addonFanart elif thumb == '0': thumb = fanart meta = dict((k, v) for k, v in i.iteritems() if not v == '0') meta.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname) }) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s&tvshowtitle=%s&date=%s&meta=%s&t=%s' % ( sysaddon, episodename, episodetitle, year, imdb, tvdb, season, episode, systitle, syspremiered, sysmeta, self.systime) sysurl = urllib.quote_plus(url) if sysaction == 'episodes': url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s' % ( sysaddon, systitle, year, imdb, tvdb, season, episode) isFolder = True cacheToDisc = True cm = [] if isFolder == False: cm.append((control.lang(30261).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append( (control.lang(30272).encode('utf-8'), 'Action(Info)')) if multi == True: cm.append((control.lang(30274).encode( 'utf-8' ), 'ActivateWindow(Videos,%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s,return)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) item = control.item(label=label, iconImage=thumb, thumbnailImage=thumb) try: item.setArt({ 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner }) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels=meta) item.setProperty('Video', 'true') item.setProperty('IsPlayable', isPlayable) item.setProperty('resumetime', str(0)) item.setProperty('totaltime', str(1)) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except Exception as e: logger.error(e) pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=episodes&tvshowtitle=%s&url=%s&provider=%s' % ( sysaddon, systitle, urllib.quote_plus(url), provider) addonNext = control.addonNext() item = control.item(label=control.lang(30213).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([]) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass content = 'episodes' control.content(syshandle, content) control.directory(syshandle, cacheToDisc=cacheToDisc) views.setView( content, { 'skin.confluence': control.viewMode['confluence'][confViewMode], 'skin.estuary': control.viewMode['esturary'][estViewMode] })
def tvshowDirectory(self, items, confViewMode='list', estViewMode='widelist'): if items == None or len(items) == 0: return isFolder = True if control.setting('host_select') == '1' else False addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting( 'fanart') for i in items: try: label = i['name'] systitle = sysname = urllib.quote_plus( i['title'].encode('utf-8'), safe=':/') imdb, tvdb, year = i['imdb'], i['tvdb'], i['year'] try: sysurl, sysprovider = urllib.quote_plus( i['url']), i['provider'] except: pass poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if poster == '0': poster = addonPoster if banner == '0' and poster == '0': banner = addonBanner elif banner == '0': banner = poster meta = dict((k, v) for k, v in i.iteritems() if not v == '0') meta.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname) }) if i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass action = 'episodes' url = '%s?action=%s&provider=%s&url=%s&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % ( sysaddon, action, sysprovider, sysurl, systitle, year, imdb, tvdb) cm = [] if isFolder == False: cm.append((control.lang(30232).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append( (control.lang(30233).encode('utf-8'), 'Action(Info)')) cm.append((control.lang(30234).encode( 'utf-8' ), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append((control.lang(30235).encode( 'utf-8' ), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append((control.lang(30240).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({ 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner }) except: pass if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setInfo(type='Video', infoLabels=meta) item.setProperty('Video', 'true') item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except Exception as e: logger.error(e, __name__) pass content = 'tvshows' control.content(syshandle, content) control.directory(syshandle, cacheToDisc=True) views.setView( content, { 'skin.confluence': control.viewMode['confluence'][confViewMode], 'skin.estuary': control.viewMode['esturary'][estViewMode] })