def list_episodes(self, showname, snum=None):
        """
        Get the list of all of the episodes available for a given show for a given season. If no season is specified,
        it will return all of the episodes for the show.
        :param showname: The name of the show
        :param season: The season whose episodes you want. If not specified, this function will return all of the episodes
                        for the show.
        :return: A list of the episode file names for the requested show.
        :rtype: list[str]
        """
        seasons = self.list_seasons(showname)
        showdirectory = self.show_path(showname)
        ret = []

        if snum is None:
            # Get all the episodes if no season is specified
            for season in seasons:
                walk = os.walk(showdirectory + "/" + season)
                directory, _, episodes = next(walk)
                ret = ret + episodes
        else:
            seasoncandidates = filter(lambda x:mediautlils.seasonnumber(x) == snum, seasons)
            for season in seasoncandidates:
                walk = os.walk(showdirectory + "/" + season)
                directory, _, episodes = next(walk)
                ret = episodes

        # Filter out non-video files
        filtered = []
        for result in ret:
            if any(ext in result for ext in extensionsToCheck):
                filtered.append(result)

        return filtered
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))
 def list_seasons(self, show_name):
     """
     Get the list of all the seasons available for a given show. Any folder under the show directory is considered a
     season.
     :param show_name: The name of the show
     :return: A list of the seasons available for this show.
     :rtype : list[str]
     """
     show_name = self.find_show(show_name)
     rootpath = self.show_path(show_name)
     walk = os.walk(rootpath)
     try:
         _, seasons, files = next(walk)
         seasons = filter(lambda x:mediautlils.seasonnumber(x) is not None, seasons)
         return seasons
     except Exception, e:
         print "No seasons available for %s" % show_name
         return None