def views(self): try: control.idle() items = [ (control.lang(32001).encode('utf-8'), 'movies'), (control.lang(32002).encode('utf-8'), 'tvshows'), (control.lang(32054).encode('utf-8'), 'seasons'), (control.lang(32038).encode('utf-8'), 'episodes') ] select = control.selectDialog([i[0] for i in items], control.lang(32049).encode('utf-8')) if select == -1: return content = items[select][1] title = control.lang(32059).encode('utf-8') url = '%s?action=addView&content=%s' % (sys.argv[0], content) poster, banner, fanart = control.addonPoster(), control.addonBanner(), control.addonFanart() item = control.item(label=title) item.setInfo(type='Video', infoLabels = {'title': title}) item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner}) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) control.content(int(sys.argv[1]), content) control.directory(int(sys.argv[1]), cacheToDisc=True) from resources.lib.addon import views views.setView(content, {}) except: return
def addDirectory(self, items, queue=False): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonFanart, addonThumb, artPath = control.addonFanart(), control.addonThumb(), control.artPath() queueMenu = control.lang(32065).encode('utf-8') playRandom = control.lang(32535).encode('utf-8') addToLibrary = control.lang(32551).encode('utf-8') for i in items: try: 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 = [] cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=show&url=%s)' % (sysaddon, urllib.quote_plus(i['url'])))) if queue == True: cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) try: cm.append((addToLibrary, 'RunPlugin(%s?action=tvshowsToLibrary&url=%s)' % (sysaddon, urllib.quote_plus(i['context'])))) except: pass item = control.item(label=name) item.setArt({'icon': thumb, 'thumb': thumb}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.content(syshandle, 'addons') control.directory(syshandle, cacheToDisc=True)
def channelDirectory(self, items): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') try: isOld = False ; control.item().getArt('type') except: isOld = True isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') refreshMenu = control.lang(32072).encode('utf-8') for i in items: try: label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(), i['title'], i['year']) sysname = urllib.quote_plus('%s (%s)' % (i['title'], i['year'])) systitle = urllib.quote_plus(i['title']) imdb, tmdb, year = i['imdb'], i['tmdb'], i['year'] meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb}) meta.update({'tmdb_id': tmdb}) meta.update({'mediatype': 'movie'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb}) meta.update({'playcount': 0, 'overlay': 6}) try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=play&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, sysmeta, self.systime) sysurl = urllib.quote_plus(url) cm = [] cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if isOld == True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) art = {} if 'poster2' in i and not i['poster2'] == '0': art.update({'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2']}) elif 'poster' in i and not i['poster'] == '0': art.update({'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster']}) else: art.update({'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster}) art.update({'banner': addonBanner}) if settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0': item.setProperty('Fanart_Image', i['fanart']) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setArt(art) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def tvshowDirectory(self, items): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False ; control.item().getArt('type') except: isOld = True indicators = playcount.getTVShowIndicators(refresh=True) if action == 'tvshows' else playcount.getTVShowIndicators() flatten = True if control.setting('flatten.tvshows') == 'true' else False watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') nextMenu = control.lang(32053).encode('utf-8') playRandom = control.lang(32535).encode('utf-8') addToLibrary = control.lang(32551).encode('utf-8') for i in items: try: label = i['title'] systitle = sysname = urllib.quote_plus(i['originaltitle']) sysimage = urllib.quote_plus(i['poster']) imdb, tvdb, year = i['imdb'], i['tvdb'], i['year'] meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb}) meta.update({'tvdb_id': tvdb}) meta.update({'mediatype': 'tvshow'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(label))}) if not 'duration' in i: meta.update({'duration': '60'}) elif i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: overlay = int(playcount.getTVShowOverlay(indicators, tvdb)) if overlay == 7: meta.update({'playcount': 1, 'overlay': 7}) else: meta.update({'playcount': 0, 'overlay': 6}) except: pass if flatten == True: url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb) else: url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb) cm = [] cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=season&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, urllib.quote_plus(systitle), urllib.quote_plus(year), urllib.quote_plus(imdb), urllib.quote_plus(tvdb)))) cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb))) cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, imdb, tvdb))) if traktCredentials == True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb))) if isOld == True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) cm.append((addToLibrary, 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tvdb))) item = control.item(label=label) art = {} if 'poster' in i and not i['poster'] == '0': art.update({'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster']}) #elif 'poster2' in i and not i['poster2'] == '0': #art.update({'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2']}) else: art.update({'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster}) if 'banner' in i and not i['banner'] == '0': art.update({'banner': i['banner']}) #elif 'banner2' in i and not i['banner2'] == '0': #art.update({'banner': i['banner2']}) elif 'fanart' in i and not i['fanart'] == '0': art.update({'banner': i['fanart']}) else: art.update({'banner': addonBanner}) if 'clearlogo' in i and not i['clearlogo'] == '0': art.update({'clearlogo': i['clearlogo']}) if 'clearart' in i and not i['clearart'] == '0': art.update({'clearart': i['clearart']}) if settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0': item.setProperty('Fanart_Image', i['fanart']) #elif settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0': #item.setProperty('Fanart_Image', i['fanart2']) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setArt(art) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels = meta) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass try: url = items[0]['next'] if url == '': raise Exception() icon = control.addonNext() url = '%s?action=tvshowPage&url=%s' % (sysaddon, urllib.quote_plus(url)) item = control.item(label=nextMenu) item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.content(syshandle, 'tvshows') control.directory(syshandle, cacheToDisc=True) views.setView('tvshows', {'skin.estuary': 55, 'skin.confluence': 500})
def addItem(self, title): control.playlist.clear() items = control.window.getProperty(self.itemProperty) items = json.loads(items) if items == None or len(items) == 0: control.idle() ; sys.exit() meta = control.window.getProperty(self.metaProperty) meta = json.loads(meta) sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) downloads = True if control.setting('downloads') == 'true' and not (control.setting('movie.download.path') == '' or control.setting('tv.download.path') == '') else False systitle = sysname = urllib.quote_plus(title) if 'tvshowtitle' in meta and 'season' in meta and 'episode' in meta: sysname += urllib.quote_plus(' S%02dE%02d' % (int(meta['season']), int(meta['episode']))) elif 'year' in meta: sysname += urllib.quote_plus(' (%s)' % meta['year']) poster = meta['poster3'] if 'poster3' in meta else '0' if poster == '0': poster = meta['poster'] if 'poster' in meta else '0' fanart = meta['fanart2'] if 'fanart2' in meta else '0' if fanart == '0': fanart = meta['fanart'] if 'fanart' in meta else '0' thumb = meta['thumb'] if 'thumb' in meta else '0' if thumb == '0': thumb = poster if thumb == '0': thumb = fanart banner = meta['banner'] if 'banner' in meta else '0' if banner == '0': banner = poster if poster == '0': poster = control.addonPoster() if banner == '0': banner = control.addonBanner() if not control.setting('fanart') == 'true': fanart = '0' if fanart == '0': fanart = control.addonFanart() if thumb == '0': thumb = control.addonFanart() sysimage = urllib.quote_plus(poster.encode('utf-8')) downloadMenu = control.lang(32403).encode('utf-8') for i in range(len(items)): try: label = items[i]['label'] syssource = urllib.quote_plus(json.dumps([items[i]])) sysurl = '%s?action=playItem&title=%s&source=%s' % (sysaddon, systitle, syssource) cm = [] if downloads == True: cm.append((downloadMenu, 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)' % (sysaddon, sysname, sysimage, syssource))) item = control.item(label=label) item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster, 'banner': banner}) item.setProperty('Fanart_Image', fanart) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels = meta) control.addItem(handle=syshandle, url=sysurl, listitem=item, isFolder=False) except: pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def endDirectory(self): control.content(syshandle, 'addons') control.directory(syshandle, cacheToDisc=True)
def addItem(self, title): control.playlist.clear() items = control.window.getProperty(self.itemProperty) items = json.loads(items) if items == None or len(items) == 0: control.idle() sys.exit() meta = control.window.getProperty(self.metaProperty) meta = json.loads(meta) sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) downloads = True if control.setting('downloads') == 'true' and not ( control.setting('movie.download.path') == '' or control.setting('tv.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'])) elif '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() sysimage = urllib.quote_plus(poster.encode('utf-8')) downloadMenu = control.lang(32403).encode('utf-8') for i in range(len(items)): try: label = items[i]['label'] syssource = urllib.quote_plus(json.dumps([items[i]])) sysurl = '%s?action=playItem&title=%s&source=%s' % ( sysaddon, systitle, syssource) cm = [] if downloads == True: cm.append(( downloadMenu, 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)' % (sysaddon, sysname, sysimage, syssource))) item = control.item(label=label) 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) except: pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)