def genres(self): genres = [ ('Action', 'action'), ('Adventure', 'adventure'), ('Animation', 'animation'), ('Biography', 'biography'), ('Comedy', 'comedy'), ('Crime', 'crime'), ('Drama', 'drama'), ('Family', 'family'), ('Fantasy', 'fantasy'), ('History', 'history'), ('Horror', 'horror'), ('Music ', 'music'), ('Musical', 'musical'), ('Mystery', 'mystery'), ('Romance', 'romance'), ('Science Fiction', 'sci_fi'), ('Sport', 'sport'), ('Thriller', 'thriller'), ('War', 'war'), ('Western', 'western') ] for i in genres: self.list.append({'name': cleangenre.lang(i[0], self.lang), 'url': self.genre_link % i[1], 'image': 'genres.png', 'action': 'movies'}) self.addDirectory(self.list) return self.list
def genres(self): genres = [ ('Action', 'action'), ('Adventure', 'adventure'), ('Animation', 'animation'), ('Biography', 'biography'), ('Comedy', 'comedy'), ('Crime', 'crime'), ('Documentary', 'documentary'), ('Drama', 'drama'), ('Family', 'family'), ('Fantasy', 'fantasy'), ('History', 'history'), ('Horror', 'horror'), ('Music ', 'music'), ('Musical', 'musical'), ('Mystery', 'mystery'), ('Romance', 'romance'), ('Science Fiction', 'sci_fi'), ('Sport', 'sport'), ('Thriller', 'thriller'), ('War', 'war'), ('Western', 'western') ] for i in genres: self.list.append( { 'name': cleangenre.lang(i[0], self.lang), 'url': self.genre_link % i[1], 'image': 'genres.png', 'action': 'movies' }) self.addDirectory(self.list) return self.list
def genres(self): genres = [ ('Action', 'action', True), ('Adventure', 'adventure', True), ('Animation', 'animation', True), ('Anime', 'anime', False), ('Biography', 'biography', True), ('Comedy', 'comedy', True), ('Crime', 'crime', True), ('Documentary', 'documentary', True), ('Drama', 'drama', True), ('Family', 'family', True), ('Fantasy', 'fantasy', True), ('History', 'history', True), ('Horror', 'horror', True), ('Music ', 'music', True), ('Musical', 'musical', True), ('Mystery', 'mystery', True), ('Romance', 'romance', True), ('Science Fiction', 'sci_fi', True), ('Sport', 'sport', True), ('Thriller', 'thriller', True), ('War', 'war', True), ('Western', 'western', True) ] params = { 'title_type': 'feature,tv_movie,documentary', 'num_votes': '100,', 'sort': 'moviemeter,asc', 'release_date': ',date[0]', } for i in genres: imdb_params = dict(params.items() + [('genres', i[1])]) # Convert the dictionary to url parameters, then URL encode params_str = self.imdblists.params_encode(imdb_params) url = 'q=imdb_params&{}'.format(params_str) self.list.append({ 'name': cleangenre.lang(i[0], self.lang), 'url': url, 'image': 'genres.png', 'action': 'movies' }) self.addDirectory(self.list) return self.list
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 = control.addonFanart() 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, year = i['imdb'], i['year'] poster, banner = i['poster'], i['poster'] 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({'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) item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass control.content(syshandle, 'movies') # control.do_block_check(False) control.directory(syshandle, cacheToDisc=True)
def genres(self): genres = [ ('Action', 'action', True), ('Adventure', 'adventure', True), ('Animation', 'animation', True), ('Anime', 'anime', False), ('Biography', 'biography', True), ('Comedy', 'comedy', True), ('Crime', 'crime', True), ('Drama', 'drama', True), ('Family', 'family', True), ('Fantasy', 'fantasy', True), ('Game-Show', 'game_show', True), ('History', 'history', True), ('Horror', 'horror', True), ('Music ', 'music', True), ('Musical', 'musical', True), ('Mystery', 'mystery', True), ('News', 'news', True), ('Reality-TV', 'reality_tv', True), ('Romance', 'romance', True), ('Science Fiction', 'sci_fi', True), ('Sport', 'sport', True), ('Talk-Show', 'talk_show', True), ('Thriller', 'thriller', True), ('War', 'war', True), ('Western', 'western', True)] for i in genres: self.list.append({'name': cleangenre.lang(i[0], self.lang), 'url': self.genre_link % i[1] if i[2] else self.keyword_link % i[1], 'image': 'genres.png', 'icon': 'DefaultGenre.png', 'action': 'tvshows'}) self.addDirectory(self.list) return self.list
def genres(self): genres = [ ('Action', 'action', True), ('Adventure', 'adventure', True), ('Animation', 'animation', True), ('Anime', 'anime', False), ('Biography', 'biography', True), ('Comedy', 'comedy', True), ('Crime', 'crime', True), ('Drama', 'drama', True), ('Family', 'family', True), ('Fantasy', 'fantasy', True), ('Game-Show', 'game_show', True), ('History', 'history', True), ('Horror', 'horror', True), ('Music ', 'music', True), ('Musical', 'musical', True), ('Mystery', 'mystery', True), ('News', 'news', True), ('Reality-TV', 'reality_tv', True), ('Romance', 'romance', True), ('Science Fiction', 'sci_fi', True), ('Sport', 'sport', True), ('Talk-Show', 'talk_show', True), ('Thriller', 'thriller', True), ('War', 'war', True), ('Western', 'western', True) ] for i in genres: self.list.append( { 'name': cleangenre.lang(i[0], self.lang), 'url': self.genre_link % i[1] if i[2] else self.keyword_link % i[1], 'image': 'genres.png', 'action': 'tvshows' }) self.addDirectory(self.list) return self.list
def genres(self): genres = [ ('Action', 'action', True, 'Action.png'), ('Adventure', 'adventure', True, 'Adventure.png'), ('Animation', 'animation', True, 'Animation.png'), ('Anime', 'anime', True, 'Anime.png'), ('Biography', 'biography', True, 'Biography.png'), ('Comedy', 'comedy', True, 'Comedy.png'), ('Crime', 'crime', True, 'Crime.png'), ('Documentary', 'documentary', True, 'Documentary.png'), ('Drama', 'drama', True, 'Drama.png'), ('Family', 'family', True, 'Family.png'), ('Fantasy', 'fantasy', True, 'Fantasy.png'), ('History', 'history', True, 'History.png'), ('Horror', 'horror', True, 'Horror.png'), ('Music ', 'music', True, 'Music.png'), ('Musical', 'musical', True, 'Musical.png'), ('Mystery', 'mystery', True, 'Mystery.png'), ('Romance', 'romance', True, 'Romance.png'), ('Science Fiction', 'sci_fi', True, 'Science Fiction.png'), ('Sport', 'sport', True, 'Sport.png'), ('Thriller', 'thriller', True, 'Thriller.png'), ('War', 'war', True, 'War.png') , ('Western', 'western', True, 'Western.png'), ] for i in genres: self.list.append( { 'name': cleangenre.lang(i[0], self.lang), 'url': self.genre_link % i[1] if i[2] else self.keyword_link % i[1], 'image': i[3], 'action': 'movies' }) self.addDirectory(self.list) return self.list
def channelDirectory(self, items): if items == None or len(items) == 0: interface.Loader.hide() interface.Dialog.notification(title = 32007, message = 33049, icon = interface.Dialog.IconInformation) sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), tools.Settings.getBoolean('interface.fanart') try: isOld = False ; control.item().getArt('type') except: isOld = True isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' # Gaia presetMenu = control.lang(35058).encode('utf-8') if control.setting('providers.customization.presets.enabled') == 'true' else None playbackMenu = control.lang(32063).encode('utf-8') if control.setting('playback.automatic.enabled') == 'true' 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: # [GAIACODE] #label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(), i['title'], i['year']) label = '[B]%s[/B][CR]%s (%s)' % (i['channel'].upper(), i['title'], i['year']) # [/GAIACODE] sysname = urllib.quote_plus('%s (%s)' % (i['title'], i['year'])) systitle = urllib.quote_plus(i['title']) imdb, year = i['imdb'], i['year'] meta = dict((k,v) for k, v in i.iteritems() if not v == '0') 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 # Gaia # Some descriptions have a link at the end that. Remove it. try: plot = meta['plot'] index = plot.rfind('See full summary') if index >= 0: plot = plot[:index] plot = plot.strip() if re.match('[a-zA-Z\d]$', plot): plot += ' ...' meta['plot'] = plot except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = self.parameterize('%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((interface.Translation.string(35119), 'RunPlugin(%s?action=shortcutsShow&link=%s&name=%s&create=1)' % (sysaddon, sysurl, label))) cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)) if not self.kidsOnly() and control.setting('downloads.manual.enabled') == 'true': cm.append((control.lang(33585).encode('utf-8'), 'Container.Update(%s?action=downloadsManager)' % (sysaddon))) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) # Gaia if presetMenu: cm.append((presetMenu, 'RunPlugin(%s?action=presetSources&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 = {} poster = '0' if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart if not poster == '0' and not poster == None: art.update({'poster' : poster}) if not icon == '0' and not icon == None: art.update({'icon' : icon}) if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb}) if not banner == '0' and not banner == None: art.update({'banner' : banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass control.content(syshandle, 'files') 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 channelDirectory(self, items): if items == None or len(items) == 0: interface.Loader.hide() interface.Dialog.notification( title=32007, message=33049, icon=interface.Dialog.IconInformation) sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart( ), tools.Settings.getBoolean('interface.theme.fanart') indicators = playcount.getMovieIndicators() isPlayable = 'true' if not 'plugin' in control.infoLabel( 'Container.PluginName') else 'false' ratingsOwn = tools.Settings.getInteger('interface.ratings.type') == 1 context = interface.Context.enabled() for i in items: try: title = i['title'] imdb, tmdb, year = i['imdb'], i['tmdb'], i['year'] label = '[B]%s[/B][CR]%s (%s)' % (i['channel'].upper(), title, year) name = '%s (%s)' % (title, year) sysname = urllib.quote_plus(name) systitle = urllib.quote_plus(title) meta = dict((k, v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'movie'}) meta.update({ 'trailer': self.parameterize( '%s?action=streamsVideo&video=trailer&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb)) }) meta.update({'playcount': 0, 'overlay': 6}) try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass # Gaia # Some descriptions have a link at the end that. Remove it. try: plot = meta['plot'] index = plot.rfind('See full summary') if index >= 0: plot = plot[:index] plot = plot.strip() if re.match('[a-zA-Z\d]$', plot): plot += ' ...' meta['plot'] = plot except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = self.parameterize( '%s?action=scrape&title=%s&year=%s&imdb=%s&metadata=%s' % (sysaddon, systitle, year, imdb, sysmeta)) meta.update( tools.Rater.extract(meta) ) # Update again, in case the old metadata was retrieved from cache, but the settings changed. watched = int(playcount.getMovieOverlay(indicators, imdb)) == 7 if watched: meta.update({'playcount': 1, 'overlay': 7}) else: meta.update({'playcount': 0, 'overlay': 6}) meta.update( {'watched': int(watched)} ) # Kodi's documentation says this value is deprecate. However, without this value, Kodi adds the watched checkmark over the remaining episode count. item = control.item(label=label) poster = '0' if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart art = {} if not poster == '0' and not poster == None: art.update({'poster': poster}) if not icon == '0' and not icon == None: art.update({'icon': icon}) if not thumb == '0' and not thumb == None: art.update({'thumb': thumb}) if not banner == '0' and not banner == None: art.update({'banner': banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo': clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart': clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels=tools.Media.metadataClean(meta)) if context: item.addContextMenuItems([ interface.Context(mode=interface.Context.ModeItem, type=self.type, kids=self.kids, create=True, queue=True, watched=watched, refresh=True, metadata=meta, art=art, label=label, link=url, title=title, year=year, imdb=imdb, tmdb=tmdb).menu() ]) 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') 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, sysname)}) 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)')) 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 channelDirectory(self, items): if items == None or len(items) == 0: return #control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() traktCredentials = trakt.getTraktCredentialsInfo() kodiVersion = control.getKodiVersion() isPlayable = True if not 'plugin' in control.infoLabel('Container.PluginName') else False indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators() if self.trailer_source == '0': trailerAction = 'tmdb_trailer' elif self.trailer_source == '1': trailerAction = 'yt_trailer' else: trailerAction = 'imdb_trailer' playbackMenu = control.lang(32063) if control.setting('hosts.mode') == '2' else control.lang(32064) watchedMenu = control.lang(32068) if trakt.getTraktIndicatorsInfo() == True else control.lang(32066) unwatchedMenu = control.lang(32069) if trakt.getTraktIndicatorsInfo() == True else control.lang(32067) queueMenu = control.lang(32065) traktManagerMenu = control.lang(32070) nextMenu = control.lang(32053) addToLibrary = control.lang(32551) clearProviders = control.lang(32081) findSimilar = control.lang(32100) infoMenu = control.lang(32101) for i in items: try: imdb, tmdb, title, year = i['imdb'], i['tmdb'], i['originaltitle'], i['year'] label = i['label'] if 'label' in i and not i['label'] == '0' else title label = '%s (%s)' % (label, year) if 'channel' in i: label = '[B]%s[/B] : %s' % (i['channel'].upper(), label) status = i['status'] if 'status' in i else '0' sysname = urllib_parse.quote_plus('%s (%s)' % (title, year)) systitle = urllib_parse.quote_plus(title) meta = dict((k,v) for k, v in six.iteritems(i) if not v == '0') meta.update({'imdbnumber': imdb, 'code': tmdb}) meta.update({'mediatype': 'movie'}) meta.update({'trailer': '%s?action=%s&name=%s&tmdb=%s&imdb=%s' % (sysaddon, trailerAction, systitle, tmdb, imdb)}) if not 'duration' in i: meta.update({'duration': '120'}) elif i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass if 'castwiththumb' in i and not i['castwiththumb'] == '0': meta.pop('cast', '0') poster = i['poster'] if 'poster' in i and not i['poster'] == '0' else addonPoster meta.update({'poster': poster}) sysmeta = urllib_parse.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_parse.quote_plus(url) #path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb) cm = [] cm.append((findSimilar, 'Container.Update(%s?action=movies&url=%s)' % (sysaddon, urllib_parse.quote_plus(self.related_link % tmdb)))) cm.append(('[I]Cast[/I]', 'RunPlugin(%s?action=moviecredits&tmdb=%s&status=%s)' % (sysaddon, tmdb, status))) cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) try: overlay = int(playcount.getMovieOverlay(indicators, imdb)) if overlay == 7: cm.append((unwatchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb))) meta.update({'playcount': 1, 'overlay': 7}) else: cm.append((watchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb))) meta.update({'playcount': 0, 'overlay': 6}) except: pass if traktCredentials == True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb))) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if kodiVersion < 17: cm.append((infoMenu, 'Action(Info)')) cm.append((addToLibrary, 'RunPlugin(%s?action=movieToLibrary&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s)' % (sysaddon, sysname, systitle, year, imdb, tmdb))) cm.append(('[I]Scrape Filterless[/I]', 'RunPlugin(%s?action=playUnfiltered&title=%s&year=%s&imdb=%s&meta=%s&t=%s)' % (sysaddon, systitle, year, imdb, sysmeta, self.systime))) cm.append((clearProviders, 'RunPlugin(%s?action=clearCacheProviders)' % sysaddon)) try: item = control.item(label=label, offscreen=True) except: item = control.item(label=label) art = {} art.update({'icon': poster, 'thumb': poster, 'poster': poster}) fanart = i['fanart'] if 'fanart' in i and not i['fanart'] == '0' else addonFanart if self.settingFanart == 'true': art.update({'fanart': fanart}) else: art.update({'fanart': addonFanart}) if 'banner' in i and not i['banner'] == '0': art.update({'banner': i['banner']}) 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 'landscape' in i and not i['landscape'] == '0': landscape = i['landscape'] else: landscape = fanart art.update({'landscape': landscape}) if 'discart' in i and not i['discart'] == '0': art.update({'discart': i['discart']}) item.setArt(art) item.addContextMenuItems(cm) if isPlayable: item.setProperty('IsPlayable', 'true') castwiththumb = i.get('castwiththumb') if castwiththumb and not castwiththumb == '0': if kodiVersion >= 18: item.setCast(castwiththumb) else: cast = [(p['name'], p['role']) for p in castwiththumb] meta.update({'cast': cast}) offset = bookmarks.get('movie', imdb, '', '', True) if float(offset) > 120: percentPlayed = int(float(offset) / float(meta['duration']) * 100) item.setProperty('resumetime', str(offset)) item.setProperty('percentplayed', str(percentPlayed)) item.setProperty('imdb_id', imdb) item.setProperty('tmdb_id', tmdb) try: item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb}) except: pass item.setInfo(type='Video', infoLabels = control.metadataClean(meta)) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: log_utils.log('channels_dir', 1) pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def seasonDirectory(self, items): from sys import argv # some functions like ActivateWindow() throw invalid handle less this is imported here. if not items: # with reuselanguageinvoker on an empty directory must be loaded, do not use sys.exit() control.hide() control.notification(title=32054, message=33049) sysaddon, syshandle = argv[0], int(argv[1]) is_widget = 'plugin' not in control.infoLabel('Container.PluginName') settingFanart = getSetting('fanart') == 'true' addonPoster, addonFanart, addonBanner = control.addonPoster( ), control.addonFanart(), control.addonBanner() try: indicators = getSeasonIndicators( items[0]['imdb']) # refresh not needed now due to service sync except: indicators = None if trakt.getTraktIndicatorsInfo(): watchedMenu, unwatchedMenu = getLS(32068), getLS(32069) else: watchedMenu, unwatchedMenu = getLS(32066), getLS(32067) traktManagerMenu, queueMenu = getLS(32070), getLS(32065) showPlaylistMenu, clearPlaylistMenu = getLS(35517), getLS(35516) labelMenu, playRandom = getLS(32055), getLS(32535) addToLibrary = getLS(32551) try: multi = [i['tvshowtitle'] for i in items] except: multi = [] multi = True if len( [x for y, x in enumerate(multi) if x not in multi[:y]]) > 1 else False for i in items: try: title, imdb, tmdb, tvdb, year, season = i.get( 'tvshowtitle'), i.get('imdb', ''), i.get('tmdb', ''), i.get( 'tvdb', ''), i.get('year', ''), i.get('season') label = '%s %s' % (labelMenu, season) try: if i['unaired'] == 'true': label = '[COLOR %s][I]%s[/I][/COLOR]' % ( self.unairedcolor, label) except: pass systitle = quote_plus(title) meta = dict((k, v) for k, v in iter(i.items()) if v is not None and v != '') # setting mediatype to "season" causes "Infomation" and "play trailer" to not be available in some skins meta.update( { 'code': imdb, 'imdbnumber': imdb, 'mediatype': 'tvshow', 'tag': [imdb, tmdb] } ) # "tag" and "tagline" for movies only, but works in my skin mod so leave try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass poster = meta.get( 'tvshow.poster') or addonPoster # tvshow.poster if self.prefer_tmdbArt: season_poster = meta.get('season_poster') or meta.get( 'season_poster2') or poster else: season_poster = meta.get('season_poster2') or meta.get( 'season_poster') or poster fanart = '' if settingFanart: fanart = meta.get('fanart') or addonFanart icon = meta.get('icon') or poster banner = meta.get('banner') or addonBanner art = {} art.update({ 'poster': season_poster, 'tvshow.poster': poster, 'season.poster': season_poster, 'fanart': fanart, 'icon': icon, 'thumb': season_poster, 'banner': banner, 'clearlogo': meta.get('clearlogo', ''), 'tvshow.clearlogo': meta.get('clearlogo', ''), 'clearart': meta.get('clearart', ''), 'tvshow.clearart': meta.get('clearart', ''), 'landscape': meta.get('landscape') }) # for k in ('poster2', 'poster3', 'fanart2', 'fanart3', 'banner2', 'banner3'): meta.pop(k, None) meta.update({ 'poster': poster, 'fanart': fanart, 'banner': banner, 'thumb': season_poster, 'season_poster': season_poster, 'icon': icon }) ####-Context Menu and Overlays-#### cm = [] try: overlay = int( getSeasonOverlay(indicators, imdb, tvdb, season)) watched = (overlay == 5) if self.traktCredentials: cm.append(( traktManagerMenu, 'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&season=%s&watched=%s)' % (sysaddon, systitle, imdb, tvdb, season, watched))) if watched: meta.update({'playcount': 1, 'overlay': 5}) cm.append(( unwatchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=4)' % (sysaddon, systitle, imdb, tvdb, season))) else: meta.update({'playcount': 0, 'overlay': 4}) cm.append(( watchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=5)' % (sysaddon, systitle, imdb, tvdb, season))) except: pass sysmeta = quote_plus(jsdumps(meta)) cm.append(( playRandom, 'RunPlugin(%s?action=play_Random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s&season=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta, season))) cm.append((queueMenu, 'RunPlugin(%s?action=playlist_QueueItem&name=%s)' % (sysaddon, systitle))) cm.append((showPlaylistMenu, 'RunPlugin(%s?action=playlist_Show)' % sysaddon)) cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=playlist_Clear)' % sysaddon)) cm.append(( addToLibrary, 'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb))) cm.append( ('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=tools_openSettings)' % sysaddon)) #################################### url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s&season=%s' % ( sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta, season) item = control.item(label=label, offscreen=True) if 'castandart' in i: item.setCast(i['castandart']) item.setArt(art) try: count = getSeasonCount(imdb, season) if count: item.setProperties({ 'WatchedEpisodes': str(count['watched']), 'UnWatchedEpisodes': str(count['unwatched']) }) item.setProperties({ 'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': str(count['total']) }) else: if meta.get('status') != 'Returning Series' or ( meta.get('status') == 'Returning Series' and meta.get('last_episode_to_air', {}).get( 'season_number') > int(season)): item.setProperties({ 'WatchedEpisodes': '0', 'UnWatchedEpisodes': str( meta.get('counts', {}).get(str(season), '')) }) item.setProperties({ 'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': str(meta.get('total_episodes', '')) }) else: if meta.get( 'last_episode_to_air', {}).get('season_number') == int(season): item.setProperties({ 'WatchedEpisodes': '0', 'UnWatchedEpisodes': str( meta.get('last_episode_to_air', {}).get('episode_number')) }) item.setProperties({ 'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': str( meta.get('last_episode_to_air', {}).get('episode_number')) }) else: item.setProperties({ 'WatchedEpisodes': '0', 'UnWatchedEpisodes': '0' }) item.setProperties({ 'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': '0' }) except: pass if is_widget: item.setProperty('isVenom_widget', 'true') try: # Year is the shows year, not the seasons year. Extract year from premier date for InfoLabels to have "season_year". season_year = re.findall(r'(\d{4})', i.get('premiered', ''))[0] meta.update({'year': season_year}) except: pass item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb}) item.setProperty('IsPlayable', 'false') item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: from resources.lib.modules import log_utils log_utils.error() try: control.property(syshandle, 'showplot', items[0]['plot']) except: pass control.content(syshandle, 'seasons') control.directory( syshandle, cacheToDisc=False ) # disable cacheToDisc so unwatched counts loads fresh data counts if changes made views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def seasonDirectory(self, items): if not items: control.hide() control.notification(title=32054, message=33049) sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) is_widget = 'plugin' not in control.infoLabel('Container.PluginName') settingFanart = control.setting('fanart') addonPoster = control.addonPoster() addonFanart = control.addonFanart() addonBanner = control.addonBanner() try: indicators = playcount.getSeasonIndicators(items[0]['imdb'], refresh=True) except: indicators = None unwatchedEnabled = control.setting( 'tvshows.unwatched.enabled') == 'true' if trakt.getTraktIndicatorsInfo(): watchedMenu = control.lang(32068) unwatchedMenu = control.lang(32069) else: watchedMenu = control.lang(32066) unwatchedMenu = control.lang(32067) traktManagerMenu = control.lang(32070) queueMenu = control.lang(32065) showPlaylistMenu = control.lang(35517) clearPlaylistMenu = control.lang(35516) labelMenu = control.lang(32055) playRandom = control.lang(32535) addToLibrary = control.lang(32551) 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 if self.disable_fanarttv != 'true': tvdb = [i['tvdb'] for i in items][0] from resources.lib.indexers import fanarttv extended_art = cache.get(fanarttv.get_tvshow_art, 168, tvdb) else: extended_art = None for i in items: try: imdb, tmdb, tvdb, year, season = i.get('imdb', '0'), i.get( 'tmdb', '0'), i.get('tvdb', '0'), i.get('year', '0'), i['season'] title = i['tvshowtitle'] label = '%s %s' % (labelMenu, i['season']) if not self.season_special and control.setting( 'tv.specials') == 'true': self.season_special = True if int(season) == 0 else False try: if i['unaired'] == 'true': label = '[COLOR %s][I]%s[/I][/COLOR]' % ( self.unairedcolor, label) except: pass systitle = quote_plus(title) meta = dict((k, v) for k, v in i.iteritems() if v != '0') meta.update({ 'code': imdb, 'imdbnumber': imdb, 'mediatype': 'tvshow', 'tag': [imdb, tvdb] }) # Some descriptions have a link at the end that. Remove it. try: plot = meta['plot'] index = plot.rfind('See full summary') if index >= 0: plot = plot[:index] plot = plot.strip() if re.match(r'[a-zA-Z\d]$', plot): plot += ' ...' meta['plot'] = plot except: pass try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: meta.update({'tvshowtitle': i['label']}) except: pass try: # Year is the shows year, not the seasons year. Extract the correct year from the premier date. yearNew = re.findall(r'(\d{4})', i['premiered'])[0] yearNew = yearNew.encode('utf-8') meta.update({'year': yearNew}) except: pass # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster = meta.get('thumb') or meta.get('poster3') or meta.get( 'poster2') or poster1 or addonPoster fanart = '' if settingFanart: fanart = meta.get('fanart3') or meta.get( 'fanart2') or meta.get('fanart') or addonFanart thumb = meta.get('thumb') or poster icon = meta.get('icon') or poster banner = meta.get('banner3') or meta.get( 'banner2') or meta.get('banner') or addonBanner if extended_art: clearlogo = extended_art.get('clearlogo') clearart = extended_art.get('clearart') else: clearlogo = '0' clearart = '0' art = {} art.update({ 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'fanart': fanart, 'icon': icon, 'thumb': thumb, 'banner': banner, 'clearlogo': clearlogo, 'clearart': clearart }) ####-Context Menu and Overlays-#### cm = [] if self.traktCredentials: cm.append(( traktManagerMenu, 'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)' % (sysaddon, systitle, imdb, tvdb, season))) try: overlay = int( playcount.getSeasonOverlay(indicators, imdb, tvdb, season)) watched = overlay == 7 if watched: meta.update({'playcount': 1, 'overlay': 7}) cm.append(( unwatchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)' % (sysaddon, systitle, imdb, tvdb, season))) else: meta.update({'playcount': 0, 'overlay': 6}) cm.append(( watchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)' % (sysaddon, systitle, imdb, tvdb, season))) except: pass url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&season=%s' % ( sysaddon, systitle, year, imdb, tmdb, tvdb, season) cm.append(( playRandom, 'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)' % (sysaddon, systitle, year, imdb, tvdb, season))) cm.append((queueMenu, 'RunPlugin(%s?action=playlist_QueueItem&name=%s)' % (sysaddon, systitle))) cm.append((showPlaylistMenu, 'RunPlugin(%s?action=playlist_Show)' % sysaddon)) cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=playlist_Clear)' % sysaddon)) cm.append(( addToLibrary, 'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb))) cm.append( ('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=tools_openSettings)' % sysaddon)) #################################### if not i.get('trailer'): meta.update({ 'trailer': '%s?action=trailer&type=%s&name=%s&year=%s&imdb=%s' % (sysaddon, 'show', quote_plus(title), year, imdb) }) item = control.item(label=label) if 'castandart' in i: item.setCast(i['castandart']) if 'episodeIDS' in i: item.setUniqueIDs(i['episodeIDS']) if unwatchedEnabled: count = playcount.getSeasonCount(imdb, season, self.season_special) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) if 'total_seasons' in meta: item.setProperty('TotalSeasons', str(meta.get('total_seasons'))) item.setArt(art) item.setProperty('IsPlayable', 'false') if is_widget: item.setProperty('isVenom_widget', 'true') item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.addContextMenuItems(cm) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: log_utils.error() try: control.property(syshandle, 'showplot', items[0]['plot']) except: pass control.content(syshandle, 'seasons') control.directory(syshandle, cacheToDisc=True) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def movieDirectory(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 isEstuary = True if 'estuary' in control.skin else False isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators() playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8') 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') for i in items: try: label = '%s (%s)' % (i['title'], i['year']) imdb, title, year = i['imdb'], i['originaltitle'], i['year'] sysname = urllib.quote_plus('%s (%s)' % (title, year)) systitle = urllib.quote_plus(title) poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if banner == '0' and not fanart == '0': banner = fanart elif banner == '0' and not poster == '0': banner = poster if poster == '0': poster = addonPoster if banner == '0': banner = addonBanner meta = dict((k,v) for k, v in i.iteritems() if not v == '0') 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}) if i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass if isEstuary == True: try: del meta['cast'] 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) path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb) cm = [] cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) try: overlay = int(playcount.getMovieOverlay(indicators, imdb)) if overlay == 7: cm.append((unwatchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb))) meta.update({'playcount': 1, 'overlay': 7}) else: cm.append((watchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb))) meta.update({'playcount': 0, 'overlay': 6}) except: pass if traktCredentials == True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb))) 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) item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner}) if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass try: url = items[0]['next'] if url == '': raise Exception() icon = control.addonNext() url = '%s?action=moviePage&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, 'movies') #control.do_block_check(False) control.directory(syshandle, cacheToDisc=True) views.setView('movies', {'skin.confluence': 500})
def episodeDirectory(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(), tools.Settings.getBoolean('interface.fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False ; control.item().getArt('type') except: isOld = True isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' 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 = '' isFolder = False if not sysaction == 'episodes' else True playbackMenu = control.lang(32063).encode('utf-8') if control.setting('playback.automatic.enabled') == 'true' else control.lang(32064).encode('utf-8') traktHas = trakt.getTraktIndicatorsInfo() == True watchedMenu = control.lang(32068).encode('utf-8') if traktHas else control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') if traktHas else control.lang(32067).encode('utf-8') unwatchedEnabled = tools.Settings.getBoolean('interface.tvshows.unwatched.enabled') unwatchedLimit = tools.Settings.getBoolean('interface.tvshows.unwatched.limit') airEnabled = tools.Settings.getBoolean('interface.tvshows.air.enabled') if airEnabled: airZone = tools.Settings.getInteger('interface.tvshows.air.zone') airLocation = tools.Settings.getInteger('interface.tvshows.air.location') airFormat = tools.Settings.getInteger('interface.tvshows.air.format') airAbbreviation = tools.Settings.getBoolean('interface.tvshows.air.abbreviation') airBold = tools.Settings.getBoolean('interface.tvshows.air.bold') airLabel = interface.Format.bold(interface.Translation.string(35032) + ': ') queueMenu = control.lang(32065).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') tvshowBrowserMenu = control.lang(32071).encode('utf-8') media = tools.Media() for i in items: try: if not 'label' in i: i['label'] = i['title'] if i['label'] == None or i['label'] == '' or i['label'] == '0': i['label'] = '%s %d' % (layoutEpisodeLong, int(i['episode'])) label = None try: label = media.title(tools.Media.TypeEpisode, title = i['label'], season = i['season'], episode = i['episode']) except: pass if label == None: label = i['label'] if multi == True and not label in i['tvshowtitle'] and not i['tvshowtitle'] in label: label = '%s - %s' % (i['tvshowtitle'], label) imdb, tvdb, year, season, episode, premiered = i['imdb'], i['tvdb'], i['year'], i['season'], i['episode'], i['premiered'] # Make new episodes italicself. date = tools.Time.datetime(premiered, format = '%Y-%m-%d') current = datetime.datetime.now() if current <= date or current.date() == date.date(): label = '[I]' + label + '[/I]' systitle = urllib.quote_plus(i['title']) systvshowtitle = urllib.quote_plus(i['tvshowtitle']) syspremiered = urllib.quote_plus(i['premiered']) meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'episode'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, systvshowtitle)}) # Bubbles # Remove default time, since this might mislead users. Rather show no time. #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: meta.update({'title': i['label']}) except: pass try: meta.update({'year': date.year}) # Kodi uses the year (the year the show started) as the year for the episode. Change it from the premiered date. except: pass if airEnabled: air = [] airday = None airtime = None if 'airday' in meta and not meta['airday'] == None and not meta['airday'] == '': airday = meta['airday'] if 'airtime' in meta and not meta['airtime'] == None and not meta['airtime'] == '': airtime = meta['airtime'] if 'airzone' in meta and not meta['airzone'] == None and not meta['airzone'] == '': if airLocation == 1: zoneTo = meta['airzone'] elif airLocation == 2: zoneTo = tools.Time.ZoneUtc else: zoneTo = tools.Time.ZoneLocal airtime = tools.Time.local(stringTime = meta['airtime'], stringDay = airday, zoneFrom = meta['airzone'], zoneTo = zoneTo) if airday: airday = airtime[1] airtime = airtime[0] if airday: if airAbbreviation: try: airday = airday[:3] except: pass air.append(airday) if airtime: air.append(airtime) if len(air) > 0: if airFormat == 0: air = airtime elif airFormat == 1: air = airday elif airFormat == 2: air = air = ' '.join(air) if airLocation == 0 or airLocation == 1: air = '[%s]' % air if airBold: air = interface.Format.bold(air) if airLocation == 0: label = '%s %s' % (air, label) elif airLocation == 1: label = '%s %s' % (label, air) elif airLocation == 2: meta['plot'] = '%s%s\r\n%s' % (airLabel, air, meta['plot']) elif airLocation == 3: meta['plot'] = '%s%s\r\n%s' % (airLabel, meta['plot'], air) airEnabled = tools.Settings.getBoolean('interface.tvshows.air.enabled') if airEnabled: airZone = tools.Settings.getInteger('interface.tvshows.air.zone') airLocation = tools.Settings.getInteger('interface.tvshows.air.location') airFormat = tools.Settings.getInteger('interface.tvshows.air.format') airAbbreviation = tools.Settings.getBoolean('interface.tvshows.air.abbreviation') airBold = tools.Settings.getBoolean('interface.tvshows.air.bold') sysmeta = urllib.quote_plus(json.dumps(meta)) url = self.parameterize('%s?action=play&title=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s&tvshowtitle=%s&premiered=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, tvdb, season, episode, systvshowtitle, syspremiered, sysmeta, self.systime)) sysurl = urllib.quote_plus(url) path = self.parameterize('%s?action=play&title=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s&tvshowtitle=%s&premiered=%s' % (sysaddon, systitle, year, imdb, tvdb, season, episode, systvshowtitle, syspremiered)) if isFolder == True: url = self.parameterize('%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s' % (sysaddon, systvshowtitle, year, imdb, tvdb, season, episode)) cm = [] cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) if multi == True: link = self.parameterize('%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systvshowtitle, year, imdb, tvdb)) cm.append((tvshowBrowserMenu, 'Container.Update(%s,return)' % link)) try: overlay = int(playcount.getEpisodeOverlay(indicators, imdb, tvdb, season, episode)) if overlay == 7: if not traktHas: link = self.parameterize('%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=6' % (sysaddon, imdb, tvdb, season, episode)) cm.append((unwatchedMenu, 'RunPlugin(%s)' % link)) meta.update({'playcount': 1, 'overlay': 7}) else: if not traktHas: link = self.parameterize('%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=7' % (sysaddon, imdb, tvdb, season, episode)) cm.append((watchedMenu, 'RunPlugin(%s)' % link)) meta.update({'playcount': 0, 'overlay': 6}) except: overlay = None if traktCredentials == True: link = self.parameterize('%s?action=traktManager&tvdb=%s&season=%s&episode=%s' % (sysaddon, tvdb, season, episode)) cm.append((traktManagerMenu, 'RunPlugin(%s)' % link)) if not self.kidsOnly() and control.setting('downloads.manual.enabled') == 'true': cm.append((control.lang(33585).encode('utf-8'), 'Container.Update(%s?action=downloadsManager)' % (sysaddon))) if isFolder == False: 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) if multi and unwatchedEnabled and not overlay == None and not overlay == 7: try: count = playcount.getShowCount(indicators, tvdb, unwatchedLimit) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) except: pass art = {} poster = '0' if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart if not poster == '0' and not poster == None: art.update({'poster' : poster, 'tvshow.poster' : poster, 'season.poster' : poster}) if not icon == '0' and not icon == None: art.update({'icon' : icon}) if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb}) if not banner == '0' and not banner == None: art.update({'banner' : banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder) except: tools.Logger.error pass # Bubbles # Show multi as show, in order to display unwatched count. if multi: control.content(syshandle, 'tvshows') control.directory(syshandle, cacheToDisc=True) views.setView('shows', {'skin.estuary': 55, 'skin.confluence': 500}) else: control.content(syshandle, 'episodes') control.directory(syshandle, cacheToDisc=True) views.setView('episodes', {'skin.estuary': 55, 'skin.confluence': 504})
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 movieDirectory(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 isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators() playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8') 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') addToLibrary = control.lang(32551).encode('utf-8') for i in items: try: label = '%s (%s)' % (i['title'], i['year']) imdb, tmdb, title, year = i['imdb'], i['tmdb'], i['originaltitle'], i['year'] sysname = urllib.quote_plus('%s (%s)' % (title, year)) systitle = urllib.quote_plus(title) 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, urllib.quote_plus(label))}) #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb}) if not 'duration' in i: meta.update({'duration': '120'}) elif i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass poster = [i[x] for x in ['poster3', 'poster', 'poster2'] if i.get(x, '0') != '0'] poster = poster[0] if poster else addonPoster meta.update({'poster': poster}) 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) path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb) cm = [] cm.append(('Find similar', 'ActivateWindow(10025,%s?action=movies&url=https://api.trakt.tv/movies/%s/related,return)' % ( sysaddon, imdb))) cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) try: overlay = int(playcount.getMovieOverlay(indicators, imdb)) if overlay == 7: cm.append((unwatchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb))) meta.update({'playcount': 1, 'overlay': 7}) else: cm.append((watchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb))) meta.update({'playcount': 0, 'overlay': 6}) except: pass if traktCredentials == True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb))) 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)')) cm.append((addToLibrary, 'RunPlugin(%s?action=movieToLibrary&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s)' % (sysaddon, sysname, systitle, year, imdb, tmdb))) item = control.item(label=label) art = {} art.update({'icon': poster, 'thumb': poster, 'poster': poster}) if 'banner' in i and not i['banner'] == '0': art.update({'banner': i['banner']}) 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 'fanart2' in i and not i['fanart2'] == '0': item.setProperty('Fanart_Image', i['fanart2']) elif 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 try: url = items[0]['next'] if url == '': raise Exception() icon = control.addonNext() url = '%s?action=moviePage&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, 'movies') control.directory(syshandle, cacheToDisc=True) views.setView('movies', {'skin.estuary': 55, 'skin.confluence': 500})
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 isEstuary = True if 'estuary' in control.skin else False indicators = playcount.getTVShowIndicators(refresh=True) if action == 'tvshows' else playcount.getTVShowIndicators() 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') 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'] poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if banner == '0' and not fanart == '0': banner = fanart elif banner == '0' and not poster == '0': banner = poster if poster == '0': poster = addonPoster if banner == '0': banner = addonBanner meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'tvshow'}) 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 try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass if isEstuary == True: try: del meta['cast'] 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 url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb) cm = [] 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)')) item = control.item(label=label) item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner}) if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels = meta) 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, 'tvshow.poster': icon, 'season.poster': icon, 'banner': icon, 'tvshow.banner': icon, 'season.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.do_block_check(False) control.directory(syshandle, cacheToDisc=True) views.setView('tvshows', {'skin.confluence': 500})
def seasonDirectory(self, items): if isinstance(items, dict) and 'value' in items: items = items['value'] if isinstance(items, basestring): try: items = tools.Converter.jsonFrom(items) except: pass if items == None or len(items) == 0: interface.Loader.hide() interface.Dialog.notification(title = 32054, message = 33049, icon = interface.Dialog.IconInformation) sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) media = tools.Media() addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), tools.Settings.getBoolean('interface.fanart') try: indicators = playcount.getSeasonIndicators(items[0]['imdb']) except: indicators = None unwatchedEnabled = tools.Settings.getBoolean('interface.tvshows.unwatched.enabled') unwatchedLimit = tools.Settings.getBoolean('interface.tvshows.unwatched.limit') 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 for i in items: try: imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i['season'] title = i['tvshowtitle'] label = None try: label = media.title(tools.Media.TypeSeason, season = season) except: pass if label == None: label = season if multi == True and not label in title and not title in label: label = '%s - %s' % (title, label) systitle = sysname = urllib.quote_plus(title) meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'tvshow'}) meta.update({'trailer': '%s?action=streamsTrailer&title=%s&imdb=%s' % (sysaddon, sysname, imdb)}) # Gaia # Remove default time, since this might mislead users. Rather show no time. #if not 'duration' in i: meta.update({'duration': '60'}) #elif i['duration'] == '0': meta.update({'duration': '60'}) # Gaia # Some descriptions have a link at the end that. Remove it. try: plot = meta['plot'] index = plot.rfind('See full summary') if index >= 0: plot = plot[:index] plot = plot.strip() if re.match('[a-zA-Z\d]$', plot): plot += ' ...' meta['plot'] = plot except: pass try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: meta.update({'tvshowtitle': i['label']}) except: pass try: # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date. yearNew = i['premiered'] yearNew = re.findall('(\d{4})', yearNew)[0] yearNew = yearNew.encode('utf-8') meta.update({'year': yearNew}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = self.parameterize('%s?action=episodesRetrieve&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tvdb, season)) item = control.item(label = label) try: overlay = int(playcount.getSeasonOverlay(indicators, imdb, tvdb, season)) watched = overlay == 7 if watched: meta.update({'playcount': 1, 'overlay': 7}) else: meta.update({'playcount': 0, 'overlay': 6}) if unwatchedEnabled and not watched: count = playcount.getSeasonCount(imdb, season, unwatchedLimit) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) except: pass # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster = '0' if poster == '0' and 'thumb3' in i: poster = i['thumb3'] if poster == '0' and 'thumb2' in i: poster = i['thumb2'] if poster == '0' and 'thumb' in i: poster = i['thumb'] if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart art = {} if not poster == '0' and not poster == None: art.update({'poster' : poster, 'tvshow.poster' : poster, 'season.poster' : poster}) if not icon == '0' and not icon == None: art.update({'icon' : icon}) if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb}) if not banner == '0' and not banner == None: art.update({'banner' : banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.setInfo(type = 'Video', infoLabels = tools.Media.metadataClean(meta)) item.addContextMenuItems([interface.Context(mode = interface.Context.ModeItem, type = self.type, kids = self.kids, create = True, watched = watched, season = season, metadata = meta, art = art, label = label, link = url, trailer = title, title = title, year = year, imdb = imdb, tvdb = tvdb).menu()]) 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) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def seasonDirectory(self, items): if not items: # with reuselanguageinvoker on an empty directory must be loaded, do not use sys.exit() control.hide() control.notification(title=32054, message=33049) sysaddon, syshandle = argv[0], int(argv[1]) is_widget = 'plugin' not in control.infoLabel('Container.PluginName') settingFanart = control.setting('fanart') == 'true' addonPoster, addonFanart, addonBanner = control.addonPoster( ), control.addonFanart(), control.addonBanner() try: indicators = playcount.getSeasonIndicators(items[0]['imdb'], refresh=True) except: indicators = None unwatchedEnabled = control.setting( 'tvshows.unwatched.enabled') == 'true' if trakt.getTraktIndicatorsInfo(): watchedMenu, unwatchedMenu = control.lang(32068), control.lang( 32069) else: watchedMenu, unwatchedMenu = control.lang(32066), control.lang( 32067) traktManagerMenu, queueMenu = control.lang(32070), control.lang(32065) showPlaylistMenu, clearPlaylistMenu = control.lang( 35517), control.lang(35516) labelMenu, playRandom = control.lang(32055), control.lang(32535) addToLibrary = control.lang(32551) try: multi = [i['tvshowtitle'] for i in items] except: multi = [] multi = True if len( [x for y, x in enumerate(multi) if x not in multi[:y]]) > 1 else False for i in items: try: imdb, tmdb, tvdb, year, season = i.get('imdb', ''), i.get( 'tmdb', ''), i.get('tvdb', ''), i.get('year', ''), i.get('season') title = i.get('tvshowtitle') label = '%s %s' % (labelMenu, i.get('season')) if not self.season_special and self.showspecials: self.season_special = True if int(season) == 0 else False try: if i['unaired'] == 'true': label = '[COLOR %s][I]%s[/I][/COLOR]' % ( self.unairedcolor, label) except: pass systitle = quote_plus(title) meta = dict((k, v) for k, v in control.iteritems(i) if v is not None and v != '') # setting mediatype to "season" causes "Infomation" and "play trailer" to not be available in some skins meta.update( { 'code': imdb, 'imdbnumber': imdb, 'mediatype': 'season', 'tag': [imdb, tmdb] } ) # "tag" and "tagline" for movies only, but works in my skin mod so leave try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster = meta.get('thumb') or meta.get('poster3') or meta.get( 'poster2') or meta.get('poster') or addonPoster season_poster = meta.get('season_poster') or poster landscape = meta.get('landscape') fanart = '' if settingFanart: fanart = meta.get('fanart3') or meta.get( 'fanart2') or meta.get( 'fanart') or landscape or addonFanart thumb = season_poster icon = meta.get('icon') or poster banner = meta.get('banner3') or meta.get( 'banner2') or meta.get('banner') or addonBanner art = {} art.update({ 'poster': season_poster, 'tvshow.poster': poster, 'season.poster': season_poster, 'fanart': fanart, 'icon': icon, 'thumb': thumb, 'banner': banner, 'clearlogo': meta.get('clearlogo'), 'clearart': meta.get('clearart'), 'landscape': landscape }) for k in ('poster2', 'poster3', 'fanart2', 'fanart3', 'banner2', 'banner3'): meta.pop(k, None) meta.update({ 'poster': poster, 'fanart': fanart, 'banner': banner, 'thumb': thumb, 'icon': icon }) ####-Context Menu and Overlays-#### cm = [] if self.traktCredentials: cm.append(( traktManagerMenu, 'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)' % (sysaddon, systitle, imdb, tvdb, season))) try: overlay = int( playcount.getSeasonOverlay(indicators, imdb, tvdb, season)) watched = (overlay == 5) if watched: meta.update({'playcount': 1, 'overlay': 5}) cm.append(( unwatchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=4)' % (sysaddon, systitle, imdb, tvdb, season))) else: meta.update({'playcount': 0, 'overlay': 4}) cm.append(( watchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=5)' % (sysaddon, systitle, imdb, tvdb, season))) except: pass sysmeta = quote_plus(jsdumps(meta)) cm.append(( playRandom, 'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s&season=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta, season))) cm.append((queueMenu, 'RunPlugin(%s?action=playlist_QueueItem&name=%s)' % (sysaddon, systitle))) cm.append((showPlaylistMenu, 'RunPlugin(%s?action=playlist_Show)' % sysaddon)) cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=playlist_Clear)' % sysaddon)) cm.append(( addToLibrary, 'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb))) cm.append( ('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=tools_openSettings)' % sysaddon)) #################################### url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s&season=%s' % ( sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta, season) try: item = control.item(label=label, offscreen=True) except: item = control.item(label=label) if 'castandart' in i: item.setCast(i['castandart']) item.setArt(art) if unwatchedEnabled: try: count = playcount.getSeasonCount( imdb, season, self.season_special ) # self.season_special is just a flag to set if a season special exists and we are set to show it if count: item.setProperties({ 'WatchedEpisodes': str(count['watched']), 'UnWatchedEpisodes': str(count['unwatched']) }) else: item.setProperties( { 'WatchedEpisodes': '0', 'UnWatchedEpisodes': str( meta.get('counts', {}).get(str(season), '')) } ) # temp use TMDb's season-episode count for threads not finished....next load counts will update with trakt data except: pass try: item.setProperties({ 'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': str(meta.get('total_episodes', '')) }) except: pass #da hell with 17 users if is_widget: item.setProperty('isVenom_widget', 'true') try: # Year is the shows year, not the seasons year. Extract year from premier date for InfoLabels to have "season_year". season_year = re.findall(r'(\d{4})', i.get('premiered', ''))[0] meta.update({'year': season_year}) except: pass item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb}) item.setProperty('IsPlayable', 'false') item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: log_utils.error() try: control.property(syshandle, 'showplot', items[0]['plot']) except: pass control.content(syshandle, 'seasons') control.directory(syshandle, cacheToDisc=True) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def seasonDirectory(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( ), tools.Settings.getBoolean('interface.fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False control.item().getArt('type') except: isOld = True try: indicators = playcount.getSeasonIndicators(items[0]['imdb']) except: pass traktHas = trakt.getTraktIndicatorsInfo() == True watchedMenu = control.lang(32068).encode( 'utf-8') if traktHas else control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32069).encode( 'utf-8') if traktHas else control.lang(32067).encode('utf-8') unwatchedEnabled = tools.Settings.getBoolean( 'interface.tvshows.unwatched.enabled') unwatchedLimit = tools.Settings.getBoolean( 'interface.tvshows.unwatched.limit') queueMenu = control.lang(32065).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') media = tools.Media() 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 for i in items: try: label = None try: label = media.title(tools.Media.TypeSeason, season=i['season']) except: pass if label == None: label = i['season'] if multi == True and not label in i['tvshowtitle'] and not i[ 'tvshowtitle'] in label: label = '%s - %s' % (i['tvshowtitle'], label) systitle = sysname = urllib.quote_plus(i['tvshowtitle']) imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i[ 'season'] meta = dict((k, v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'tvshow'}) meta.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname) }) # Bubbles # Remove default time, since this might mislead users. Rather show no time. #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: meta.update({'tvshowtitle': i['label']}) except: pass try: # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date. yearNew = i['premiered'] yearNew = re.findall('(\d{4})', yearNew)[0] yearNew = yearNew.encode('utf-8') meta.update({'year': yearNew}) except: pass try: if season in indicators: meta.update({'playcount': 1, 'overlay': 7}) overlay = 7 else: meta.update({'playcount': 0, 'overlay': 6}) overlay = 6 except: overlay = None url = self.parameterize( '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tvdb, season)) cm = [] cm.append( (queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) if not traktHas: link = self.parameterize( '%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7' % (sysaddon, systitle, imdb, tvdb, season)) cm.append((watchedMenu, 'RunPlugin(%s)' % link)) link = self.parameterize( '%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6' % (sysaddon, systitle, imdb, tvdb, season)) cm.append((unwatchedMenu, 'RunPlugin(%s)' % link)) if traktCredentials == True: link = self.parameterize( '%s?action=traktManager&tvdb=%s&season=%s' % (sysaddon, tvdb, season)) cm.append((traktManagerMenu, 'RunPlugin(%s)' % link)) if not self.kidsOnly() and control.setting( 'downloads.manual.enabled') == 'true': cm.append( (control.lang(33585).encode('utf-8'), 'RunPlugin(%s?action=downloadsManager)' % (sysaddon))) if isOld == True: cm.append( (control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) if unwatchedEnabled and not overlay == None and not overlay == 7: try: count = playcount.getSeasonCount( imdb, season, unwatchedLimit) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) except: pass art = {} # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster = '0' if poster == '0' and 'poster3' in i: poster = i['thumb3'] if poster == '0' and 'poster2' in i: poster = i['thumb2'] if poster == '0' and 'poster' in i: poster = i['thumb'] if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart if not poster == '0' and not poster == None: art.update({ 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster }) if not icon == '0' and not icon == None: art.update({'icon': icon}) if not thumb == '0' and not thumb == None: art.update({'thumb': thumb}) if not banner == '0' and not banner == None: art.update({'banner': banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo': clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart': clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels=meta) 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) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def movieDirectory(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 isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators() playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8') #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') addToLibrary = control.lang(32551).encode('utf-8') for i in items: try: label = '%s (%s)' % (i['title'], i['year']) imdb, tmdb, title, year = i['imdb'], i['tmdb'], i['originaltitle'], i['year'] sysname = urllib.quote_plus('%s (%s)' % (title, year)) systitle = urllib.quote_plus(title) 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, urllib.quote_plus(label))}) #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb}) if not 'duration' in i: meta.update({'duration': '120'}) elif i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass poster = [i[x] for x in ['poster3', 'poster', 'poster2'] if i.get(x, '0') != '0'] poster = poster[0] if poster else addonPoster meta.update({'poster': poster}) 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) path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb) cm = [] cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) try: overlay = int(playcount.getMovieOverlay(indicators, imdb)) if overlay == 7: #cm.append((unwatchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb))) meta.update({'playcount': 1, 'overlay': 7}) else: #cm.append((watchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb))) meta.update({'playcount': 0, 'overlay': 6}) except: pass if traktCredentials == True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb))) 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)')) cm.append((addToLibrary, 'RunPlugin(%s?action=movieToLibrary&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s)' % (sysaddon, sysname, systitle, year, imdb, tmdb))) item = control.item(label=label) art = {} art.update({'icon': poster, 'thumb': poster, 'poster': poster}) if 'banner' in i and not i['banner'] == '0': art.update({'banner': i['banner']}) 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 'fanart2' in i and not i['fanart2'] == '0': item.setProperty('Fanart_Image', i['fanart2']) elif 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 try: url = items[0]['next'] if url == '': raise Exception() icon = control.addonNext() url = '%s?action=moviePage&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, 'movies') control.directory(syshandle, cacheToDisc=True) views.setView('movies', {'skin.estuary': 55, 'skin.confluence': 500})
def tvshowDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting( 'autoplay') == 'false' and control.setting( 'hosts.mode') == '1' else False isFolder = False if control.window.getProperty( 'PseudoTVRunning') == 'True' else isFolder traktCredentials = trakt.getTraktCredentialsInfo() indicators = playcount.getTVShowIndicators() addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting( 'fanart') sysaddon = sys.argv[0] 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'] poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if banner == '0' and not poster == '0': banner = poster if poster == '0': poster = addonPoster if banner == '0': banner = addonBanner 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 try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % ( sysaddon, systitle, year, imdb, tvdb) 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 cm = [] if isFolder == False: cm.append((control.lang(30232).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) if traktCredentials == True: cm.append((control.lang(30236).encode( 'utf-8' ), 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb))) cm.append((control.lang(30242).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname))) cm.append( (control.lang(30233).encode('utf-8'), 'Action(Info)')) cm.append((control.lang(30234).encode( 'utf-8' ), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb))) cm.append((control.lang(30235).encode( 'utf-8' ), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, 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, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=tvshows&url=%s' % (sysaddon, urllib.quote_plus(url)) addonNext = control.addonNext() item = control.item(label=control.lang(30241).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([], replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'tvshows') control.directory(int(sys.argv[1]), cacheToDisc=True) views.setView('tvshows', {'skin.confluence': 500})
def tvshowDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('hosts.mode') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder traktCredentials = trakt.getTraktCredentialsInfo() indicators = playcount.getTVShowIndicators() addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] 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'] poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if banner == '0' and not poster == '0': banner = poster if poster == '0': poster = addonPoster if banner == '0': banner = addonBanner 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 try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb) 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 cm = [] if isFolder == False: cm.append((control.lang(30232).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) if traktCredentials == True: cm.append((control.lang(30236).encode('utf-8'), 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb))) cm.append((control.lang(30242).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname))) cm.append((control.lang(30233).encode('utf-8'), 'Action(Info)')) cm.append((control.lang(30234).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb))) cm.append((control.lang(30235).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, 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, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass try: url = items[0]['next'] if url == '': raise Exception() url = '%s?action=tvshows&url=%s' % (sysaddon, urllib.quote_plus(url)) addonNext = control.addonNext() item = control.item(label=control.lang(30241).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext) item.addContextMenuItems([], replaceItems=False) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'tvshows') control.directory(int(sys.argv[1]), cacheToDisc=True) views.setView('tvshows', {'skin.estuary': 54, 'skin.confluence': 500})
def movieDirectory(self, items, unfinished=False, next=True): if not items: # with reuselanguageinvoker on an empty directory must be loaded, do not use sys.exit() control.hide() ; control.notification(title=32001, message=33049) from resources.lib.modules.player import Bookmarks sysaddon, syshandle = argv[0], int(argv[1]) disable_player_art = control.setting('disable.player.art') == 'true' hosts_mode = control.setting('hosts.mode') is_widget = 'plugin' not in control.infoLabel('Container.PluginName') settingFanart = control.setting('fanart') == 'true' addonPoster, addonFanart, addonBanner = control.addonPoster(), control.addonFanart(), control.addonBanner() indicators = playcount.getMovieIndicators(refresh=True) isPlayable = 'false' if 'plugin' not in control.infoLabel('Container.PluginName'): isPlayable = 'true' elif hosts_mode != '1': isPlayable = 'true' if hosts_mode == '2': playbackMenu = control.lang(32063) else: playbackMenu = control.lang(32064) if trakt.getTraktIndicatorsInfo(): watchedMenu, unwatchedMenu = control.lang(32068), control.lang(32069) else: watchedMenu, unwatchedMenu = control.lang(32066), control.lang(32067) playlistManagerMenu, queueMenu = control.lang(35522), control.lang(32065) traktManagerMenu, addToLibrary = control.lang(32070), control.lang(32551) nextMenu, clearSourcesMenu = control.lang(32053), control.lang(32611) for i in items: try: imdb, tmdb, title, year = i.get('imdb', ''), i.get('tmdb', ''), i['title'], i.get('year', '') trailer, runtime = i.get('trailer'), i.get('duration') label = '%s (%s)' % (title, year) try: labelProgress = label + '[COLOR %s] [%s][/COLOR]' % (self.highlight_color, str(round(float(i['progress'] * 100), 1)) + '%') except: labelProgress = label try: if int(re.sub(r'[^0-9]', '', str(i['premiered']))) > int(re.sub(r'[^0-9]', '', str(self.today_date))): labelProgress = '[COLOR %s][I]%s[/I][/COLOR]' % (self.unairedcolor, labelProgress) except: pass if i.get('traktHistory') is True: try: air_time = tools.Time.convert(stringTime=i.get('lastplayed', ''), zoneFrom='utc', zoneTo='local', formatInput='%Y-%m-%dT%H:%M:%S.000Z', formatOutput='%b %d %Y %I:%M %p') if air_time[12] == '0': air_time = air_time[:12] + '' + air_time[13:] labelProgress = labelProgress + '[COLOR %s] [%s][/COLOR]' % (self.highlight_color, air_time) except: pass sysname, systitle = quote_plus(label), quote_plus(title) meta = dict((k, v) for k, v in control.iteritems(i) if v is not None and v != '') meta.update({'code': imdb, 'imdbnumber': imdb, 'mediatype': 'movie', 'tag': [imdb, tmdb]}) try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass poster = meta.get('poster3') or meta.get('poster2') or meta.get('poster') or addonPoster fanart = '' if settingFanart: fanart = meta.get('fanart3') or meta.get('fanart2') or meta.get('fanart') or addonFanart landscape = meta.get('landscape') or fanart thumb = meta.get('thumb') or poster or landscape icon = meta.get('icon') or poster banner = meta.get('banner3') or meta.get('banner2') or meta.get('banner') or addonBanner art = {} if disable_player_art and hosts_mode == '2': # setResolvedUrl uses the selected ListItem so pop keys out here if user wants no player art for k in ('clearart', 'clearlogo', 'discart'): meta.pop(k, None) art.update({'icon': icon, 'thumb': thumb, 'banner': banner, 'poster': poster, 'fanart': fanart, 'landscape': landscape, 'clearlogo': meta.get('clearlogo', ''), 'clearart': meta.get('clearart', ''), 'discart': meta.get('discart', ''), 'keyart': meta.get('keyart', '')}) for k in ('poster2', 'poster3', 'fanart2', 'fanart3', 'banner2', 'banner3', 'trailer'): meta.pop(k, None) meta.update({'poster': poster, 'fanart': fanart, 'banner': banner}) ####-Context Menu and Overlays-#### cm = [] if self.traktCredentials: cm.append((traktManagerMenu, 'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s)' % (sysaddon, sysname, imdb))) try: overlay = int(playcount.getMovieOverlay(indicators, imdb)) watched = (overlay == 5) if watched: cm.append((unwatchedMenu, 'RunPlugin(%s?action=playcount_Movie&name=%s&imdb=%s&query=4)' % (sysaddon, sysname, imdb))) meta.update({'playcount': 1, 'overlay': 5}) # lastplayed = trakt.watchedMoviesTime(imdb) # meta.update({'lastplayed': lastplayed}) else: cm.append((watchedMenu, 'RunPlugin(%s?action=playcount_Movie&name=%s&imdb=%s&query=5)' % (sysaddon, sysname, imdb))) meta.update({'playcount': 0, 'overlay': 4}) except: pass sysmeta, sysart = quote_plus(jsdumps(meta)), quote_plus(jsdumps(art)) url = '%s?action=play&title=%s&year=%s&imdb=%s&tmdb=%s&meta=%s' % (sysaddon, systitle, year, imdb, tmdb, sysmeta) sysurl = quote_plus(url) cm.append((playlistManagerMenu, 'RunPlugin(%s?action=playlist_Manager&name=%s&url=%s&meta=%s&art=%s)' % (sysaddon, sysname, sysurl, sysmeta, sysart))) cm.append((queueMenu, 'RunPlugin(%s?action=playlist_QueueItem&name=%s)' % (sysaddon, sysname))) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if hosts_mode == '1': cm.append(('Rescrape Item', 'RunPlugin(%s?action=play&title=%s&year=%s&imdb=%s&tmdb=%s&meta=%s&rescrape=true)' % (sysaddon, systitle, year, imdb, tmdb, sysmeta))) elif hosts_mode != '1': cm.append(('Rescrape Item', 'PlayMedia(%s?action=play&title=%s&year=%s&imdb=%s&tmdb=%s&meta=%s&rescrape=true)' % (sysaddon, systitle, year, imdb, tmdb, sysmeta))) cm.append((addToLibrary, 'RunPlugin(%s?action=library_movieToLibrary&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s)' % (sysaddon, sysname, systitle, year, imdb, tmdb))) cm.append(('Find similar', 'ActivateWindow(10025,%s?action=movies&url=https://api.trakt.tv/movies/%s/related,return)' % (sysaddon, imdb))) cm.append((clearSourcesMenu, 'RunPlugin(%s?action=cache_clearSources)' % sysaddon)) cm.append(('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=tools_openSettings)' % sysaddon)) #################################### if trailer: meta.update({'trailer': trailer}) else: meta.update({'trailer': '%s?action=trailer&type=%s&name=%s&year=%s&imdb=%s' % (sysaddon, 'movie', sysname, year, imdb)}) item = control.item(label=labelProgress, offscreen=True) if 'castandart' in i: item.setCast(i['castandart']) item.setArt(art) item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb}) item.setProperty('IsPlayable', isPlayable) if is_widget: item.setProperty('isVenom_widget', 'true') resumetime = Bookmarks().get(name=label, imdb=imdb, tmdb=tmdb, year=str(year), runtime=runtime, ck=True) # item.setProperty('TotalTime', str(meta['duration'])) # Adding this property causes the Kodi bookmark CM items to be added item.setProperty('ResumeTime', str(resumetime)) try: watched_percent = round(float(resumetime) / float(runtime) * 100, 1) # resumetime and runtime are both in seconds item.setProperty('PercentPlayed', str(watched_percent)) except: pass item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: log_utils.error() if next: try: if not items: raise Exception() url = items[0]['next'] if not url: raise Exception() url_params = dict(parse_qsl(urlsplit(url).query)) if 'imdb.com' in url and 'start' in url_params: page = ' [I](%s)[/I]' % str(int(((int(url_params.get('start')) - 1) / int(self.count)) + 1)) else: page = ' [I](%s)[/I]' % url_params.get('page') nextMenu = '[COLOR skyblue]' + nextMenu + page + '[/COLOR]' u = urlparse(url).netloc.lower() if u not in self.tmdb_link: url = '%s?action=moviePage&url=%s' % (sysaddon, quote_plus(url)) elif u in self.tmdb_link: url = '%s?action=tmdbmoviePage&url=%s' % (sysaddon, quote_plus(url)) item = control.item(label=nextMenu, offscreen=True) icon = control.addonNext() item.setProperty('IsPlayable', 'false') item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon}) item.setProperty ('SpecialSort', 'bottom') control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: log_utils.error() control.content(syshandle, 'movies') control.directory(syshandle, cacheToDisc=True) control.sleep(500) views.setView('movies', {'skin.estuary': 55, 'skin.confluence': 500})
def movieDirectory(self, items): if items == None or len(items) == 0: return isFolder = True if control.setting('autoplay') == 'false' and control.setting('hosts.mode') == '1' else False isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder playbackMenu = control.lang(30204).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30203).encode('utf-8') traktCredentials = trakt.getTraktCredentialsInfo() indicators = playcount.getMovieIndicators() cacheToDisc = False if not action == 'movieSearch' else True addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') sysaddon = sys.argv[0] for i in items: try: label = '%s (%s)' % (i['title'], i['year']) imdb, title, year = i['imdb'], i['originaltitle'], i['year'] sysname = urllib.quote_plus('%s (%s)' % (title, year)) sysimage = urllib.quote_plus(i['poster']) 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' % (sysaddon, sysname)}) if i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: del meta['tagline'] 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) path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb) if isFolder == True: url = '%s?action=sources&title=%s&year=%s&imdb=%s&meta=%s' % (sysaddon, systitle, year, imdb, sysmeta) try: overlay = int(playcount.getMovieOverlay(indicators, imdb)) if overlay == 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))) if isFolder == False: cm.append((control.lang(30202).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon)) if traktCredentials == True: cm.append((control.lang(30208).encode('utf-8'), 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb))) cm.append((control.lang(30214).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname))) cm.append((control.lang(30205).encode('utf-8'), 'Action(Info)')) cm.append((control.lang(30206).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb))) cm.append((control.lang(30207).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb))) cm.append((control.lang(30212).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon)) 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', 'true') item.addContextMenuItems(cm, replaceItems=True) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder) except: 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([], replaceItems=True) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True) except: pass control.content(int(sys.argv[1]), 'movies') control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc) views.setView('movies', {'skin.confluence': 500})
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) if control.setting( 'hosts.mode') == '2' else control.lang(32064) queueMenu = control.lang(32065) refreshMenu = control.lang(32072) infoMenu = control.lang(32101) for i in items: try: label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(), i['title'], i['year']) sysname = urllib_parse.quote_plus('%s (%s)' % (i['title'], i['year'])) systitle = urllib_parse.quote_plus(i['title']) imdb, tmdb, year = i['imdb'], i['tmdb'], i['year'] meta = dict( (k, v) for k, v in six.iteritems(i) 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_parse.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_parse.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((infoMenu, '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=control.metadataClean(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 seasonDirectory(self, items): if items is None or len(items) == 0: control.idle() control.notification(title=32054, message=33049, icon='INFO') 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() if trakt.getTraktIndicatorsInfo() is True: watchedMenu = control.lang(32068).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') else: watchedMenu = control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32067).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') playlistManagerMenu = control.lang(35522).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') showPlaylistMenu = control.lang(35517).encode('utf-8') clearPlaylistMenu = control.lang(35516).encode('utf-8') labelMenu = control.lang(32055).encode('utf-8') playRandom = control.lang(32535).encode('utf-8') addToLibrary = control.lang(32551).encode('utf-8') 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 for i in items: try: imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i[ 'season'] title = i['tvshowtitle'] label = '%s %s' % (labelMenu, i['season']) if self.season_special is False and control.setting( 'tv.specials') == 'true': self.season_special = True if int(season) == 0 else False try: if i['unaired'] == 'true': label = '[COLOR %s][I]%s[/I][/COLOR]' % ( self.unairedcolor, label) except: pass systitle = sysname = urllib.quote_plus(title) 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, sysname) }) try: plot = meta['plot'] index = plot.rfind('See full summary') if index >= 0: plot = plot[:index] plot = plot.strip() if re.match('[a-zA-Z\d]$', plot): plot += ' ...' meta['plot'] = plot except: pass try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: meta.update({'tvshowtitle': i['label']}) except: pass try: # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date. yearNew = i['premiered'] yearNew = re.findall('(\d{4})', yearNew)[0] yearNew = yearNew.encode('utf-8') meta.update({'year': yearNew}) except: pass # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster = '0' if poster == '0' and 'thumb3' in i: poster = i['thumb3'] if poster == '0' and 'thumb2' in i: poster = i['thumb2'] if poster == '0' and 'thumb' in i: poster = i['thumb'] if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart art = {} if not poster == '0' and not poster is None: art.update({ 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster }) if not fanart == '0' and not fanart is None: art.update({'fanart': fanart}) if not icon == '0' and not icon is None: art.update({'icon': icon}) if not thumb == '0' and not thumb is None: art.update({'thumb': thumb}) if not banner == '0' and not banner is None: art.update({'banner': banner}) if not clearlogo == '0' and not clearlogo is None: art.update({'clearlogo': clearlogo}) if not clearart == '0' and not clearart is None: art.update({'clearart': clearart}) ####-Context Menu and Overlays-#### cm = [] if traktCredentials is True: cm.append(( traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)' % (sysaddon, sysname, imdb, tvdb, season))) try: indicators = playcount.getSeasonIndicators(imdb) overlay = int( playcount.getSeasonOverlay(indicators, imdb, tvdb, season)) watched = overlay == 7 if watched: meta.update({'playcount': 1, 'overlay': 7}) cm.append(( unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)' % (sysaddon, systitle, imdb, tvdb, season))) else: meta.update({'playcount': 0, 'overlay': 6}) cm.append(( watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)' % (sysaddon, systitle, imdb, tvdb, season))) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) sysart = urllib.quote_plus(json.dumps(art)) url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % ( sysaddon, systitle, year, imdb, tvdb, season) sysurl = urllib.quote_plus(url) cm.append(( playRandom, 'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)' % (sysaddon, urllib.quote_plus(systitle), urllib.quote_plus(year), urllib.quote_plus(imdb), urllib.quote_plus(tvdb), urllib.quote_plus(season)))) # cm.append((playlistManagerMenu, 'RunPlugin(%s?action=playlistManager&name=%s&url=%s&meta=%s&art=%s)' % (sysaddon, systitle, sysurl, sysmeta, sysart))) cm.append( (queueMenu, 'RunPlugin(%s?action=queueItem&name=%s)' % (sysaddon, systitle))) cm.append((showPlaylistMenu, 'RunPlugin(%s?action=showPlaylist)' % sysaddon)) cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=clearPlaylist)' % sysaddon)) cm.append(( addToLibrary, 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append(('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=openSettings&query=(0,0))' % sysaddon)) #################################### item = control.item(label=label) unwatchedEnabled = True unwatchedLimit = False if unwatchedEnabled: count = playcount.getSeasonCount(imdb, season, self.season_special, unwatchedLimit) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) total_seasons = trakt.getSeasons(imdb, full=False) if not total_seasons is None: total_seasons = [i['number'] for i in total_seasons] total_seasons = len(total_seasons) if control.setting( 'tv.specials' ) == 'false' or self.season_special is False: total_seasons = total_seasons - 1 item.setProperty('TotalSeasons', str(total_seasons)) if 'episodeIDS' in i: item.setUniqueIDs(i['episodeIDS']) if 'cast' in i: item.setCast(i['cast']) # if not fanart == '0' and not fanart is None: # item.setProperty('Fanart_Image', fanart) item.setArt(art) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.addContextMenuItems(cm) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) 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) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def seasonDirectory(self, items): if items is None or len(items) == 0: control.hide() control.notification(title = 32054, message = 33049, icon = 'INFO', sound=notificationSound) sys.exit() settingFanart = control.setting('fanart') addonPoster = control.addonPoster() addonFanart = control.addonFanart() addonBanner = control.addonBanner() try: indicators = playcount.getSeasonIndicators(items[0]['imdb']) except : pass unwatchedEnabled = control.setting('tvshows.unwatched.enabled') unwatchedLimit = False seasoncountEnabled = control.setting('tvshows.seasoncount.enabled') if trakt.getTraktIndicatorsInfo() is True: watchedMenu = control.lang(32068).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') else: watchedMenu = control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32067).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') # playlistManagerMenu = control.lang(35522).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') showPlaylistMenu = control.lang(35517).encode('utf-8') clearPlaylistMenu = control.lang(35516).encode('utf-8') labelMenu = control.lang(32055).encode('utf-8') playRandom = control.lang(32535).encode('utf-8') addToLibrary = control.lang(32551).encode('utf-8') 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 for i in items: try: imdb, tmdb, tvdb, year, season = i.get('imdb', '0'), i.get('tmdb', '0'), i.get('tvdb', '0'), i.get('year', '0'), i['season'] title = i['tvshowtitle'] label = '%s %s' % (labelMenu, i['season']) if self.season_special is False and control.setting('tv.specials') == 'true': self.season_special = True if int(season) == 0 else False try: if i['unaired'] == 'true': label = '[COLOR %s][I]%s[/I][/COLOR]' % (self.unairedcolor, label) except: pass systitle = urllib.quote_plus(title) meta = dict((k, v) for k, v in i.iteritems() if v != '0') meta.update({'code': imdb, 'imdbnumber': imdb}) meta.update({'mediatype': 'tvshow'}) meta.update({'tag': [imdb, tvdb]}) # Some descriptions have a link at the end that. Remove it. try: plot = meta['plot'] index = plot.rfind('See full summary') if index >= 0: plot = plot[:index] plot = plot.strip() if re.match('[a-zA-Z\d]$', plot): plot += ' ...' meta['plot'] = plot except: pass try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: meta.update({'tvshowtitle': i['label']}) except: pass try: # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date. yearNew = i['premiered'] yearNew = re.findall('(\d{4})', yearNew)[0] yearNew = yearNew.encode('utf-8') meta.update({'year': yearNew}) except: pass # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster1 = meta.get('poster') poster2 = meta.get('poster2') poster3 = meta.get('poster3') poster4 = meta.get('thumb') poster = poster4 or poster3 or poster2 or poster1 or addonPoster fanart = '' if settingFanart: fanart1 = meta.get('fanart') fanart2 = meta.get('fanart2') fanart3 = meta.get('fanart3') fanart = fanart3 or fanart2 or fanart1 or addonFanart # landscape = meta.get('landscape') thumb = meta.get('thumb') or poster icon = meta.get('icon') or poster banner1 = meta.get('banner') banner2 = meta.get('banner2') banner3 = meta.get('banner3') banner = banner3 or banner2 or banner1 or addonBanner clearlogo = meta.get('clearlogo') clearart = meta.get('clearart') art = {} art.update({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'fanart': fanart, 'icon': icon, 'thumb': thumb, 'banner': banner, 'clearlogo': clearlogo, 'clearart': clearart}) ####-Context Menu and Overlays-#### cm = [] if self.traktCredentials is True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)' % (sysaddon, systitle, imdb, tvdb, season))) try: overlay = int(playcount.getSeasonOverlay(indicators, imdb, tvdb, season)) watched = overlay == 7 if watched: meta.update({'playcount': 1, 'overlay': 7}) cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)' % (sysaddon, systitle, imdb, tvdb, season))) else: meta.update({'playcount': 0, 'overlay': 6}) cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)' % (sysaddon, systitle, imdb, tvdb, season))) except: pass # sysmeta = urllib.quote_plus(json.dumps(meta)) # sysart = urllib.quote_plus(json.dumps(art)) url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, season) # sysurl = urllib.quote_plus(url) cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)' % ( sysaddon, systitle, year, imdb, tvdb, season))) # cm.append((playlistManagerMenu, 'RunPlugin(%s?action=playlistManager&name=%s&url=%s&meta=%s&art=%s)' % (sysaddon, systitle, sysurl, sysmeta, sysart))) cm.append((queueMenu, 'RunPlugin(%s?action=queueItem&name=%s)' % (sysaddon, systitle))) cm.append((showPlaylistMenu, 'RunPlugin(%s?action=showPlaylist)' % sysaddon)) cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=clearPlaylist)' % sysaddon)) if control.setting('library.service.update') == 'true': cm.append((addToLibrary, 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb))) cm.append((control.lang(32610).encode('utf-8'), 'RunPlugin(%s?action=clearAllCache&opensettings=false)' % sysaddon)) cm.append(('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=openSettings)' % sysaddon)) #################################### if not i.get('trailer'): meta.update({'trailer': '%s?action=trailer&type=%s&name=%s&year=%s&imdb=%s' % (sysaddon, 'show', urllib.quote_plus(title), year, imdb)}) item = control.item(label = label) if 'castandart' in i: item.setCast(i['castandart']) if 'episodeIDS' in i: item.setUniqueIDs(i['episodeIDS']) if unwatchedEnabled == 'true': count = playcount.getSeasonCount(imdb, season, self.season_special, unwatchedLimit) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) if seasoncountEnabled == 'true' and self.traktCredentials is True: total_seasons = trakt.getSeasons(imdb, full=False) if total_seasons is not None: total_seasons = [i['number'] for i in total_seasons] season_special = True if 0 in total_seasons else False total_seasons = len(total_seasons) if control.setting('tv.specials') == 'false' and season_special is True: total_seasons = total_seasons - 1 item.setProperty('TotalSeasons', str(total_seasons)) item.setArt(art) item.setProperty('IsPlayable', 'false') if is_widget: item.setProperty('isVenom_widget', 'true') item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.addContextMenuItems(cm) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: log_utils.error() pass try: control.property(syshandle, 'showplot', items[0]['plot']) except: pass control.content(syshandle, 'seasons') control.directory(syshandle, cacheToDisc=True) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def tvshowDirectory(self, items, next=True): control.playlist.clear() if not items: # with reuselanguageinvoker on an empty directory must be loaded, do not use sys.exit() control.hide() ; control.notification(title=32002, message=33049) sysaddon, syshandle = argv[0], int(argv[1]) is_widget = 'plugin' not in control.infoLabel('Container.PluginName') settingFanart = control.setting('fanart') == 'true' addonPoster, addonFanart, addonBanner = control.addonPoster(), control.addonFanart(), control.addonBanner() indicators = getTVShowIndicators(refresh=True) unwatchedEnabled = control.setting('tvshows.unwatched.enabled') == 'true' flatten = control.setting('flatten.tvshows') == 'true' if trakt.getTraktIndicatorsInfo(): watchedMenu, unwatchedMenu = control.lang(32068), control.lang(32069) else: watchedMenu, unwatchedMenu = control.lang(32066), control.lang(32067) traktManagerMenu, queueMenu = control.lang(32070), control.lang(32065) showPlaylistMenu, clearPlaylistMenu = control.lang(35517), control.lang(35516) playRandom, addToLibrary = control.lang(32535), control.lang(32551) nextMenu = control.lang(32053) for i in items: try: imdb, tmdb, tvdb, year, trailer = i.get('imdb', ''), i.get('tmdb', ''), i.get('tvdb', ''), i.get('year', ''), i.get('trailer', '') title = i.get('tvshowtitle') or i.get('title') systitle = quote_plus(title) meta = dict((k, v) for k, v in iter(i.items()) if v is not None and v != '') meta.update({'code': imdb, 'imdbnumber': imdb, 'mediatype': 'tvshow', 'tag': [imdb, tmdb]}) # "tag" and "tagline" for movies only, but works in my skin mod so leave if unwatchedEnabled: trakt.seasonCount(imdb) # pre-cache season counts for the listed shows try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: if 'tvshowtitle' not in meta: meta.update({'tvshowtitle': title}) except: pass poster = meta.get('poster3') or meta.get('poster2') or meta.get('poster') or addonPoster landscape = meta.get('landscape') fanart = '' if settingFanart: fanart = meta.get('fanart3') or meta.get('fanart2') or meta.get('fanart') or landscape or addonFanart thumb = meta.get('thumb') or poster or landscape icon = meta.get('icon') or poster banner = meta.get('banner3') or meta.get('banner2') or meta.get('banner') or addonBanner art = {} art.update({'poster': poster, 'tvshow.poster': poster, 'fanart': fanart, 'icon': icon, 'thumb': thumb, 'banner': banner, 'clearlogo': meta.get('clearlogo', ''), 'tvshow.clearlogo': meta.get('clearlogo', ''), 'clearart': meta.get('clearart', ''), 'tvshow.clearart': meta.get('clearart', ''), 'landscape': landscape}) for k in ('poster2', 'poster3', 'fanart2', 'fanart3', 'banner2', 'banner3', 'trailer'): meta.pop(k, None) meta.update({'poster': poster, 'fanart': fanart, 'banner': banner, 'thumb': thumb, 'icon': icon}) ####-Context Menu and Overlays-#### cm = [] try: overlay = int(getTVShowOverlay(indicators, imdb, tvdb)) watched = (overlay == 5) if self.traktCredentials: cm.append((traktManagerMenu, 'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&watched=%s)' % (sysaddon, systitle, imdb, tvdb, watched))) if watched: meta.update({'playcount': 1, 'overlay': 5}) cm.append((unwatchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&query=4)' % (sysaddon, systitle, imdb, tvdb))) else: meta.update({'playcount': 0, 'overlay': 4}) cm.append((watchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&query=5)' % (sysaddon, systitle, imdb, tvdb))) except: pass sysmeta, sysart = quote_plus(jsdumps(meta)), quote_plus(jsdumps(art)) cm.append(('Find similar', 'ActivateWindow(10025,%s?action=tvshows&url=https://api.trakt.tv/shows/%s/related,return)' % (sysaddon, imdb))) cm.append((playRandom, 'RunPlugin(%s?action=play_Random&rtype=season&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&art=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysart))) cm.append((queueMenu, 'RunPlugin(%s?action=playlist_QueueItem&name=%s)' % (sysaddon, systitle))) cm.append((showPlaylistMenu, 'RunPlugin(%s?action=playlist_Show)' % sysaddon)) cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=playlist_Clear)' % sysaddon)) cm.append((addToLibrary, 'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb))) cm.append(('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=tools_openSettings)' % sysaddon)) #################################### if flatten: url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta) else: url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&art=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysart) if trailer: meta.update({'trailer': trailer}) else: meta.update({'trailer': '%s?action=play_Trailer&type=%s&name=%s&year=%s&imdb=%s' % (sysaddon, 'show', systitle, year, imdb)}) item = control.item(label=title, offscreen=True) if 'castandart' in i: item.setCast(i['castandart']) item.setArt(art) if unwatchedEnabled: try: count = getShowCount(indicators, imdb, tvdb) # this is threaded without .join() so not all results are immediately seen if count: item.setProperties({'WatchedEpisodes': str(count['watched']), 'UnWatchedEpisodes': str(count['unwatched'])}) item.setProperties({'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': str(count['total'])}) else: item.setProperties({'WatchedEpisodes': '0', 'UnWatchedEpisodes': str(meta.get('total_aired_episodes', ''))}) # temp use TMDb's "total_aired_episodes" for threads not finished....next load counts will update with trakt data item.setProperties({'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': str(meta.get('total_aired_episodes', ''))}) except: pass item.setProperty('IsPlayable', 'false') item.setProperty('tmdb_id', str(tmdb)) if is_widget: item.setProperty('isVenom_widget', 'true') item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb}) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: from resources.lib.modules import log_utils log_utils.error() if next: try: if not items: raise Exception() url = items[0]['next'] if not url: raise Exception() url_params = dict(parse_qsl(urlsplit(url).query)) if 'imdb.com' in url and 'start' in url_params: page = ' [I](%s)[/I]' % str(int(((int(url_params.get('start')) - 1) / int(self.page_limit)) + 1)) else: page = ' [I](%s)[/I]' % url_params.get('page') nextMenu = '[COLOR skyblue]' + nextMenu + page + '[/COLOR]' u = urlparse(url).netloc.lower() if u in self.imdb_link or u in self.trakt_link: url = '%s?action=tvshowPage&url=%s' % (sysaddon, quote_plus(url)) elif u in self.tmdb_link: url = '%s?action=tmdbTvshowPage&url=%s' % (sysaddon, quote_plus(url)) elif u in self.tvmaze_link: url = '%s?action=tvmazeTvshowPage&url=%s' % (sysaddon, quote_plus(url)) item = control.item(label=nextMenu, offscreen=True) icon = control.addonNext() item.setProperty('IsPlayable', 'false') item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon}) item.setProperty ('SpecialSort', 'bottom') control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: from resources.lib.modules import log_utils log_utils.error() control.content(syshandle, 'tvshows') control.directory(syshandle, cacheToDisc=True) # control.sleep(500) views.setView('tvshows', {'skin.estuary': 55, 'skin.confluence': 500})
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(), tools.Settings.getBoolean('interface.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('playback.automatic.enabled') == 'true' 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: # [BUBBLESCODE] #label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(), i['title'], i['year']) label = '[B]%s[/B][CR]%s (%s)' % (i['channel'].upper(), i['title'], i['year']) # [/BUBBLESCODE] sysname = urllib.quote_plus('%s (%s)' % (i['title'], i['year'])) systitle = urllib.quote_plus(i['title']) imdb, year = i['imdb'], i['year'] meta = dict((k,v) for k, v in i.iteritems() if not v == '0') 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 = self.parameterize('%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)) if not self.kidsOnly() and control.setting('downloads.manual.enabled') == 'true': cm.append((control.lang(33585).encode('utf-8'), 'Container.Update(%s?action=downloadsManager)' % (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 = {} poster = '0' if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart if not poster == '0' and not poster == None: art.update({'poster' : poster}) if not icon == '0' and not icon == None: art.update({'icon' : icon}) if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb}) if not banner == '0' and not banner == None: art.update({'banner' : banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) 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 seasonDirectory(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(), tools.Settings.getBoolean('interface.fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False ; control.item().getArt('type') except: isOld = True try: indicators = playcount.getSeasonIndicators(items[0]['imdb']) except: pass traktHas = trakt.getTraktIndicatorsInfo() == True watchedMenu = control.lang(32068).encode('utf-8') if traktHas else control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') if traktHas else control.lang(32067).encode('utf-8') unwatchedEnabled = tools.Settings.getBoolean('interface.tvshows.unwatched.enabled') unwatchedLimit = tools.Settings.getBoolean('interface.tvshows.unwatched.limit') queueMenu = control.lang(32065).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') media = tools.Media() 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 for i in items: try: label = None try: label = media.title(tools.Media.TypeSeason, season = i['season']) except: pass if label == None: label = i['season'] if multi == True and not label in i['tvshowtitle'] and not i['tvshowtitle'] in label: label = '%s - %s' % (i['tvshowtitle'], label) systitle = sysname = urllib.quote_plus(i['tvshowtitle']) imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i['season'] meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'tvshow'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) # Bubbles # Remove default time, since this might mislead users. Rather show no time. #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: meta.update({'tvshowtitle': i['label']}) except: pass try: # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date. yearNew = i['premiered'] yearNew = re.findall('(\d{4})', yearNew)[0] yearNew = yearNew.encode('utf-8') meta.update({'year': yearNew}) except: pass try: if season in indicators: meta.update({'playcount': 1, 'overlay': 7}) overlay = 7 else: meta.update({'playcount': 0, 'overlay': 6}) overlay = 6 except: overlay = None url = self.parameterize('%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tvdb, season)) cm = [] cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) if not traktHas: link = self.parameterize('%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7' % (sysaddon, systitle, imdb, tvdb, season)) cm.append((watchedMenu, 'RunPlugin(%s)' % link)) link = self.parameterize('%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6' % (sysaddon, systitle, imdb, tvdb, season)) cm.append((unwatchedMenu, 'RunPlugin(%s)' % link)) if traktCredentials == True: link = self.parameterize('%s?action=traktManager&tvdb=%s&season=%s' % (sysaddon, tvdb, season)) cm.append((traktManagerMenu, 'RunPlugin(%s)' % link)) if not self.kidsOnly() and control.setting('downloads.manual.enabled') == 'true': cm.append((control.lang(33585).encode('utf-8'), 'RunPlugin(%s?action=downloadsManager)' % (sysaddon))) if isOld == True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) if unwatchedEnabled and not overlay == None and not overlay == 7: try: count = playcount.getSeasonCount(imdb, season, unwatchedLimit) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) except: pass art = {} # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster = '0' if poster == '0' and 'poster3' in i: poster = i['thumb3'] if poster == '0' and 'poster2' in i: poster = i['thumb2'] if poster == '0' and 'poster' in i: poster = i['thumb'] if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart if not poster == '0' and not poster == None: art.update({'poster' : poster, 'tvshow.poster' : poster, 'season.poster' : poster}) if not icon == '0' and not icon == None: art.update({'icon' : icon}) if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb}) if not banner == '0' and not banner == None: art.update({'banner' : banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels = meta) 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) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})