def find_episode(self, showname, season, episodenum): """ Find the file path for the requested episode. :param showname: The name of the show :param season: The season number of the episode :param episodenum: The episode number within the season of the episode :return: The file path for the episode requested, or None if the episode was not found :rtype: str """ episodes = self.list_episode_paths(showname, season) if episodes is None: print "Season %d not found for show %s" % (season, showname) return None candidates = filter(lambda x: mediautlils.episodenumber(x) == episodenum, episodes) if len(candidates) > 0: return candidates[0] return None
def main(): volumes = ["/Volumes/First", "/Volumes/Second", "/Users/adrian"] # volumes = ["testFolderStructure", "/cygdrive/k"] library = MediaLibrary(volumes) # List all of the shows the library has available shows = library.list_shows() print "The Library has shows:" for show in shows: print show print "\n" # List all of the movies in the library movies = library.list_movies() print "The Library has movies:" for movie in movies: print movie print "\n" # List all of the seasons for every show in the library, and their episodes for show in shows: seasons = library.list_seasons(show) episodes = library.list_episodes(show) episode_paths = library.list_episode_paths(show) print "%s has seasons:" % show for season in seasons: print "\t" + season snum = mediautlils.seasonnumber(season) season_episodes = filter(lambda x: mediautlils.seasonnumber(x) == snum, episodes) for episode in season_episodes: epnum = mediautlils.episodenumber(episode) index = episodes.index(episode) print "\t\tEpisode %d, index %d: %s -> %s" % (epnum, index, episode, episode_paths[index]) print "\n" print "\n" # # List all of the movie paths in the library movie_paths = library.list_movie_paths() print "Movies in Library:\n" for movie in movies: print "%s -> %s" % (movie, library.movie_path(movie))