def getMovieInfobySearch(movietitle,movieyear): filename = '/{0} ({1})'.format(movietitle,movieyear) filename = CleanFileName(filename) filename = os.path.join(CACHE_PATH, filename+'.txt' ) movie = readMovie(filename,type='search') if movie: return getMovieInfobyImdbid(movie['imdb_id']) movies = traktlib.getMovieInfobySearch(movietitle) mymovie = None if not movies: return None for movie in movies: try: if int(movie['year']) == int(movieyear) or len(movies)==1: mymovie = getMovieInfobyImdbid(movie['imdb_id']) writeMovieInfobySearch(movietitle,movieyear,movie) break else: continue except: continue if mymovie: return movie else: return None
def getMovieInfobySearch(movietitle, movieyear): filename = '/{0} ({1})'.format(movietitle, movieyear) filename = CleanFileName(filename) filename = os.path.join(CACHE_PATH, filename + '.txt') movie = readMovie(filename, type='search') if movie: return getMovieInfobyImdbid(movie['imdb_id']) movies = traktlib.getMovieInfobySearch(movietitle) mymovie = None if not movies: return None for movie in movies: try: if int(movie['year']) == int(movieyear) or len(movies) == 1: mymovie = getMovieInfobyImdbid(movie['imdb_id']) writeMovieInfobySearch(movietitle, movieyear, movie) break else: continue except: continue if mymovie: return movie else: return None
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'])