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 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 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 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: multi = [] multi = len([x for y, x in enumerate(multi) if x not in multi[:y]]) multi = True if multi > 1 else False try: sysaction = items[0]['action'] except: sysaction = '' for i in items: try: try: if i['title'] == '0': label = '%sx%02d . %s %s' % (i['season'], int(i['episode']), 'Episode', 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']) episodetitle, episodename = urllib.quote_plus( i['title']), urllib.quote_plus(i['name']) 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))) ''' try: overlay = int(playcount.getEpisodeOverlay(indicators, systitle, episode, season)) if overlay == 7: cm.append((control.lang(30264).encode('utf-8'), 'RunPlugin(%s?action=episodePlaycount&tvshowtitle=%s&episode=%s&season=%s&query=6&name=%s)' % (sysaddon, systitle, episode, season, episodename))) meta.update({'playcount': 1, 'overlay': 7}) else: cm.append((control.lang(30263).encode('utf-8'), 'RunPlugin(%s?action=episodePlaycount&tvshowtitle=%s&episode=%s&season=%s&query=7&name=%s)' % (sysaddon, systitle, episode, season, episodename))) meta.update({'playcount': 0, 'overlay': 6}) except Exception as e: logger.error(e, __name__) pass ''' #cm.append((control.lang(30273).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon)) 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: 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 seasonDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting('host_select') == '1' else False isFolder = False if control.window.getProperty( 'PseudoTVRunning') == 'True' else isFolder addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting( 'fanart') for i in items: try: label = '%s %s' % ('Season', i['season']) systitle = sysname = urllib.quote_plus(i['tvshowtitle']) imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['season'] 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 poster == '0': thumb = addonPoster elif thumb == '0': thumb = 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 sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % ( sysaddon, systitle, year, imdb, tvdb, season) cm = [] if isFolder == False: cm.append((control.lang(30261).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append( (control.lang(30262).encode('utf-8'), 'Action(Info)')) cm.append((control.lang(30263).encode( 'utf-8' ), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&season=%s&query=7)' % (sysaddon, systitle, year, imdb, tvdb, season))) cm.append((control.lang(30264).encode( 'utf-8' ), 'RunPlugin(%s?action=tvPlaycount&name=%s&year=%s&imdb=%s&tvdb=%s&season=%s&query=6)' % (sysaddon, systitle, year, imdb, tvdb, season))) #cm.append((control.lang(30267).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) #cm.append((control.lang(30268).encode('utf-8'), 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, tvrage))) cm.append((control.lang(30269).encode('utf-8'), 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon)) item = control.item(label=label, iconImage=thumb, thumbnailImage=thumb) try: item.setArt({ 'poster': thumb, 'tvshow.poster': poster, 'season.poster': thumb, '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: pass try: control.property(syshandle, 'showplot', items[0]['plot']) except: pass control.content(syshandle, 'seasons') control.directory(syshandle, cacheToDisc=True) viewMode = 'thumbnails' views.setView( 'seasons', { 'skin.confluence': control.viewMode['confluence'][viewMode], 'skin.estuary': control.viewMode['esturary'][viewMode] })
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']) sysimage = urllib.quote_plus(i['poster']) 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 sysmeta = urllib.quote_plus(json.dumps(meta)) 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) logger.debug('poster %s banner %s fanart %s' % (poster, banner, fanart)) 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]})
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') #try: # from metahandler import metahandlers # metaget = metahandlers.MetaData(tmdb_api_key=self.tmdb_key, preparezip=False) #except: # pass 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 #logger.debug('Title : %s poster : %s banner : %s fanart : %s' % (i['title'], poster, banner, fanart), __name__) 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) #try: # playcount = metaget._get_watched('movie', imdb, '', '') # if playcount == 7: meta.update({'playcount': 1, 'overlay': 7}) # else: meta.update({'playcount': 0, 'overlay': 6}) #except: # pass 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 channelDirectory(self, items, action='play'): if items == None or len(items) == 0: return addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() artPath = control.logoPath() for i in items: try: label = "%s" % (i['name']) sysname = urllib.quote_plus(i['name']) meta = json.loads(i['meta']) poster, banner, direct = meta['poster'], meta['poster'], i[ 'direct'] try: provider = i['provider'] except: provider = None if poster.startswith('http'): pass elif not artPath == None and not poster == "": poster = os.path.join(artPath, poster) else: poster = addonPoster url = i['url'] if not direct: content = 'live' meta = {"poster": poster, "iconImage": poster} source = { "provider": provider, "url": url, "quality": 'HD', "label": 'Resolving %s' % label, "source": provider, "meta": json.dumps(meta) } syssource = urllib.quote_plus(json.dumps([source])) url = 'action=%s&content=%s&name=%s' % (action, content, sysname) url = '%s?%s' % (sysaddon, url) item = control.item(label=label, iconImage=poster, thumbnailImage=poster) try: item.setArt({'poster': poster, 'banner': banner}) except: pass if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setProperty('Video', 'true') item.setProperty("IsPlayable", "true") item.addContextMenuItems([]) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except Exception as e: logger.error(e, __name__) pass #control.content(syshandle, 'video') #viewMode = 'list' #views.setView('movies', {'skin.confluence': control.viewMode['confluence'][viewMode], 'skin.estuary': # control.viewMode['esturary'][viewMode]}) control.directory(syshandle, cacheToDisc=False)