def calculateProgress(): progress = traktlib.getProgress() shows = {} progressByShow = {} for current in progress: lastseason = 100 lastepisode = 100 allwatched = False if current['progress']['left']<>0: for season in current['seasons']: seasonnumber = int(season['season']) for episode in season ['episodes']: if not season ['episodes'][episode]: myseason,myepisode = seasonnumber,int(episode) if myseason<lastseason: lastseason = myseason lastepisode = 100 if myseason==lastseason and myepisode<lastepisode: lastepisode = myepisode #print '{0} S{1} E{2} / S{3} E{4}'.format(current['show']['title'],myseason,myepisode,lastseason,lastepisode) else: allwatched = True #print '{0} S{1} E{2}'.format(current['show']['title'],lastseason,lastepisode) #break show = {} if lastseason<>100: shows[current['show']['title']]= (lastseason,lastepisode) elif allwatched: shows[current['show']['title']]= (0,0) return shows
def calculateProgress(): progress = traktlib.getProgress() shows = [] for current in progress: showprogress = {} if current['next_episode'] <> False : lastseason = current['next_episode']['season'] lastepisode = current['next_episode']['num'] else: lastseason = 0 lastepisode= 0 showprogress['title'] = current['show']['title'] showprogress['season'] = lastseason showprogress['episode'] = lastepisode showprogress['tvdb_id'] = current['show']['tvdb_id'] shows.append(showprogress) return shows
def displayProgress(): progress = traktlib.getProgress() for current in progress: lastseason = 100 lastepisode = 100 for season in current['seasons']: seasonnumber = int(season['season']) for episode in season ['episodes']: if not season ['episodes'][episode]: myseason,myepisode = seasonnumber,int(episode) if myseason<lastseason: lastseason = myseason lastepisode = 100 if myseason==lastseason and myepisode<lastepisode: lastepisode = myepisode #print '{0} S{1} E{2} / S{3} E{4}'.format(current['show']['title'],myseason,myepisode,lastseason,lastepisode) #print '{0} S{1} E{2}'.format(current['show']['title'],lastseason,lastepisode) #break if lastseason <>100: common.createShowListItemTrakt(current['show'],len(progress),lastseason,lastepisode) common.endofDir()
def traktAction(params): if(params['action'] == 'trakt_Menu'): displayTraktMenu() elif(params['action'] == 'trakt_SearchMovies'): # Search keyboard = xbmc.Keyboard('', 'Search') keyboard.doModal() if keyboard.isConfirmed(): query = keyboard.getText() movies = traktlib.getMovieInfobySearch(unicode(query)) for movie in movies: common.createMovieListItemTrakt(movie,totalItems = len(movies)) common.endofDir() elif(params['action'] == 'trakt_SearchShows'): # Search keyboard = xbmc.Keyboard('', 'Search') keyboard.doModal() if keyboard.isConfirmed(): query = keyboard.getText() shows = traktlib.getShowInfobySearch(unicode(query)) for show in shows: common.createShowListItemTrakt(show,totalItems = len(shows)) common.endofDir() elif(params['action'] == 'trakt_SeenRate'): imdbid = params['imdbid'] traktSeenRate(imdbid) elif(params['action'] == 'trakt_DismissMovie'): imdbid = params['imdbid'] traktDismissMovie(imdbid) elif(params['action'] == 'trakt_MovieGenres'): displayGenres(type='Movie') elif(params['action'] == 'trakt_ShowGenres'): displayGenres(type='Show') elif(params['action'] == 'trakt_RecommendedShows'): try: genre = params['genre'] except: genre = None if genre: displayRecommendedShows(genre) else : url = sys.argv[0]+'?action=trakt_ShowGenres' common.createListItem('Filter by Genre', True, url) displayRecommendedShows(genre) elif(params['action'] == 'trakt_listfeeds'): myfeeds = furklib.myFeeds()['feeds'] myfeeds = sorted(myfeeds,key=lambda feed: feed['name']) url = sys.argv[0]+'?action=trakt_addfeeds' common.createListItem('Add Feeds from trakt', True, url) for feed in myfeeds: url = sys.argv[0]+'?action=trakt_MovieGenres' common.createListItem(feed['name'], True, url) common.endofDir() elif(params['action'] == 'trakt_addfeeds'): myfeeds = furklib.myFeeds()['feeds'] shows = traktlib.getWatchlistShowsfromTrakt() progress = traktlib.getProgress() series = [] for current in progress: series.append(current['show']) shows = shows + series for show in shows: check = [feed for feed in myfeeds if feed['name'] == show['title']] if len(check)==0: furklib.addFeed(show['title']) url = sys.argv[0]+'?action=trakt_MovieGenres' common.createListItem(show['title'], False, '') common.endofDir() elif(params['action'] == 'trakt_RecommendedMovies'): try: genre = params['genre'] except: genre = None if genre: displayRecommendedMovies(genre) else : url = sys.argv[0]+'?action=trakt_MovieGenres' common.createListItem('Filter by Genre', True, url) displayRecommendedMovies(genre) elif(params['action'] == 'trakt_AddShowtoWatchlist'): tvdbid = params['tvdbid'] addShowtoWatchlist(tvdbid) elif(params['action'] == 'trakt_AddMovietoWatchlist'): imdbid = params['imdbid'] addMovietoWatchlist(imdbid) elif(params['action'] == 'trakt_RemoveMoviefromWatchlist'): imdbid = params['imdbid'] response = traktlib.removeMoviefromWatchlist(imdbid) common.traktResponse(response) elif(params['action'] == 'trakt_DismissShow'): tvdbid = params['tvdbid'] traktDismissShow(tvdbid) elif(params['action'] == 'trakt_SetShowSeen'): tvdbid = params['tvdbid'] try: season = params['season'] episode = params['episode'] except: season = 100 episode = 100 response = traktSeenShow(tvdbid,season,episode) elif(params['action'] == 'trakt_TrendingMovies'): movies = traktlib.getTrendingMoviesFromTrakt() for movie in movies: common.createMovieListItemTrakt(movie,totalItems = len(movies)) common.endofDir() elif(params['action'] == 'trakt_TrendingShows'): shows = traktlib.getTrendingShowsFromTrakt() progressShows = calculateProgress() for show in shows: if show['title'] in progressShows: common.createShowListItemTrakt(show,len(shows),progressShows[show['title']][0],progressShows[show['title']][1]) else: common.createShowListItemTrakt(show,totalItems = len(shows)) common.endofDir() elif(params['action'] == 'trakt_Progress'): displayProgress() elif(params['action'] == 'trakt_getList'): user=params['user'] slug=params['slug'] displayList(user,slug) else: common.Notification('Action Not found:' , params['action'])