def tvshows(tvshowtitle, imdb, tvdb, season, watched): control.busy() try: import sys,xbmc if not trakt.getTraktIndicatorsInfo() == False: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData(preparezip=False) name = control.addonInfo('name') dialog = control.progressDialogBG dialog.create(str(name), str(tvshowtitle)) dialog.update(0, str(name), str(tvshowtitle)) metaget.get_meta('tvshow', name='', imdb_id=imdb) items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False) try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))] except: pass items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items] for i in range(len(items)): if xbmc.abortRequested == True: return sys.exit() dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label'])) season, episode = items[i]['season'], items[i]['episode'] metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode) metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched)) try: dialog.close() except: pass except: try: dialog.close() except: pass try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if season: from resources.lib.indexers import episodes items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, season, idx=False) items = [(int(i['season']), int(i['episode'])) for i in items] items = [i[1] for i in items if int('%01d' % int(season)) == int('%01d' % i[0])] for i in items: if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, i) else: trakt.markEpisodeAsNotWatched(tvdb, season, i) else: if int(watched) == 7: trakt.markTVShowAsWatched(tvdb) else: trakt.markTVShowAsNotWatched(tvdb) trakt.cachesyncTVShows() except: pass control.refresh()
def episodes(imdb, tvdb, season, episode, watched): control.busy() try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, episode) else: trakt.markEpisodeAsNotWatched(tvdb, season, episode) trakt.cachesyncTVShows() control.refresh() except: pass try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('tvshow', name='', imdb_id=imdb) metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode) metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched)) if trakt.getTraktIndicatorsInfo() == False: control.refresh() except: pass
def getSeasonIndicators(imdb): try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() indicators = trakt.syncSeason(imdb) return indicators except: pass
def markEpisodeDuringPlayback(imdb, tvdb, season, episode, watched): try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, episode) else: trakt.markEpisodeAsNotWatched(tvdb, season, episode) trakt.cachesyncTVShows() if trakt.getTraktAddonEpisodeInfo() == True: trakt.markEpisodeAsNotWatched(tvdb, season, episode) except: pass try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('tvshow', name='', imdb_id=imdb) metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode) metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched)) except: pass
def getTVShowIndicators(refresh=False): try: if trakt.getTraktIndicatorsInfo() == True: raise Exception() from metahandler import metahandlers indicators = metahandlers.MetaData(preparezip=False) return indicators except: pass try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if refresh == False: timeout = 720 elif trakt.getWatchedActivity() < trakt.timeoutsyncTVShows(): timeout = 720 else: timeout = 0 indicators = trakt.cachesyncTVShows(timeout=timeout) return indicators except: pass
def movies(imdb, watched): control.busy() try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if int(watched) == 7: trakt.markMovieAsWatched(imdb) else: trakt.markMovieAsNotWatched(imdb) trakt.cachesyncMovies() control.refresh() except: pass try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('movie', name='', imdb_id=imdb) metaget.change_watched('movie', name='', imdb_id=imdb, watched=int(watched)) if trakt.getTraktIndicatorsInfo() == False: control.refresh() except: pass
def markMovieDuringPlayback(imdb, watched): try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if int(watched) == 7: trakt.markMovieAsWatched(imdb) else: trakt.markMovieAsNotWatched(imdb) trakt.cachesyncMovies() if trakt.getTraktAddonMovieInfo() == True: trakt.markMovieAsNotWatched(imdb) except: pass try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('movie', name='', imdb_id=imdb) metaget.change_watched('movie', name='', imdb_id=imdb, watched=int(watched)) except: pass
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})
from resources.lib.addon import control from resources.lib.addon import trakt sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) control.moderator() artPath = control.artPath() addonFanart = control.addonFanart() imdbCredentials = False if control.setting('imdb.user') == '' else True traktCredentials = trakt.getTraktCredentialsInfo() traktIndicators = trakt.getTraktIndicatorsInfo() queueMenu = control.lang(32065).encode('utf-8') uv = control.current() ua = control.setting('useramount') class navigator: def root(self): self.addDirectoryItem(32001, 'movieNavigator', 'movies.png', 'DefaultMovies.png') self.addDirectoryItem(32002, 'tvNavigator', 'tvshows.png', 'DefaultTVShows.png')
import os,sys,urlparse from resources.lib.addon import control from resources.lib.addon import trakt sysaddon = sys.argv[0] ; syshandle = int(sys.argv[1]) ; control.moderator() artPath = control.artPath() ; addonFanart = control.addonFanart() imdbCredentials = False if control.setting('imdb.user') == '' else True traktCredentials = trakt.getTraktCredentialsInfo() traktIndicators = trakt.getTraktIndicatorsInfo() queueMenu = control.lang(32065).encode('utf-8') uv =control.current() ua = control.setting('useramount') class navigator: def root(self): self.addDirectoryItem(32001, 'movieNavigator', 'movies.png', 'DefaultMovies.png') self.addDirectoryItem(32002, 'tvNavigator', 'tvshows.png', 'DefaultTVShows.png') if not control.setting('lists.widget') == '0': self.addDirectoryItem(32003, 'mymovieNavigator', 'mymovies.png', 'DefaultVideoPlaylists.png') self.addDirectoryItem(32004, 'mytvNavigator', 'mytvshows.png', 'DefaultVideoPlaylists.png')
def tvshows(tvshowtitle, imdb, tvdb, season, watched): control.busy() try: import sys, xbmc if not trakt.getTraktIndicatorsInfo() == False: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData(preparezip=False) name = control.addonInfo('name') dialog = control.progressDialogBG dialog.create(str(name), str(tvshowtitle)) dialog.update(0, str(name), str(tvshowtitle)) metaget.get_meta('tvshow', name='', imdb_id=imdb) items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False) try: items = [ i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season'])) ] except: pass items = [{ 'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode'])) } for i in items] for i in range(len(items)): if xbmc.abortRequested == True: return sys.exit() dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label'])) season, episode = items[i]['season'], items[i]['episode'] metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode) metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched)) try: dialog.close() except: pass except: try: dialog.close() except: pass try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if season: from resources.lib.indexers import episodes items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, season, idx=False) items = [(int(i['season']), int(i['episode'])) for i in items] items = [ i[1] for i in items if int('%01d' % int(season)) == int('%01d' % i[0]) ] for i in items: if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, i) else: trakt.markEpisodeAsNotWatched(tvdb, season, i) else: if int(watched) == 7: trakt.markTVShowAsWatched(tvdb) else: trakt.markTVShowAsNotWatched(tvdb) trakt.cachesyncTVShows() except: pass control.refresh()